react-listing-engine 0.7.7 → 0.7.8
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/CHANGELOG.md +6 -0
- package/dist/{chunk-JMYPJAXI.cjs → chunk-E4JVC65P.cjs} +1 -1
- package/dist/{chunk-CT3V6J2U.js → chunk-NTEMHMCX.js} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{listing-app-B2i6Ohza.d.cts → listing-app-Bna5fHSA.d.cts} +5 -5
- package/dist/{listing-app-z3cah3BH.d.ts → listing-app-D1MWFKTR.d.ts} +5 -5
- package/dist/styled/index.cjs +1 -1
- package/dist/styled/index.d.cts +2 -2
- package/dist/styled/index.d.ts +2 -2
- package/dist/styled/index.js +1 -1
- package/dist/styles.css +3 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# react-listing-engine
|
|
2
2
|
|
|
3
|
+
## 0.7.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Reposition and rename the just-added filter-bar slot: `filterBarEnd` -> `filterBarStart`, rendered BETWEEN the search box and the quick-filters row (search, [slot] | filters...). The end position read as an afterthought; an advanced-filters trigger belongs next to the search box.
|
|
8
|
+
|
|
3
9
|
## 0.7.7
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5;"use client";
|
|
2
|
-
var X= (_class =class{__init() {this.listeners=new Set}constructor(e){;_class.prototype.__init.call(this);this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:_nullishCoalesce(e.mode, () => ("paged")),loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}}, _class);var U= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.defs=new Map}add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(n=>this.defs.has(n));r.forEach((n,o)=>{this.defs.get(n).order=o});let s=new Set(r);return i.filter(n=>!s.has(n.key)).forEach((n,o)=>{n.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,s)=>({...r,...s}),{})}activeKeys(e){return this.list().filter(i=>_optionalChain([i, 'access', _2 => _2.isActive, 'optionalCall', _3 => _3(e)])).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}}, _class2);var J= (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this.defs=new Map}add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>_optionalChain([e, 'access', _4 => _4.visible, 'optionalCall', _5 => _5()])!==!1).map(e=>e.id)}}, _class3);var Y= (_class4 =class{constructor() { _class4.prototype.__init4.call(this); }__init4() {this.map=new Map}dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let s of[...i])s(e);let r=this.map.get("*");if(r)for(let s of[...r])s(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}}, _class4);var Me={pagination:"paged",pageSize:20,debounceMs:250};var ee=class{constructor(e){this.options=Object.freeze({...Me,...e})}};var te= (_class5 =class{__init5() {this.emitter=new Y}__init6() {this.debounceTimer=null}__init7() {this.debounceResolve=null}__init8() {this.queryToken=0}__init9() {this.pointsToken=0}__init10() {this.mapHandle=null}constructor(e){;_class5.prototype.__init5.call(this);_class5.prototype.__init6.call(this);_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);this.datasets=e.datasets,this.filters=_nullishCoalesce(e.filters, () => (new U)),this.map=e.map,this.config=new ee(e.config);let i=_nullishCoalesce(e.primaryDatasetId, () => (_optionalChain([this, 'access', _6 => _6.datasets, 'access', _7 => _7.list, 'call', _8 => _8(), 'access', _9 => _9[0], 'optionalAccess', _10 => _10.id])));if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${_nullishCoalesce(i, () => (""))}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new X({filters:_nullishCoalesce(e.initialFilters, () => ({})),mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(s=>{this.debounceResolve=s,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,s(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let s=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(s):this.store.setResults(s),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:s.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async s=>{let n=this.datasets.get(s);if(!n)return;let o=await n.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(s,o)}))}setMapHandle(e){this.mapHandle=e}fitBounds(e){!this.map||!this.mapHandle||this.map.fitBounds(this.mapHandle,e)}selectPoint(e,i){this.store.setSelection(i);let r=_optionalChain([this, 'access', _11 => _11.state, 'access', _12 => _12.points, 'access', _13 => _13[e], 'optionalAccess', _14 => _14.find, 'call', _15 => _15(s=>s.id===i)]);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(_nullishCoalesce(this.state.layers[e], () => (!0)));this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}}, _class5);function De(...t){let e={config:{},filters:new U,datasets:new J};for(let i of t)i(e);return e}var Oe=t=>e=>{e.config={...e.config,...t}},_e= exports.j =t=>e=>{e.map=t},Be= exports.k =t=>e=>{e.datasets.add(t)},He= exports.l =t=>e=>{t(e.filters)},ki= exports.m =t=>e=>{e.urlSync=t},Ae= exports.n =t=>e=>{e.initialFilters=t},Ii= exports.o =t=>e=>{e.primaryDatasetId=t};var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function gt(t){return String(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _16 => _16.title]), () => ("")))}var yt=({item:t})=>_jsxruntime.jsx.call(void 0, "div",{children:gt(t)}),ht=()=>_jsxruntime.jsx.call(void 0, "div",{}),ce= exports.p =()=>_jsxruntime.jsx.call(void 0, "div",{}),vt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),Lt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),bt=({value:t,onChange:e,placeholder:i})=>_jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search"))}),Tt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status",children:"No results"}),Pt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Ft=({count:t})=>_jsxruntime.jsxs.call(void 0, "div",{children:[t," results"]}),Ct=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),I={Card:yt,Marker:ht,Popup:ce,Sidebar:vt,FilterPanel:Lt,Search:bt,Empty:Tt,Loading:Pt,ResultHeader:Ft,Toolbar:Ct},ze=_react.createContext.call(void 0, I);function Ue(t){let{Card:e,Marker:i,Popup:r,Sidebar:s,FilterPanel:n,Search:o,Empty:l,Loading:d,ResultHeader:p,Toolbar:a,children:f}=t,L={Card:_nullishCoalesce(e, () => (I.Card)),Marker:_nullishCoalesce(i, () => (I.Marker)),Popup:_nullishCoalesce(r, () => (I.Popup)),Sidebar:_nullishCoalesce(s, () => (I.Sidebar)),FilterPanel:_nullishCoalesce(n, () => (I.FilterPanel)),Search:_nullishCoalesce(o, () => (I.Search)),Empty:_nullishCoalesce(l, () => (I.Empty)),Loading:_nullishCoalesce(d, () => (I.Loading)),ResultHeader:_nullishCoalesce(p, () => (I.ResultHeader)),Toolbar:_nullishCoalesce(a, () => (I.Toolbar))};return _jsxruntime.jsx.call(void 0, ze.Provider,{value:L,children:f})}function T(){return _react.useContext.call(void 0, ze)}var ie=_react.createContext.call(void 0, null);function y(){let t=_react.useContext.call(void 0, ie);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}function P(){let t=y(),e=_react.useCallback.call(void 0, r=>t.subscribe(r),[t]),i=_react.useCallback.call(void 0, ()=>t.state,[t]);return _react.useSyncExternalStore.call(void 0, e,i,i)}function re(){let t=y(),e=P(),i=_react.useCallback.call(void 0, s=>t.applyFilters(s),[t]),r=_react.useCallback.call(void 0, (s,n)=>t.applyFilters({[s]:n}),[t]);return{filters:e.filters,set:i,setField:r}}function ue({className:t,groupClassName:e,hideLabels:i,draft:r,onDraftChange:s}={}){let n=y(),{FilterPanel:o}=T(),{filters:l}=re(),d=r!==void 0&&s!==void 0,p=d?r:l;return _jsxruntime.jsx.call(void 0, o,{children:_jsxruntime.jsx.call(void 0, "div",{className:_nullishCoalesce(t, () => ("space-y-5")),children:n.filters.list().map(a=>{if(typeof a.render=="string")return _jsxruntime.jsx.call(void 0, "div",{"data-filter":a.key,className:e},a.key);let f=a.render;return _jsxruntime.jsxs.call(void 0, "div",{className:e,children:[a.label&&!i&&_jsxruntime.jsx.call(void 0, "div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:a.label}),_jsxruntime.jsx.call(void 0, f,{value:a.fromParams(p),onChange:L=>d?s(a.toParams(L)):void n.applyFilters(a.toParams(L))})]},a.key)})})})}function K(){return P().results}function xt(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function $e({className:t}={}){let e=y(),{items:i}=K(),{pagination:r,selection:s}=P(),{Card:n,Empty:o,Loading:l}=T();return r.loading&&i.length===0?_jsxruntime.jsx.call(void 0, l,{}):i.length===0?_jsxruntime.jsx.call(void 0, o,{}):_jsxruntime.jsx.call(void 0, "div",{role:"list",className:t,children:i.map((d,p)=>{let a=xt(d,p);return _jsxruntime.jsx.call(void 0, n,{item:d,selected:s===a,onSelect:()=>e.selectPoint(e.primaryDatasetId,a)},a)})})}var _reactdom = require('react-dom');var Rt={west:-179.9,south:-85,east:179.9,north:85},qe=.1,je=.02;function Mt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,s=t[0].lat;for(let{lat:l,lng:d}of t)d<e&&(e=d),d>i&&(i=d),l<r&&(r=l),l>s&&(s=l);let n=s>r?(s-r)*qe:je,o=i>e?(i-e)*qe:je;return{west:e-o,east:i+o,south:r-n,north:s+n}}function Ge(t){let{center:e,zoom:i,fallback:r,mapControls:s}=t,n=y(),o=P(),l=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, null),[a,f]=_react.useState.call(void 0, !1),L=_react.useRef.call(void 0, !1),E=_react.useRef.call(void 0, !1),C=_react.useRef.call(void 0, !1),c=n.map;_react.useEffect.call(void 0, ()=>{let b=p.current;if(!c||!b)return;let h=[];for(let u of Object.keys(o.points)){if(o.layers[u]===!1)continue;let g=n.datasets.get(u),R=_nullishCoalesce(o.points[u], () => ([])),W={id:u,markers:R.map(k=>({id:k.id,position:k.position,iconUrl:_optionalChain([g, 'optionalAccess', _17 => _17.marker, 'access', _18 => _18.iconUrl, 'optionalCall', _19 => _19(k.entity)]),element:_optionalChain([g, 'optionalAccess', _20 => _20.marker, 'access', _21 => _21.element, 'optionalCall', _22 => _22(k.entity)])})),clustering:_optionalChain([g, 'optionalAccess', _23 => _23.clustering]),onMarkerClick:k=>n.selectPoint(u,k)};h.push(c.renderLayer(b,W))}return()=>{h.forEach(u=>u())}},[n,c,a,o.points,o.layers]),_react.useEffect.call(void 0, ()=>{if(!l.current||!c)return;let b=l.current,h=!1,u=null;return(async()=>{let g=await c.mount(b,{center:e,zoom:i,fullscreenTarget:_nullishCoalesce(d.current, () => (void 0))});if(h){c.destroy(g);return}p.current=g,n.setMapHandle(g),u=c.onBoundsChange(g,R=>{C.current?C.current=!1:E.current=!0,n.loadPoints(R)}),f(!0),n.loadPoints(Rt)})(),()=>{h=!0,_optionalChain([u, 'optionalCall', _24 => _24()]),p.current&&(c.destroy(p.current),p.current=null,n.setMapHandle(null)),f(!1)}},[n,c]),_react.useEffect.call(void 0, ()=>{let b=p.current;if(!c||!b||e||L.current||E.current)return;let h=[];for(let g of Object.keys(o.points))if(o.layers[g]!==!1)for(let R of _nullishCoalesce(o.points[g], () => ([])))h.push(R.position);let u=Mt(h);u&&(L.current=!0,C.current=!0,c.fitBounds(b,u))},[c,e,a,o.points,o.layers]),_react.useEffect.call(void 0, ()=>{_optionalChain([c, 'optionalAccess', _25 => _25.updateMarkerStates, 'call', _26 => _26(o.selection,o.hovered)])},[c,a,o.selection,o.hovered]);let{Popup:x}=T(),N=x!==ce,w=_nullishCoalesce(o.points[n.primaryDatasetId], () => ([])),z=o.selection!=null?w.find(b=>b.id===o.selection):void 0,[S,D]=_react.useState.call(void 0, null),Z=_react.useRef.call(void 0, z);return Z.current=z,_react.useEffect.call(void 0, ()=>{let b=p.current;if(!c||!b||!N)return;let h=Z.current;if(!h)return;let u=c.mountOverlay(h.position);D({entity:h.entity,position:h.position,container:u.container});let g=()=>n.selectPoint(n.primaryDatasetId,null),R=k=>{k.key==="Escape"&&g()};document.addEventListener("keydown",R);let W=c.onMapClick(g);return()=>{document.removeEventListener("keydown",R),W(),u.unmount(),D(null)}},[n,c,a,o.selection,N]),_jsxruntime.jsxs.call(void 0, "div",{ref:d,className:"relative h-full min-h-0 w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:!c&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!c&&r,N&&S?_reactdom.createPortal.call(void 0, _jsxruntime.jsx.call(void 0, x,{entity:S.entity,onClose:()=>n.selectPoint(n.primaryDatasetId,null)}),S.container):null]}),s!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0",children:_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-auto",children:s})})]})}function Ze(){let t=y(),{results:e,pagination:i}=P();return e.nextCursor==null?null:_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}function Xe(){let{items:t,total:e}=K(),{ResultHeader:i}=T();return _jsxruntime.jsx.call(void 0, i,{count:t.length,total:e})}function Je(t,e){let i=y(),r=_react.useRef.call(void 0, e);r.current=e,_react.useEffect.call(void 0, ()=>i.on(t,s=>r.current(s)),[i,t])}function et(t){let{children:e,...i}=t,[r]=_react.useState.call(void 0, ()=>i),[s,n]=_react.useState.call(void 0, null);return _react.useEffect.call(void 0, ()=>{let o=new te({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),n(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),n(l=>l===o?null:l)}},[r]),s?_jsxruntime.jsx.call(void 0, ie.Provider,{value:s,children:e}):null}function V(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}function zt(t){return t?"rle-card rle-card--selected":"rle-card"}function fe({item:t,selected:e,onSelect:i}){let r=_nullishCoalesce(t, () => ({})),s=zt(e),n=_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[r.imageUrl?_jsxruntime.jsx.call(void 0, "img",{src:r.imageUrl,alt:_nullishCoalesce(r.title, () => ("")),className:"rle-card-media"}):_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-card-body",children:[r.title&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-title",children:r.title}),r.subtitle&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-address",children:r.subtitle}),r.badge&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-info",children:_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-price",children:V(r.price)})]})]});return i?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:i,"aria-pressed":_nullishCoalesce(e, () => (!1)),className:s,children:n}):_jsxruntime.jsx.call(void 0, "article",{className:s,children:n})}function ge(t){return _jsxruntime.jsxs.call(void 0, "div",{role:"status",className:"rle-empty",children:[_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"11",r:"7"}),_jsxruntime.jsx.call(void 0, "path",{d:"m21 21-4.3-4.3"})]}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-title",children:"No results"}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}function ye({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-panel",children:t})}function he(t){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rle-loading-item",children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}function ve({point:t}){let e=_nullishCoalesce(t.entity, () => ({}));return _jsxruntime.jsx.call(void 0, "span",{className:"rle-pin",children:e.price!=null?V(e.price):""})}function be({entity:t,onClose:e}){let i=_nullishCoalesce(t, () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}),_jsxruntime.jsxs.call(void 0, "div",{children:[i.title&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-title",children:i.title}),i.subtitle&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-price",children:V(i.price)})]})]})}function Te({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return _jsxruntime.jsx.call(void 0, "div",{className:"rle-result-header",children:i})}function Pe({value:t,onChange:e,placeholder:i}){return _jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search")),className:"rle-input"})}function Fe({children:t}){return _jsxruntime.jsx.call(void 0, "aside",{className:"rle-sidebar",children:t})}function Ce({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-toolbar",children:t})}var rt={Card:fe,Marker:ve,Popup:be,Sidebar:Fe,FilterPanel:ye,Search:Pe,Empty:ge,Loading:he,ResultHeader:Te,Toolbar:Ce};function nt({view:t,onViewChange:e}){return _jsxruntime.jsx.call(void 0, "nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:_jsxruntime.jsxs.call(void 0, "div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[_jsxruntime.jsx.call(void 0, Gt,{}),"List"]}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[_jsxruntime.jsx.call(void 0, Zt,{}),"Map"]})]})})}function Gt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Zt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"3",x2:"8",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}function ot({open:t,onOpenChange:e,title:i,children:r,footer:s}){let n=_react.useRef.call(void 0, null),[o,l]=_react.useState.call(void 0, !1),[d,p]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(!t){p(!1),l(!1);return}l(!0);let a=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(a)},[t]),_react.useEffect.call(void 0, ()=>{if(!o)return;let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=a}},[o]),_react.useEffect.call(void 0, ()=>{if(!o)return;_optionalChain([n, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.focus, 'call', _29 => _29()]);function a(f){f.key==="Escape"&&e(!1)}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[o,e]),!o||typeof document>"u"?null:_reactdom.createPortal.call(void 0, _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "div",{className:`rle-sheet-backdrop${d?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{ref:n,className:`rle-sheet${d?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__handle","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-sheet__header",children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__title",children:i}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:_jsxruntime.jsx.call(void 0, Yt,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__body",children:r}),s&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__footer",children:s})]})]}),document.body)}function Yt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}function at({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:s}=T();return _jsxruntime.jsxs.call(void 0, "header",{className:"rle-mobile-header",children:[t&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-mobile-header__search",children:_jsxruntime.jsx.call(void 0, s,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[_jsxruntime.jsx.call(void 0, ti,{}),_jsxruntime.jsx.call(void 0, "span",{children:"Filters"}),i>0&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-mobile-header__count",children:i})]}),r&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:_nullishCoalesce(r.icon, () => (_jsxruntime.jsx.call(void 0, ii,{})))})]})}function ti(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function ii(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"12",y1:"5",x2:"12",y2:"19"}),_jsxruntime.jsx.call(void 0, "line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}var ri=_jsxruntime.jsx.call(void 0, "div",{className:"rle-empty",children:"Map unavailable"});function ni(){let t=_react.useRef.call(void 0, null),[e,i]=_react.useState.call(void 0, !0),[r,s]=_react.useState.call(void 0, !0);return _react.useEffect.call(void 0, ()=>{let n=t.current;if(!n)return;let o=()=>{let{clientWidth:f,scrollLeft:L,scrollWidth:E}=n;i(L<=0),s(L+f>=E-1)},l=0,d=()=>{l||(l=requestAnimationFrame(()=>{l=0,o()}))};o(),n.addEventListener("scroll",o,{passive:!0});let p,a;return typeof ResizeObserver<"u"&&(p=new ResizeObserver(o),p.observe(n)),typeof MutationObserver<"u"&&(a=new MutationObserver(d),a.observe(n,{characterData:!0,childList:!0,subtree:!0})),()=>{n.removeEventListener("scroll",o),_optionalChain([p, 'optionalAccess', _30 => _30.disconnect, 'call', _31 => _31()]),_optionalChain([a, 'optionalAccess', _32 => _32.disconnect, 'call', _33 => _33()]),l&&cancelAnimationFrame(l)}},[]),{atEnd:r,atStart:e,ref:t}}function si(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,r=e,s=new Set([...Object.keys(i),...Object.keys(r)]);for(let n of s)if(i[n]!==r[n])return!1;return!0}function dt({search:t,filterBarEnd:e,toolbarEnd:i,mobileAction:r,autoFetch:s=!0,hasMap:n,mapCenter:o,mapZoom:l,mapControls:d,mobileSheetFooter:p,className:a}){let f=y(),{Search:L}=T(),E=K(),{filters:C,set:c}=re(),{pagination:x}=P(),N=_nullishCoalesce(n, () => (f.map!=null)),[w,z]=_react.useState.call(void 0, "list"),[S,D]=_react.useState.call(void 0, !1),{atEnd:Z,atStart:b,ref:h}=ni(),[u,g]=_react.useState.call(void 0, C),[R,W]=_react.useState.call(void 0, S);S!==R&&(W(S),S&&g(C));let k=pe=>g(ut=>({...ut,...pe})),[Ie,Ee]=_react.useState.call(void 0, !1),de=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{if(Ie){if(x.loading){de.current=!0;return}de.current&&(de.current=!1,Ee(!1),D(!1))}},[Ie,x.loading]);let q=t?{value:String(_nullishCoalesce(C[t.filterKey], () => (""))),onChange:pe=>{c({[t.filterKey]:pe||void 0})},placeholder:t.placeholder}:void 0;_react.useEffect.call(void 0, ()=>{s!==!1&&f.applyFilters({})},[f,s]);let xe=()=>{k(f.filters.clearedParams())},Ne=()=>{if(si(u,C)){D(!1);return}Ee(!0),f.applyFilters(u)},ct=f.filters.activeKeys(C).length,Re=_nullishCoalesce(E.total, () => (E.items.length));return _jsxruntime.jsxs.call(void 0, "div",{className:a?`rle-app ${a}`:"rle-app",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar__scroll",ref:h,children:[q&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__search",children:_jsxruntime.jsx.call(void 0, L,{value:q.value,onChange:q.onChange,placeholder:q.placeholder})}),_jsxruntime.jsx.call(void 0, ue,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0}),e&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__end",children:e})]}),!b&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!Z&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),_jsxruntime.jsx.call(void 0, at,{search:q,onFiltersClick:()=>D(!0),filterCount:ct,action:r}),_jsxruntime.jsxs.call(void 0, "div",{className:`rle-body ${N?"rle-split":"rle-body--list-only"}`,"data-mobile-view":w,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list-header",children:[_jsxruntime.jsx.call(void 0, Xe,{}),i&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-list-header__toolbar",children:i})]}),_jsxruntime.jsx.call(void 0, $e,{className:"rle-list-grid"}),_jsxruntime.jsx.call(void 0, Ze,{})]}),N&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-map",children:_jsxruntime.jsx.call(void 0, Ge,{center:o,zoom:l,fallback:ri,mapControls:d})})]}),N&&_jsxruntime.jsx.call(void 0, nt,{view:w,onViewChange:z}),_jsxruntime.jsx.call(void 0, ot,{title:"Filters",open:S,onOpenChange:D,footer:p?p({draft:u,apply:Ne,clear:xe,resultCount:Re,loading:x.loading}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:xe,children:"Clear all"}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:x.loading,onClick:Ne,children:x.loading?_jsxruntime.jsx.call(void 0, "span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${Re} results`})]}),children:_jsxruntime.jsx.call(void 0, ue,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:u,onDraftChange:k})})]})}function pt(t){return"provider"in t}function pi(t){let e=t!=null&&!pt(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,s=e?t.mapOptions:void 0,n=e?t.styles:void 0,[o,l]=_react.useState.call(void 0, ()=>!t||pt(t)?{ready:!0,provider:_optionalChain([t, 'optionalAccess', _34 => _34.provider])}:{ready:!1});return _react.useEffect.call(void 0, ()=>{if(!i)return;let d=!1;return Promise.resolve().then(() => _interopRequireWildcard(require("./maps/google/index.cjs"))).then(({googleProvider:p})=>{d||l({ready:!0,provider:p({apiKey:i,mapId:r,mapOptions:s,styles:n})})}),()=>{d=!0}},[i,r]),o}function ci({onFiltersChange:t}){let e=_react.useRef.call(void 0, t);return e.current=t,Je("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Rn(t){let{datasets:e,filters:i,map:r,components:s,initialFilters:n,onFiltersChange:o,mobileAction:l,search:d,filterBarEnd:p,toolbarEnd:a,mapControls:f,mobileSheetFooter:L,config:E,autoFetch:C,className:c}=t,{ready:x,provider:N}=pi(r);if(!x)return null;let w=[];for(let D of e)w.push(Be(D));i&&w.push(He(i)),N&&w.push(_e(N)),n&&w.push(Ae(n)),E&&w.push(Oe(E));let z=De(...w),S={...rt,...s};return _jsxruntime.jsxs.call(void 0, et,{...z,children:[o&&_jsxruntime.jsx.call(void 0, ci,{onFiltersChange:o}),_jsxruntime.jsx.call(void 0, Ue,{...S,children:_jsxruntime.jsx.call(void 0, dt,{className:c,search:d,filterBarEnd:p,toolbarEnd:a,mobileAction:l,autoFetch:C,mapCenter:_optionalChain([r, 'optionalAccess', _35 => _35.center]),mapZoom:_optionalChain([r, 'optionalAccess', _36 => _36.zoom]),mapControls:f,mobileSheetFooter:L})})]})}exports.a = X; exports.b = U; exports.c = J; exports.d = Y; exports.e = Me; exports.f = ee; exports.g = te; exports.h = De; exports.i = Oe; exports.j = _e; exports.k = Be; exports.l = He; exports.m = ki; exports.n = Ae; exports.o = Ii; exports.p = ce; exports.q = Ue; exports.r = T; exports.s = ie; exports.t = y; exports.u = P; exports.v = re; exports.w = ue; exports.x = K; exports.y = $e; exports.z = Ge; exports.A = Ze; exports.B = Xe; exports.C = Je; exports.D = et; exports.E = fe; exports.F = ge; exports.G = ye; exports.H = he; exports.I = ve; exports.J = be; exports.K = Te; exports.L = Pe; exports.M = Fe; exports.N = Ce; exports.O = rt; exports.P = nt; exports.Q = ot; exports.R = dt; exports.S = Rn;
|
|
2
|
+
var X= (_class =class{__init() {this.listeners=new Set}constructor(e){;_class.prototype.__init.call(this);this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:_nullishCoalesce(e.mode, () => ("paged")),loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}}, _class);var U= (_class2 =class{constructor() { _class2.prototype.__init2.call(this); }__init2() {this.defs=new Map}add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(n=>this.defs.has(n));r.forEach((n,o)=>{this.defs.get(n).order=o});let s=new Set(r);return i.filter(n=>!s.has(n.key)).forEach((n,o)=>{n.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,s)=>({...r,...s}),{})}activeKeys(e){return this.list().filter(i=>_optionalChain([i, 'access', _2 => _2.isActive, 'optionalCall', _3 => _3(e)])).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}}, _class2);var J= (_class3 =class{constructor() { _class3.prototype.__init3.call(this); }__init3() {this.defs=new Map}add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>_optionalChain([e, 'access', _4 => _4.visible, 'optionalCall', _5 => _5()])!==!1).map(e=>e.id)}}, _class3);var Y= (_class4 =class{constructor() { _class4.prototype.__init4.call(this); }__init4() {this.map=new Map}dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let s of[...i])s(e);let r=this.map.get("*");if(r)for(let s of[...r])s(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}}, _class4);var Me={pagination:"paged",pageSize:20,debounceMs:250};var ee=class{constructor(e){this.options=Object.freeze({...Me,...e})}};var te= (_class5 =class{__init5() {this.emitter=new Y}__init6() {this.debounceTimer=null}__init7() {this.debounceResolve=null}__init8() {this.queryToken=0}__init9() {this.pointsToken=0}__init10() {this.mapHandle=null}constructor(e){;_class5.prototype.__init5.call(this);_class5.prototype.__init6.call(this);_class5.prototype.__init7.call(this);_class5.prototype.__init8.call(this);_class5.prototype.__init9.call(this);_class5.prototype.__init10.call(this);this.datasets=e.datasets,this.filters=_nullishCoalesce(e.filters, () => (new U)),this.map=e.map,this.config=new ee(e.config);let i=_nullishCoalesce(e.primaryDatasetId, () => (_optionalChain([this, 'access', _6 => _6.datasets, 'access', _7 => _7.list, 'call', _8 => _8(), 'access', _9 => _9[0], 'optionalAccess', _10 => _10.id])));if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${_nullishCoalesce(i, () => (""))}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new X({filters:_nullishCoalesce(e.initialFilters, () => ({})),mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(s=>{this.debounceResolve=s,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,s(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let s=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(s):this.store.setResults(s),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:s.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async s=>{let n=this.datasets.get(s);if(!n)return;let o=await n.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(s,o)}))}setMapHandle(e){this.mapHandle=e}fitBounds(e){!this.map||!this.mapHandle||this.map.fitBounds(this.mapHandle,e)}selectPoint(e,i){this.store.setSelection(i);let r=_optionalChain([this, 'access', _11 => _11.state, 'access', _12 => _12.points, 'access', _13 => _13[e], 'optionalAccess', _14 => _14.find, 'call', _15 => _15(s=>s.id===i)]);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(_nullishCoalesce(this.state.layers[e], () => (!0)));this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}}, _class5);function De(...t){let e={config:{},filters:new U,datasets:new J};for(let i of t)i(e);return e}var Oe=t=>e=>{e.config={...e.config,...t}},_e= exports.j =t=>e=>{e.map=t},Be= exports.k =t=>e=>{e.datasets.add(t)},He= exports.l =t=>e=>{t(e.filters)},ki= exports.m =t=>e=>{e.urlSync=t},Ae= exports.n =t=>e=>{e.initialFilters=t},Ii= exports.o =t=>e=>{e.primaryDatasetId=t};var _react = require('react');var _jsxruntime = require('react/jsx-runtime');function gt(t){return String(_nullishCoalesce(_optionalChain([t, 'optionalAccess', _16 => _16.title]), () => ("")))}var yt=({item:t})=>_jsxruntime.jsx.call(void 0, "div",{children:gt(t)}),ht=()=>_jsxruntime.jsx.call(void 0, "div",{}),ce= exports.p =()=>_jsxruntime.jsx.call(void 0, "div",{}),vt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),Lt=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),bt=({value:t,onChange:e,placeholder:i})=>_jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search"))}),Tt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status",children:"No results"}),Pt=()=>_jsxruntime.jsx.call(void 0, "div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Ft=({count:t})=>_jsxruntime.jsxs.call(void 0, "div",{children:[t," results"]}),Ct=({children:t})=>_jsxruntime.jsx.call(void 0, "div",{children:t}),I={Card:yt,Marker:ht,Popup:ce,Sidebar:vt,FilterPanel:Lt,Search:bt,Empty:Tt,Loading:Pt,ResultHeader:Ft,Toolbar:Ct},ze=_react.createContext.call(void 0, I);function Ue(t){let{Card:e,Marker:i,Popup:r,Sidebar:s,FilterPanel:n,Search:o,Empty:l,Loading:d,ResultHeader:p,Toolbar:a,children:f}=t,L={Card:_nullishCoalesce(e, () => (I.Card)),Marker:_nullishCoalesce(i, () => (I.Marker)),Popup:_nullishCoalesce(r, () => (I.Popup)),Sidebar:_nullishCoalesce(s, () => (I.Sidebar)),FilterPanel:_nullishCoalesce(n, () => (I.FilterPanel)),Search:_nullishCoalesce(o, () => (I.Search)),Empty:_nullishCoalesce(l, () => (I.Empty)),Loading:_nullishCoalesce(d, () => (I.Loading)),ResultHeader:_nullishCoalesce(p, () => (I.ResultHeader)),Toolbar:_nullishCoalesce(a, () => (I.Toolbar))};return _jsxruntime.jsx.call(void 0, ze.Provider,{value:L,children:f})}function T(){return _react.useContext.call(void 0, ze)}var ie=_react.createContext.call(void 0, null);function y(){let t=_react.useContext.call(void 0, ie);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}function P(){let t=y(),e=_react.useCallback.call(void 0, r=>t.subscribe(r),[t]),i=_react.useCallback.call(void 0, ()=>t.state,[t]);return _react.useSyncExternalStore.call(void 0, e,i,i)}function re(){let t=y(),e=P(),i=_react.useCallback.call(void 0, s=>t.applyFilters(s),[t]),r=_react.useCallback.call(void 0, (s,n)=>t.applyFilters({[s]:n}),[t]);return{filters:e.filters,set:i,setField:r}}function ue({className:t,groupClassName:e,hideLabels:i,draft:r,onDraftChange:s}={}){let n=y(),{FilterPanel:o}=T(),{filters:l}=re(),d=r!==void 0&&s!==void 0,p=d?r:l;return _jsxruntime.jsx.call(void 0, o,{children:_jsxruntime.jsx.call(void 0, "div",{className:_nullishCoalesce(t, () => ("space-y-5")),children:n.filters.list().map(a=>{if(typeof a.render=="string")return _jsxruntime.jsx.call(void 0, "div",{"data-filter":a.key,className:e},a.key);let f=a.render;return _jsxruntime.jsxs.call(void 0, "div",{className:e,children:[a.label&&!i&&_jsxruntime.jsx.call(void 0, "div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:a.label}),_jsxruntime.jsx.call(void 0, f,{value:a.fromParams(p),onChange:L=>d?s(a.toParams(L)):void n.applyFilters(a.toParams(L))})]},a.key)})})})}function K(){return P().results}function xt(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function $e({className:t}={}){let e=y(),{items:i}=K(),{pagination:r,selection:s}=P(),{Card:n,Empty:o,Loading:l}=T();return r.loading&&i.length===0?_jsxruntime.jsx.call(void 0, l,{}):i.length===0?_jsxruntime.jsx.call(void 0, o,{}):_jsxruntime.jsx.call(void 0, "div",{role:"list",className:t,children:i.map((d,p)=>{let a=xt(d,p);return _jsxruntime.jsx.call(void 0, n,{item:d,selected:s===a,onSelect:()=>e.selectPoint(e.primaryDatasetId,a)},a)})})}var _reactdom = require('react-dom');var Rt={west:-179.9,south:-85,east:179.9,north:85},qe=.1,je=.02;function Mt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,s=t[0].lat;for(let{lat:l,lng:d}of t)d<e&&(e=d),d>i&&(i=d),l<r&&(r=l),l>s&&(s=l);let n=s>r?(s-r)*qe:je,o=i>e?(i-e)*qe:je;return{west:e-o,east:i+o,south:r-n,north:s+n}}function Ge(t){let{center:e,zoom:i,fallback:r,mapControls:s}=t,n=y(),o=P(),l=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),p=_react.useRef.call(void 0, null),[a,f]=_react.useState.call(void 0, !1),L=_react.useRef.call(void 0, !1),E=_react.useRef.call(void 0, !1),C=_react.useRef.call(void 0, !1),c=n.map;_react.useEffect.call(void 0, ()=>{let b=p.current;if(!c||!b)return;let h=[];for(let u of Object.keys(o.points)){if(o.layers[u]===!1)continue;let g=n.datasets.get(u),R=_nullishCoalesce(o.points[u], () => ([])),W={id:u,markers:R.map(k=>({id:k.id,position:k.position,iconUrl:_optionalChain([g, 'optionalAccess', _17 => _17.marker, 'access', _18 => _18.iconUrl, 'optionalCall', _19 => _19(k.entity)]),element:_optionalChain([g, 'optionalAccess', _20 => _20.marker, 'access', _21 => _21.element, 'optionalCall', _22 => _22(k.entity)])})),clustering:_optionalChain([g, 'optionalAccess', _23 => _23.clustering]),onMarkerClick:k=>n.selectPoint(u,k)};h.push(c.renderLayer(b,W))}return()=>{h.forEach(u=>u())}},[n,c,a,o.points,o.layers]),_react.useEffect.call(void 0, ()=>{if(!l.current||!c)return;let b=l.current,h=!1,u=null;return(async()=>{let g=await c.mount(b,{center:e,zoom:i,fullscreenTarget:_nullishCoalesce(d.current, () => (void 0))});if(h){c.destroy(g);return}p.current=g,n.setMapHandle(g),u=c.onBoundsChange(g,R=>{C.current?C.current=!1:E.current=!0,n.loadPoints(R)}),f(!0),n.loadPoints(Rt)})(),()=>{h=!0,_optionalChain([u, 'optionalCall', _24 => _24()]),p.current&&(c.destroy(p.current),p.current=null,n.setMapHandle(null)),f(!1)}},[n,c]),_react.useEffect.call(void 0, ()=>{let b=p.current;if(!c||!b||e||L.current||E.current)return;let h=[];for(let g of Object.keys(o.points))if(o.layers[g]!==!1)for(let R of _nullishCoalesce(o.points[g], () => ([])))h.push(R.position);let u=Mt(h);u&&(L.current=!0,C.current=!0,c.fitBounds(b,u))},[c,e,a,o.points,o.layers]),_react.useEffect.call(void 0, ()=>{_optionalChain([c, 'optionalAccess', _25 => _25.updateMarkerStates, 'call', _26 => _26(o.selection,o.hovered)])},[c,a,o.selection,o.hovered]);let{Popup:x}=T(),N=x!==ce,S=_nullishCoalesce(o.points[n.primaryDatasetId], () => ([])),z=o.selection!=null?S.find(b=>b.id===o.selection):void 0,[w,D]=_react.useState.call(void 0, null),Z=_react.useRef.call(void 0, z);return Z.current=z,_react.useEffect.call(void 0, ()=>{let b=p.current;if(!c||!b||!N)return;let h=Z.current;if(!h)return;let u=c.mountOverlay(h.position);D({entity:h.entity,position:h.position,container:u.container});let g=()=>n.selectPoint(n.primaryDatasetId,null),R=k=>{k.key==="Escape"&&g()};document.addEventListener("keydown",R);let W=c.onMapClick(g);return()=>{document.removeEventListener("keydown",R),W(),u.unmount(),D(null)}},[n,c,a,o.selection,N]),_jsxruntime.jsxs.call(void 0, "div",{ref:d,className:"relative h-full min-h-0 w-full",children:[_jsxruntime.jsxs.call(void 0, "div",{ref:l,className:!c&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!c&&r,N&&w?_reactdom.createPortal.call(void 0, _jsxruntime.jsx.call(void 0, x,{entity:w.entity,onClose:()=>n.selectPoint(n.primaryDatasetId,null)}),w.container):null]}),s!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-none absolute inset-0",children:_jsxruntime.jsx.call(void 0, "div",{className:"pointer-events-auto",children:s})})]})}function Ze(){let t=y(),{results:e,pagination:i}=P();return e.nextCursor==null?null:_jsxruntime.jsx.call(void 0, "button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}function Xe(){let{items:t,total:e}=K(),{ResultHeader:i}=T();return _jsxruntime.jsx.call(void 0, i,{count:t.length,total:e})}function Je(t,e){let i=y(),r=_react.useRef.call(void 0, e);r.current=e,_react.useEffect.call(void 0, ()=>i.on(t,s=>r.current(s)),[i,t])}function et(t){let{children:e,...i}=t,[r]=_react.useState.call(void 0, ()=>i),[s,n]=_react.useState.call(void 0, null);return _react.useEffect.call(void 0, ()=>{let o=new te({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),n(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),n(l=>l===o?null:l)}},[r]),s?_jsxruntime.jsx.call(void 0, ie.Provider,{value:s,children:e}):null}function V(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}function zt(t){return t?"rle-card rle-card--selected":"rle-card"}function fe({item:t,selected:e,onSelect:i}){let r=_nullishCoalesce(t, () => ({})),s=zt(e),n=_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[r.imageUrl?_jsxruntime.jsx.call(void 0, "img",{src:r.imageUrl,alt:_nullishCoalesce(r.title, () => ("")),className:"rle-card-media"}):_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-card-body",children:[r.title&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-title",children:r.title}),r.subtitle&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-address",children:r.subtitle}),r.badge&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-info",children:_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-card-price",children:V(r.price)})]})]});return i?_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:i,"aria-pressed":_nullishCoalesce(e, () => (!1)),className:s,children:n}):_jsxruntime.jsx.call(void 0, "article",{className:s,children:n})}function ge(t){return _jsxruntime.jsxs.call(void 0, "div",{role:"status",className:"rle-empty",children:[_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"11",r:"7"}),_jsxruntime.jsx.call(void 0, "path",{d:"m21 21-4.3-4.3"})]}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-title",children:"No results"}),_jsxruntime.jsx.call(void 0, "p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}function ye({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-panel",children:t})}function he(t){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>_jsxruntime.jsxs.call(void 0, "div",{className:"rle-loading-item",children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}function ve({point:t}){let e=_nullishCoalesce(t.entity, () => ({}));return _jsxruntime.jsx.call(void 0, "span",{className:"rle-pin",children:e.price!=null?V(e.price):""})}function be({entity:t,onClose:e}){let i=_nullishCoalesce(t, () => ({}));return _jsxruntime.jsxs.call(void 0, "div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:_jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}),_jsxruntime.jsxs.call(void 0, "div",{children:[i.title&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-title",children:i.title}),i.subtitle&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-card-price",children:V(i.price)})]})]})}function Te({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return _jsxruntime.jsx.call(void 0, "div",{className:"rle-result-header",children:i})}function Pe({value:t,onChange:e,placeholder:i}){return _jsxruntime.jsx.call(void 0, "input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":_nullishCoalesce(i, () => ("Search")),className:"rle-input"})}function Fe({children:t}){return _jsxruntime.jsx.call(void 0, "aside",{className:"rle-sidebar",children:t})}function Ce({children:t}){return _jsxruntime.jsx.call(void 0, "div",{className:"rle-toolbar",children:t})}var rt={Card:fe,Marker:ve,Popup:be,Sidebar:Fe,FilterPanel:ye,Search:Pe,Empty:ge,Loading:he,ResultHeader:Te,Toolbar:Ce};function nt({view:t,onViewChange:e}){return _jsxruntime.jsx.call(void 0, "nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:_jsxruntime.jsxs.call(void 0, "div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[_jsxruntime.jsx.call(void 0, Gt,{}),"List"]}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[_jsxruntime.jsx.call(void 0, Zt,{}),"Map"]})]})})}function Gt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Zt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),_jsxruntime.jsx.call(void 0, "line",{x1:"8",y1:"3",x2:"8",y2:"18"}),_jsxruntime.jsx.call(void 0, "line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}function ot({open:t,onOpenChange:e,title:i,children:r,footer:s}){let n=_react.useRef.call(void 0, null),[o,l]=_react.useState.call(void 0, !1),[d,p]=_react.useState.call(void 0, !1);return _react.useEffect.call(void 0, ()=>{if(!t){p(!1),l(!1);return}l(!0);let a=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(a)},[t]),_react.useEffect.call(void 0, ()=>{if(!o)return;let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=a}},[o]),_react.useEffect.call(void 0, ()=>{if(!o)return;_optionalChain([n, 'access', _27 => _27.current, 'optionalAccess', _28 => _28.focus, 'call', _29 => _29()]);function a(f){f.key==="Escape"&&e(!1)}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[o,e]),!o||typeof document>"u"?null:_reactdom.createPortal.call(void 0, _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "div",{className:`rle-sheet-backdrop${d?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{ref:n,className:`rle-sheet${d?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__handle","aria-hidden":"true"}),_jsxruntime.jsxs.call(void 0, "div",{className:"rle-sheet__header",children:[i&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__title",children:i}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:_jsxruntime.jsx.call(void 0, Yt,{})})]}),_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__body",children:r}),s&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-sheet__footer",children:s})]})]}),document.body)}function Yt(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "path",{d:"M18 6 6 18"}),_jsxruntime.jsx.call(void 0, "path",{d:"m6 6 12 12"})]})}function at({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:s}=T();return _jsxruntime.jsxs.call(void 0, "header",{className:"rle-mobile-header",children:[t&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-mobile-header__search",children:_jsxruntime.jsx.call(void 0, s,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),_jsxruntime.jsxs.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[_jsxruntime.jsx.call(void 0, ti,{}),_jsxruntime.jsx.call(void 0, "span",{children:"Filters"}),i>0&&_jsxruntime.jsx.call(void 0, "span",{className:"rle-mobile-header__count",children:i})]}),r&&_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:_nullishCoalesce(r.icon, () => (_jsxruntime.jsx.call(void 0, ii,{})))})]})}function ti(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"6",x2:"20",y2:"6"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"12",x2:"20",y2:"12"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),_jsxruntime.jsx.call(void 0, "line",{x1:"4",y1:"18",x2:"20",y2:"18"}),_jsxruntime.jsx.call(void 0, "circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function ii(){return _jsxruntime.jsxs.call(void 0, "svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[_jsxruntime.jsx.call(void 0, "line",{x1:"12",y1:"5",x2:"12",y2:"19"}),_jsxruntime.jsx.call(void 0, "line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}var ri=_jsxruntime.jsx.call(void 0, "div",{className:"rle-empty",children:"Map unavailable"});function ni(){let t=_react.useRef.call(void 0, null),[e,i]=_react.useState.call(void 0, !0),[r,s]=_react.useState.call(void 0, !0);return _react.useEffect.call(void 0, ()=>{let n=t.current;if(!n)return;let o=()=>{let{clientWidth:f,scrollLeft:L,scrollWidth:E}=n;i(L<=0),s(L+f>=E-1)},l=0,d=()=>{l||(l=requestAnimationFrame(()=>{l=0,o()}))};o(),n.addEventListener("scroll",o,{passive:!0});let p,a;return typeof ResizeObserver<"u"&&(p=new ResizeObserver(o),p.observe(n)),typeof MutationObserver<"u"&&(a=new MutationObserver(d),a.observe(n,{characterData:!0,childList:!0,subtree:!0})),()=>{n.removeEventListener("scroll",o),_optionalChain([p, 'optionalAccess', _30 => _30.disconnect, 'call', _31 => _31()]),_optionalChain([a, 'optionalAccess', _32 => _32.disconnect, 'call', _33 => _33()]),l&&cancelAnimationFrame(l)}},[]),{atEnd:r,atStart:e,ref:t}}function si(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,r=e,s=new Set([...Object.keys(i),...Object.keys(r)]);for(let n of s)if(i[n]!==r[n])return!1;return!0}function dt({search:t,filterBarStart:e,toolbarEnd:i,mobileAction:r,autoFetch:s=!0,hasMap:n,mapCenter:o,mapZoom:l,mapControls:d,mobileSheetFooter:p,className:a}){let f=y(),{Search:L}=T(),E=K(),{filters:C,set:c}=re(),{pagination:x}=P(),N=_nullishCoalesce(n, () => (f.map!=null)),[S,z]=_react.useState.call(void 0, "list"),[w,D]=_react.useState.call(void 0, !1),{atEnd:Z,atStart:b,ref:h}=ni(),[u,g]=_react.useState.call(void 0, C),[R,W]=_react.useState.call(void 0, w);w!==R&&(W(w),w&&g(C));let k=pe=>g(ut=>({...ut,...pe})),[Ie,Ee]=_react.useState.call(void 0, !1),de=_react.useRef.call(void 0, !1);_react.useEffect.call(void 0, ()=>{if(Ie){if(x.loading){de.current=!0;return}de.current&&(de.current=!1,Ee(!1),D(!1))}},[Ie,x.loading]);let q=t?{value:String(_nullishCoalesce(C[t.filterKey], () => (""))),onChange:pe=>{c({[t.filterKey]:pe||void 0})},placeholder:t.placeholder}:void 0;_react.useEffect.call(void 0, ()=>{s!==!1&&f.applyFilters({})},[f,s]);let xe=()=>{k(f.filters.clearedParams())},Ne=()=>{if(si(u,C)){D(!1);return}Ee(!0),f.applyFilters(u)},ct=f.filters.activeKeys(C).length,Re=_nullishCoalesce(E.total, () => (E.items.length));return _jsxruntime.jsxs.call(void 0, "div",{className:a?`rle-app ${a}`:"rle-app",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-filter-bar__scroll",ref:h,children:[q&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__search",children:_jsxruntime.jsx.call(void 0, L,{value:q.value,onChange:q.onChange,placeholder:q.placeholder})}),e&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__slot",children:e}),_jsxruntime.jsx.call(void 0, ue,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!b&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!Z&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),_jsxruntime.jsx.call(void 0, at,{search:q,onFiltersClick:()=>D(!0),filterCount:ct,action:r}),_jsxruntime.jsxs.call(void 0, "div",{className:`rle-body ${N?"rle-split":"rle-body--list-only"}`,"data-mobile-view":S,children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"rle-list-header",children:[_jsxruntime.jsx.call(void 0, Xe,{}),i&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-list-header__toolbar",children:i})]}),_jsxruntime.jsx.call(void 0, $e,{className:"rle-list-grid"}),_jsxruntime.jsx.call(void 0, Ze,{})]}),N&&_jsxruntime.jsx.call(void 0, "div",{className:"rle-map",children:_jsxruntime.jsx.call(void 0, Ge,{center:o,zoom:l,fallback:ri,mapControls:d})})]}),N&&_jsxruntime.jsx.call(void 0, nt,{view:S,onViewChange:z}),_jsxruntime.jsx.call(void 0, ot,{title:"Filters",open:w,onOpenChange:D,footer:p?p({draft:u,apply:Ne,clear:xe,resultCount:Re,loading:x.loading}):_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:xe,children:"Clear all"}),_jsxruntime.jsx.call(void 0, "button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:x.loading,onClick:Ne,children:x.loading?_jsxruntime.jsx.call(void 0, "span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${Re} results`})]}),children:_jsxruntime.jsx.call(void 0, ue,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:u,onDraftChange:k})})]})}function pt(t){return"provider"in t}function pi(t){let e=t!=null&&!pt(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,s=e?t.mapOptions:void 0,n=e?t.styles:void 0,[o,l]=_react.useState.call(void 0, ()=>!t||pt(t)?{ready:!0,provider:_optionalChain([t, 'optionalAccess', _34 => _34.provider])}:{ready:!1});return _react.useEffect.call(void 0, ()=>{if(!i)return;let d=!1;return Promise.resolve().then(() => _interopRequireWildcard(require("./maps/google/index.cjs"))).then(({googleProvider:p})=>{d||l({ready:!0,provider:p({apiKey:i,mapId:r,mapOptions:s,styles:n})})}),()=>{d=!0}},[i,r]),o}function ci({onFiltersChange:t}){let e=_react.useRef.call(void 0, t);return e.current=t,Je("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Rn(t){let{datasets:e,filters:i,map:r,components:s,initialFilters:n,onFiltersChange:o,mobileAction:l,search:d,filterBarStart:p,toolbarEnd:a,mapControls:f,mobileSheetFooter:L,config:E,autoFetch:C,className:c}=t,{ready:x,provider:N}=pi(r);if(!x)return null;let S=[];for(let D of e)S.push(Be(D));i&&S.push(He(i)),N&&S.push(_e(N)),n&&S.push(Ae(n)),E&&S.push(Oe(E));let z=De(...S),w={...rt,...s};return _jsxruntime.jsxs.call(void 0, et,{...z,children:[o&&_jsxruntime.jsx.call(void 0, ci,{onFiltersChange:o}),_jsxruntime.jsx.call(void 0, Ue,{...w,children:_jsxruntime.jsx.call(void 0, dt,{className:c,search:d,filterBarStart:p,toolbarEnd:a,mobileAction:l,autoFetch:C,mapCenter:_optionalChain([r, 'optionalAccess', _35 => _35.center]),mapZoom:_optionalChain([r, 'optionalAccess', _36 => _36.zoom]),mapControls:f,mobileSheetFooter:L})})]})}exports.a = X; exports.b = U; exports.c = J; exports.d = Y; exports.e = Me; exports.f = ee; exports.g = te; exports.h = De; exports.i = Oe; exports.j = _e; exports.k = Be; exports.l = He; exports.m = ki; exports.n = Ae; exports.o = Ii; exports.p = ce; exports.q = Ue; exports.r = T; exports.s = ie; exports.t = y; exports.u = P; exports.v = re; exports.w = ue; exports.x = K; exports.y = $e; exports.z = Ge; exports.A = Ze; exports.B = Xe; exports.C = Je; exports.D = et; exports.E = fe; exports.F = ge; exports.G = ye; exports.H = he; exports.I = ve; exports.J = be; exports.K = Te; exports.L = Pe; exports.M = Fe; exports.N = Ce; exports.O = rt; exports.P = nt; exports.Q = ot; exports.R = dt; exports.S = Rn;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
var X=class{state;listeners=new Set;constructor(e){this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:e.mode??"paged",loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}};var U=class{defs=new Map;add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(n=>this.defs.has(n));r.forEach((n,o)=>{this.defs.get(n).order=o});let s=new Set(r);return i.filter(n=>!s.has(n.key)).forEach((n,o)=>{n.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,s)=>({...r,...s}),{})}activeKeys(e){return this.list().filter(i=>i.isActive?.(e)).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}};var J=class{defs=new Map;add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>e.visible?.()!==!1).map(e=>e.id)}};var Y=class{map=new Map;dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let s of[...i])s(e);let r=this.map.get("*");if(r)for(let s of[...r])s(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}};var Me={pagination:"paged",pageSize:20,debounceMs:250};var ee=class{options;constructor(e){this.options=Object.freeze({...Me,...e})}};var te=class{filters;map;datasets;primaryDatasetId;store;emitter=new Y;config;debounceTimer=null;debounceResolve=null;queryToken=0;pointsToken=0;mapHandle=null;constructor(e){this.datasets=e.datasets,this.filters=e.filters??new U,this.map=e.map,this.config=new ee(e.config);let i=e.primaryDatasetId??this.datasets.list()[0]?.id;if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${i??""}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new X({filters:e.initialFilters??{},mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(s=>{this.debounceResolve=s,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,s(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let s=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(s):this.store.setResults(s),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:s.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async s=>{let n=this.datasets.get(s);if(!n)return;let o=await n.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(s,o)}))}setMapHandle(e){this.mapHandle=e}fitBounds(e){!this.map||!this.mapHandle||this.map.fitBounds(this.mapHandle,e)}selectPoint(e,i){this.store.setSelection(i);let r=this.state.points[e]?.find(s=>s.id===i);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(this.state.layers[e]??!0);this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}};function De(...t){let e={config:{},filters:new U,datasets:new J};for(let i of t)i(e);return e}var Oe=t=>e=>{e.config={...e.config,...t}},_e=t=>e=>{e.map=t},Be=t=>e=>{e.datasets.add(t)},He=t=>e=>{t(e.filters)},ki=t=>e=>{e.urlSync=t},Ae=t=>e=>{e.initialFilters=t},Ii=t=>e=>{e.primaryDatasetId=t};import{createContext as mt,useContext as ft}from"react";import{jsx as M,jsxs as wt}from"react/jsx-runtime";function gt(t){return String(t?.title??"")}var yt=({item:t})=>M("div",{children:gt(t)}),ht=()=>M("div",{}),ce=()=>M("div",{}),vt=({children:t})=>M("div",{children:t}),Lt=({children:t})=>M("div",{children:t}),bt=({value:t,onChange:e,placeholder:i})=>M("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search"}),Tt=()=>M("div",{role:"status",children:"No results"}),Pt=()=>M("div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Ft=({count:t})=>wt("div",{children:[t," results"]}),Ct=({children:t})=>M("div",{children:t}),I={Card:yt,Marker:ht,Popup:ce,Sidebar:vt,FilterPanel:Lt,Search:bt,Empty:Tt,Loading:Pt,ResultHeader:Ft,Toolbar:Ct},ze=mt(I);function Ue(t){let{Card:e,Marker:i,Popup:r,Sidebar:s,FilterPanel:n,Search:o,Empty:l,Loading:d,ResultHeader:p,Toolbar:a,children:f}=t,L={Card:e??I.Card,Marker:i??I.Marker,Popup:r??I.Popup,Sidebar:s??I.Sidebar,FilterPanel:n??I.FilterPanel,Search:o??I.Search,Empty:l??I.Empty,Loading:d??I.Loading,ResultHeader:p??I.ResultHeader,Toolbar:a??I.Toolbar};return M(ze.Provider,{value:L,children:f})}function T(){return ft(ze)}import{createContext as St}from"react";var ie=St(null);import{useContext as kt}from"react";function y(){let t=kt(ie);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}import{useCallback as Ke,useSyncExternalStore as It}from"react";function P(){let t=y(),e=Ke(r=>t.subscribe(r),[t]),i=Ke(()=>t.state,[t]);return It(e,i,i)}import{useCallback as Ve}from"react";function re(){let t=y(),e=P(),i=Ve(s=>t.applyFilters(s),[t]),r=Ve((s,n)=>t.applyFilters({[s]:n}),[t]);return{filters:e.filters,set:i,setField:r}}import{jsx as j,jsxs as Et}from"react/jsx-runtime";function ue({className:t,groupClassName:e,hideLabels:i,draft:r,onDraftChange:s}={}){let n=y(),{FilterPanel:o}=T(),{filters:l}=re(),d=r!==void 0&&s!==void 0,p=d?r:l;return j(o,{children:j("div",{className:t??"space-y-5",children:n.filters.list().map(a=>{if(typeof a.render=="string")return j("div",{"data-filter":a.key,className:e},a.key);let f=a.render;return Et("div",{className:e,children:[a.label&&!i&&j("div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:a.label}),j(f,{value:a.fromParams(p),onChange:L=>d?s(a.toParams(L)):void n.applyFilters(a.toParams(L))})]},a.key)})})})}function K(){return P().results}import{jsx as ne}from"react/jsx-runtime";function xt(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function $e({className:t}={}){let e=y(),{items:i}=K(),{pagination:r,selection:s}=P(),{Card:n,Empty:o,Loading:l}=T();return r.loading&&i.length===0?ne(l,{}):i.length===0?ne(o,{}):ne("div",{role:"list",className:t,children:i.map((d,p)=>{let a=xt(d,p);return ne(n,{item:d,selected:s===a,onSelect:()=>e.selectPoint(e.primaryDatasetId,a)},a)})})}import{useEffect as Q,useRef as B,useState as We}from"react";import{createPortal as Nt}from"react-dom";import{jsx as me,jsxs as Qe}from"react/jsx-runtime";var Rt={west:-179.9,south:-85,east:179.9,north:85},qe=.1,je=.02;function Mt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,s=t[0].lat;for(let{lat:l,lng:d}of t)d<e&&(e=d),d>i&&(i=d),l<r&&(r=l),l>s&&(s=l);let n=s>r?(s-r)*qe:je,o=i>e?(i-e)*qe:je;return{west:e-o,east:i+o,south:r-n,north:s+n}}function Ge(t){let{center:e,zoom:i,fallback:r,mapControls:s}=t,n=y(),o=P(),l=B(null),d=B(null),p=B(null),[a,f]=We(!1),L=B(!1),E=B(!1),C=B(!1),c=n.map;Q(()=>{let b=p.current;if(!c||!b)return;let h=[];for(let u of Object.keys(o.points)){if(o.layers[u]===!1)continue;let g=n.datasets.get(u),R=o.points[u]??[],W={id:u,markers:R.map(k=>({id:k.id,position:k.position,iconUrl:g?.marker.iconUrl?.(k.entity),element:g?.marker.element?.(k.entity)})),clustering:g?.clustering,onMarkerClick:k=>n.selectPoint(u,k)};h.push(c.renderLayer(b,W))}return()=>{h.forEach(u=>u())}},[n,c,a,o.points,o.layers]),Q(()=>{if(!l.current||!c)return;let b=l.current,h=!1,u=null;return(async()=>{let g=await c.mount(b,{center:e,zoom:i,fullscreenTarget:d.current??void 0});if(h){c.destroy(g);return}p.current=g,n.setMapHandle(g),u=c.onBoundsChange(g,R=>{C.current?C.current=!1:E.current=!0,n.loadPoints(R)}),f(!0),n.loadPoints(Rt)})(),()=>{h=!0,u?.(),p.current&&(c.destroy(p.current),p.current=null,n.setMapHandle(null)),f(!1)}},[n,c]),Q(()=>{let b=p.current;if(!c||!b||e||L.current||E.current)return;let h=[];for(let g of Object.keys(o.points))if(o.layers[g]!==!1)for(let R of o.points[g]??[])h.push(R.position);let u=Mt(h);u&&(L.current=!0,C.current=!0,c.fitBounds(b,u))},[c,e,a,o.points,o.layers]),Q(()=>{c?.updateMarkerStates(o.selection,o.hovered)},[c,a,o.selection,o.hovered]);let{Popup:x}=T(),N=x!==ce,w=o.points[n.primaryDatasetId]??[],z=o.selection!=null?w.find(b=>b.id===o.selection):void 0,[S,D]=We(null),Z=B(z);return Z.current=z,Q(()=>{let b=p.current;if(!c||!b||!N)return;let h=Z.current;if(!h)return;let u=c.mountOverlay(h.position);D({entity:h.entity,position:h.position,container:u.container});let g=()=>n.selectPoint(n.primaryDatasetId,null),R=k=>{k.key==="Escape"&&g()};document.addEventListener("keydown",R);let W=c.onMapClick(g);return()=>{document.removeEventListener("keydown",R),W(),u.unmount(),D(null)}},[n,c,a,o.selection,N]),Qe("div",{ref:d,className:"relative h-full min-h-0 w-full",children:[Qe("div",{ref:l,className:!c&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!c&&r,N&&S?Nt(me(x,{entity:S.entity,onClose:()=>n.selectPoint(n.primaryDatasetId,null)}),S.container):null]}),s!=null&&me("div",{className:"pointer-events-none absolute inset-0",children:me("div",{className:"pointer-events-auto",children:s})})]})}import{jsx as Dt}from"react/jsx-runtime";function Ze(){let t=y(),{results:e,pagination:i}=P();return e.nextCursor==null?null:Dt("button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}import{jsx as Ot}from"react/jsx-runtime";function Xe(){let{items:t,total:e}=K(),{ResultHeader:i}=T();return Ot(i,{count:t.length,total:e})}import{useEffect as _t,useRef as Bt}from"react";function Je(t,e){let i=y(),r=Bt(e);r.current=e,_t(()=>i.on(t,s=>r.current(s)),[i,t])}import{useEffect as Ht,useState as Ye}from"react";import{jsx as At}from"react/jsx-runtime";function et(t){let{children:e,...i}=t,[r]=Ye(()=>i),[s,n]=Ye(null);return Ht(()=>{let o=new te({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),n(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),n(l=>l===o?null:l)}},[r]),s?At(ie.Provider,{value:s,children:e}):null}function V(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}import{Fragment as Ut,jsx as O,jsxs as tt}from"react/jsx-runtime";function zt(t){return t?"rle-card rle-card--selected":"rle-card"}function fe({item:t,selected:e,onSelect:i}){let r=t??{},s=zt(e),n=tt(Ut,{children:[r.imageUrl?O("img",{src:r.imageUrl,alt:r.title??"",className:"rle-card-media"}):O("div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),tt("div",{className:"rle-card-body",children:[r.title&&O("span",{className:"rle-card-title",children:r.title}),r.subtitle&&O("span",{className:"rle-card-address",children:r.subtitle}),r.badge&&O("div",{className:"rle-card-info",children:O("span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&O("span",{className:"rle-card-price",children:V(r.price)})]})]});return i?O("button",{type:"button",onClick:i,"aria-pressed":e??!1,className:s,children:n}):O("article",{className:s,children:n})}import{jsx as se,jsxs as it}from"react/jsx-runtime";function ge(t){return it("div",{role:"status",className:"rle-empty",children:[it("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[se("circle",{cx:"11",cy:"11",r:"7"}),se("path",{d:"m21 21-4.3-4.3"})]}),se("p",{className:"rle-empty-title",children:"No results"}),se("p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}import{jsx as Kt}from"react/jsx-runtime";function ye({children:t}){return Kt("div",{className:"rle-filter-panel",children:t})}import{jsx as oe,jsxs as Vt}from"react/jsx-runtime";function he(t){return oe("div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>Vt("div",{className:"rle-loading-item",children:[oe("div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),oe("div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),oe("div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}import{jsx as $t}from"react/jsx-runtime";function ve({point:t}){let e=t.entity??{};return $t("span",{className:"rle-pin",children:e.price!=null?V(e.price):""})}import{jsx as $,jsxs as Le}from"react/jsx-runtime";function be({entity:t,onClose:e}){let i=t??{};return Le("div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[$("button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:Le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[$("path",{d:"M18 6 6 18"}),$("path",{d:"m6 6 12 12"})]})}),Le("div",{children:[i.title&&$("div",{className:"rle-card-title",children:i.title}),i.subtitle&&$("div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&$("div",{className:"rle-card-price",children:V(i.price)})]})]})}import{jsx as Wt}from"react/jsx-runtime";function Te({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return Wt("div",{className:"rle-result-header",children:i})}import{jsx as qt}from"react/jsx-runtime";function Pe({value:t,onChange:e,placeholder:i}){return qt("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search",className:"rle-input"})}import{jsx as jt}from"react/jsx-runtime";function Fe({children:t}){return jt("aside",{className:"rle-sidebar",children:t})}import{jsx as Qt}from"react/jsx-runtime";function Ce({children:t}){return Qt("div",{className:"rle-toolbar",children:t})}var rt={Card:fe,Marker:ve,Popup:be,Sidebar:Fe,FilterPanel:ye,Search:Pe,Empty:ge,Loading:he,ResultHeader:Te,Toolbar:Ce};import{jsx as F,jsxs as G}from"react/jsx-runtime";function nt({view:t,onViewChange:e}){return F("nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:G("div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[G("button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[F(Gt,{}),"List"]}),G("button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[F(Zt,{}),"Map"]})]})})}function Gt(){return G("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[F("line",{x1:"8",y1:"6",x2:"20",y2:"6"}),F("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),F("line",{x1:"8",y1:"18",x2:"20",y2:"18"}),F("line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),F("line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),F("line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Zt(){return G("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[F("polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),F("line",{x1:"8",y1:"3",x2:"8",y2:"18"}),F("line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}import{useEffect as we,useRef as Xt,useState as st}from"react";import{createPortal as Jt}from"react-dom";import{Fragment as ei,jsx as _,jsxs as ae}from"react/jsx-runtime";function ot({open:t,onOpenChange:e,title:i,children:r,footer:s}){let n=Xt(null),[o,l]=st(!1),[d,p]=st(!1);return we(()=>{if(!t){p(!1),l(!1);return}l(!0);let a=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(a)},[t]),we(()=>{if(!o)return;let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=a}},[o]),we(()=>{if(!o)return;n.current?.focus();function a(f){f.key==="Escape"&&e(!1)}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[o,e]),!o||typeof document>"u"?null:Jt(ae(ei,{children:[_("div",{className:`rle-sheet-backdrop${d?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),ae("div",{ref:n,className:`rle-sheet${d?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[_("div",{className:"rle-sheet__handle","aria-hidden":"true"}),ae("div",{className:"rle-sheet__header",children:[i&&_("div",{className:"rle-sheet__title",children:i}),_("button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:_(Yt,{})})]}),_("div",{className:"rle-sheet__body",children:r}),s&&_("div",{className:"rle-sheet__footer",children:s})]})]}),document.body)}function Yt(){return ae("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_("path",{d:"M18 6 6 18"}),_("path",{d:"m6 6 12 12"})]})}import{useEffect as Se,useRef as lt,useState as A}from"react";import{jsx as v,jsxs as le}from"react/jsx-runtime";function at({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:s}=T();return le("header",{className:"rle-mobile-header",children:[t&&v("div",{className:"rle-mobile-header__search",children:v(s,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),le("button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[v(ti,{}),v("span",{children:"Filters"}),i>0&&v("span",{className:"rle-mobile-header__count",children:i})]}),r&&v("button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:r.icon??v(ii,{})})]})}function ti(){return le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[v("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),v("circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),v("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),v("circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),v("line",{x1:"4",y1:"18",x2:"20",y2:"18"}),v("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function ii(){return le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[v("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),v("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}import{Fragment as oi,jsx as m,jsxs as H}from"react/jsx-runtime";var ri=m("div",{className:"rle-empty",children:"Map unavailable"});function ni(){let t=lt(null),[e,i]=A(!0),[r,s]=A(!0);return Se(()=>{let n=t.current;if(!n)return;let o=()=>{let{clientWidth:f,scrollLeft:L,scrollWidth:E}=n;i(L<=0),s(L+f>=E-1)},l=0,d=()=>{l||(l=requestAnimationFrame(()=>{l=0,o()}))};o(),n.addEventListener("scroll",o,{passive:!0});let p,a;return typeof ResizeObserver<"u"&&(p=new ResizeObserver(o),p.observe(n)),typeof MutationObserver<"u"&&(a=new MutationObserver(d),a.observe(n,{characterData:!0,childList:!0,subtree:!0})),()=>{n.removeEventListener("scroll",o),p?.disconnect(),a?.disconnect(),l&&cancelAnimationFrame(l)}},[]),{atEnd:r,atStart:e,ref:t}}function si(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,r=e,s=new Set([...Object.keys(i),...Object.keys(r)]);for(let n of s)if(i[n]!==r[n])return!1;return!0}function dt({search:t,filterBarEnd:e,toolbarEnd:i,mobileAction:r,autoFetch:s=!0,hasMap:n,mapCenter:o,mapZoom:l,mapControls:d,mobileSheetFooter:p,className:a}){let f=y(),{Search:L}=T(),E=K(),{filters:C,set:c}=re(),{pagination:x}=P(),N=n??f.map!=null,[w,z]=A("list"),[S,D]=A(!1),{atEnd:Z,atStart:b,ref:h}=ni(),[u,g]=A(C),[R,W]=A(S);S!==R&&(W(S),S&&g(C));let k=pe=>g(ut=>({...ut,...pe})),[Ie,Ee]=A(!1),de=lt(!1);Se(()=>{if(Ie){if(x.loading){de.current=!0;return}de.current&&(de.current=!1,Ee(!1),D(!1))}},[Ie,x.loading]);let q=t?{value:String(C[t.filterKey]??""),onChange:pe=>{c({[t.filterKey]:pe||void 0})},placeholder:t.placeholder}:void 0;Se(()=>{s!==!1&&f.applyFilters({})},[f,s]);let xe=()=>{k(f.filters.clearedParams())},Ne=()=>{if(si(u,C)){D(!1);return}Ee(!0),f.applyFilters(u)},ct=f.filters.activeKeys(C).length,Re=E.total??E.items.length;return H("div",{className:a?`rle-app ${a}`:"rle-app",children:[H("div",{className:"rle-filter-bar",children:[H("div",{className:"rle-filter-bar__scroll",ref:h,children:[q&&m("div",{className:"rle-filter-bar__search",children:m(L,{value:q.value,onChange:q.onChange,placeholder:q.placeholder})}),m(ue,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0}),e&&m("div",{className:"rle-filter-bar__end",children:e})]}),!b&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!Z&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),m(at,{search:q,onFiltersClick:()=>D(!0),filterCount:ct,action:r}),H("div",{className:`rle-body ${N?"rle-split":"rle-body--list-only"}`,"data-mobile-view":w,children:[H("div",{className:"rle-list",children:[H("div",{className:"rle-list-header",children:[m(Xe,{}),i&&m("div",{className:"rle-list-header__toolbar",children:i})]}),m($e,{className:"rle-list-grid"}),m(Ze,{})]}),N&&m("div",{className:"rle-map",children:m(Ge,{center:o,zoom:l,fallback:ri,mapControls:d})})]}),N&&m(nt,{view:w,onViewChange:z}),m(ot,{title:"Filters",open:S,onOpenChange:D,footer:p?p({draft:u,apply:Ne,clear:xe,resultCount:Re,loading:x.loading}):H(oi,{children:[m("button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:xe,children:"Clear all"}),m("button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:x.loading,onClick:Ne,children:x.loading?m("span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${Re} results`})]}),children:m(ue,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:u,onDraftChange:k})})]})}import{useEffect as ai,useRef as li,useState as di}from"react";import{jsx as ke,jsxs as ui}from"react/jsx-runtime";function pt(t){return"provider"in t}function pi(t){let e=t!=null&&!pt(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,s=e?t.mapOptions:void 0,n=e?t.styles:void 0,[o,l]=di(()=>!t||pt(t)?{ready:!0,provider:t?.provider}:{ready:!1});return ai(()=>{if(!i)return;let d=!1;return import("./maps/google/index.js").then(({googleProvider:p})=>{d||l({ready:!0,provider:p({apiKey:i,mapId:r,mapOptions:s,styles:n})})}),()=>{d=!0}},[i,r]),o}function ci({onFiltersChange:t}){let e=li(t);return e.current=t,Je("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Rn(t){let{datasets:e,filters:i,map:r,components:s,initialFilters:n,onFiltersChange:o,mobileAction:l,search:d,filterBarEnd:p,toolbarEnd:a,mapControls:f,mobileSheetFooter:L,config:E,autoFetch:C,className:c}=t,{ready:x,provider:N}=pi(r);if(!x)return null;let w=[];for(let D of e)w.push(Be(D));i&&w.push(He(i)),N&&w.push(_e(N)),n&&w.push(Ae(n)),E&&w.push(Oe(E));let z=De(...w),S={...rt,...s};return ui(et,{...z,children:[o&&ke(ci,{onFiltersChange:o}),ke(Ue,{...S,children:ke(dt,{className:c,search:d,filterBarEnd:p,toolbarEnd:a,mobileAction:l,autoFetch:C,mapCenter:r?.center,mapZoom:r?.zoom,mapControls:f,mobileSheetFooter:L})})]})}export{X as a,U as b,J as c,Y as d,Me as e,ee as f,te as g,De as h,Oe as i,_e as j,Be as k,He as l,ki as m,Ae as n,Ii as o,ce as p,Ue as q,T as r,ie as s,y as t,P as u,re as v,ue as w,K as x,$e as y,Ge as z,Ze as A,Xe as B,Je as C,et as D,fe as E,ge as F,ye as G,he as H,ve as I,be as J,Te as K,Pe as L,Fe as M,Ce as N,rt as O,nt as P,ot as Q,dt as R,Rn as S};
|
|
2
|
+
var X=class{state;listeners=new Set;constructor(e){this.state=this.freezeState({filters:{...e.filters},results:{items:[],nextCursor:null},bounds:null,selection:null,hovered:null,pagination:{mode:e.mode??"paged",loading:!1},layers:{},points:{}})}getState(){return this.state}setFilters(e){this.setState({filters:{...this.state.filters,...e}})}setResults(e){this.setState({results:{items:[...e.items],nextCursor:e.nextCursor,total:e.total}})}appendResults(e){this.setState({results:{items:[...this.state.results.items,...e.items],nextCursor:e.nextCursor,total:e.total}})}setBounds(e){this.setState({bounds:e?{...e}:null})}setSelection(e){this.setState({selection:e})}setHovered(e){this.setState({hovered:e})}setLayerVisible(e,i){this.setState({layers:{...this.state.layers,[e]:i}})}setLoading(e){this.setState({pagination:{...this.state.pagination,loading:e}})}setPoints(e,i){this.setState({points:{...this.state.points,[e]:[...i]}})}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setState(e){this.state=this.freezeState({...this.state,...e}),this.notify()}notify(){for(let e of this.listeners)e()}freezeState(e){Object.freeze(e.filters),Object.freeze(e.results.items),Object.freeze(e.results),e.bounds&&Object.freeze(e.bounds),Object.freeze(e.pagination),Object.freeze(e.layers);for(let i of Object.values(e.points))Object.freeze(i);return Object.freeze(e.points),Object.freeze(e)}};var U=class{defs=new Map;add(e){if(this.defs.has(e.key))throw new Error(`FilterRegistry: filter "${e.key}" is already registered`);return this.defs.set(e.key,{...e}),this}remove(e){return this.defs.delete(e),this}replace(e,i){if(!this.defs.has(e))throw new Error(`FilterRegistry: cannot replace unregistered filter "${e}"`);return this.defs.set(e,{...i,key:e}),this}reorder(e){let i=this.list(),r=e.filter(n=>this.defs.has(n));r.forEach((n,o)=>{this.defs.get(n).order=o});let s=new Set(r);return i.filter(n=>!s.has(n.key)).forEach((n,o)=>{n.order=r.length+o}),this}list(){return[...this.defs.values()].sort((e,i)=>e.order-i.order)}has(e){return this.defs.has(e)}toFilters(e){return this.list().filter(r=>Object.hasOwn(e,r.key)).map(r=>r.toParams(e[r.key])).reduce((r,s)=>({...r,...s}),{})}activeKeys(e){return this.list().filter(i=>i.isActive?.(e)).map(i=>i.key)}clearedParams(){return this.list().reduce((e,i)=>Object.assign(e,i.toParams(i.fromParams({}))),{})}};var J=class{defs=new Map;add(e){if(this.defs.has(e.id))throw new Error(`DatasetRegistry: dataset "${e.id}" is already registered`);return this.defs.set(e.id,{...e}),this}get(e){return this.defs.get(e)}has(e){return this.defs.has(e)}list(){return[...this.defs.values()]}visibleIds(){return this.list().filter(e=>e.visible?.()!==!1).map(e=>e.id)}};var Y=class{map=new Map;dispose(){this.map.clear()}emit(e){let i=this.map.get(e.type);if(i)for(let s of[...i])s(e);let r=this.map.get("*");if(r)for(let s of[...r])s(e)}on(e,i){let r=this.map.get(e);return r||(r=new Set,this.map.set(e,r)),r.add(i),()=>{r.delete(i)}}};var Me={pagination:"paged",pageSize:20,debounceMs:250};var ee=class{options;constructor(e){this.options=Object.freeze({...Me,...e})}};var te=class{filters;map;datasets;primaryDatasetId;store;emitter=new Y;config;debounceTimer=null;debounceResolve=null;queryToken=0;pointsToken=0;mapHandle=null;constructor(e){this.datasets=e.datasets,this.filters=e.filters??new U,this.map=e.map,this.config=new ee(e.config);let i=e.primaryDatasetId??this.datasets.list()[0]?.id;if(i==null||!this.datasets.has(i))throw new Error(`ListingEngine: primary dataset "${i??""}" is not registered \u2014 pass a valid primaryDatasetId or register at least one dataset`);this.primaryDatasetId=i,this.store=new X({filters:e.initialFilters??{},mode:this.config.options.pagination})}get state(){return this.store.getState()}get options(){return this.config.options}applyFilters(e){this.store.setFilters(e),this.emitter.emit({type:"FiltersChanged",filters:this.currentFilters()}),this.clearDebounce();let i=++this.queryToken,r=this.config.options.debounceMs;return r<=0?this.runQuery(i):new Promise(s=>{this.debounceResolve=s,this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.debounceResolve=null,s(this.runQuery(i))},r)})}async loadPage(){let e=this.state.results.nextCursor;if(e===null)return;let i=++this.queryToken,r=this.primaryDataset();this.store.setLoading(!0);try{let s=await r.adapter.list(this.currentFilters(),{cursor:e,limit:this.config.options.pageSize});if(i!==this.queryToken)return;this.config.options.pagination==="infinite"?this.store.appendResults(s):this.store.setResults(s),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:s.items.length})}finally{i===this.queryToken&&this.store.setLoading(!1)}}async loadPoints(e){this.store.setBounds(e),this.emitter.emit({type:"BoundsChanged",bounds:e});let i=this.currentFilters(),r=++this.pointsToken;await Promise.allSettled(this.datasets.visibleIds().map(async s=>{let n=this.datasets.get(s);if(!n)return;let o=await n.adapter.getPoints(i,e);r===this.pointsToken&&this.store.setPoints(s,o)}))}setMapHandle(e){this.mapHandle=e}fitBounds(e){!this.map||!this.mapHandle||this.map.fitBounds(this.mapHandle,e)}selectPoint(e,i){this.store.setSelection(i);let r=this.state.points[e]?.find(s=>s.id===i);r&&this.emitter.emit({type:"PointClicked",datasetId:e,id:r.id,entity:r.entity})}setHovered(e,i){this.store.setHovered(i)}toggleLayer(e){let r=!(this.state.layers[e]??!0);this.store.setLayerVisible(e,r),this.emitter.emit({type:"LayerToggled",datasetId:e,visible:r})}subscribe(e){return this.store.subscribe(e)}on(e,i){return this.emitter.on(e,i)}dispose(){this.clearDebounce(),this.emitter.dispose(),this.mapHandle=null}async runQuery(e){if(e!==this.queryToken)return;let i=this.primaryDataset();this.store.setLoading(!0);try{let r=await i.adapter.list(this.currentFilters(),{cursor:null,limit:this.config.options.pageSize});if(e!==this.queryToken)return;this.store.setResults(r),this.emitter.emit({type:"ResultsLoaded",datasetId:this.primaryDatasetId,count:r.items.length})}finally{e===this.queryToken&&this.store.setLoading(!1)}}primaryDataset(){return this.datasets.get(this.primaryDatasetId)}currentFilters(){return this.store.getState().filters}clearDebounce(){this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.debounceResolve!==null&&(this.debounceResolve(),this.debounceResolve=null)}};function De(...t){let e={config:{},filters:new U,datasets:new J};for(let i of t)i(e);return e}var Oe=t=>e=>{e.config={...e.config,...t}},_e=t=>e=>{e.map=t},Be=t=>e=>{e.datasets.add(t)},He=t=>e=>{t(e.filters)},ki=t=>e=>{e.urlSync=t},Ae=t=>e=>{e.initialFilters=t},Ii=t=>e=>{e.primaryDatasetId=t};import{createContext as mt,useContext as ft}from"react";import{jsx as M,jsxs as St}from"react/jsx-runtime";function gt(t){return String(t?.title??"")}var yt=({item:t})=>M("div",{children:gt(t)}),ht=()=>M("div",{}),ce=()=>M("div",{}),vt=({children:t})=>M("div",{children:t}),Lt=({children:t})=>M("div",{children:t}),bt=({value:t,onChange:e,placeholder:i})=>M("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search"}),Tt=()=>M("div",{role:"status",children:"No results"}),Pt=()=>M("div",{role:"status","aria-busy":"true",children:"Loading\u2026"}),Ft=({count:t})=>St("div",{children:[t," results"]}),Ct=({children:t})=>M("div",{children:t}),I={Card:yt,Marker:ht,Popup:ce,Sidebar:vt,FilterPanel:Lt,Search:bt,Empty:Tt,Loading:Pt,ResultHeader:Ft,Toolbar:Ct},ze=mt(I);function Ue(t){let{Card:e,Marker:i,Popup:r,Sidebar:s,FilterPanel:n,Search:o,Empty:l,Loading:d,ResultHeader:p,Toolbar:a,children:f}=t,L={Card:e??I.Card,Marker:i??I.Marker,Popup:r??I.Popup,Sidebar:s??I.Sidebar,FilterPanel:n??I.FilterPanel,Search:o??I.Search,Empty:l??I.Empty,Loading:d??I.Loading,ResultHeader:p??I.ResultHeader,Toolbar:a??I.Toolbar};return M(ze.Provider,{value:L,children:f})}function T(){return ft(ze)}import{createContext as wt}from"react";var ie=wt(null);import{useContext as kt}from"react";function y(){let t=kt(ie);if(t===null)throw new Error("useListing must be used within a <ListingProvider>");return t}import{useCallback as Ke,useSyncExternalStore as It}from"react";function P(){let t=y(),e=Ke(r=>t.subscribe(r),[t]),i=Ke(()=>t.state,[t]);return It(e,i,i)}import{useCallback as Ve}from"react";function re(){let t=y(),e=P(),i=Ve(s=>t.applyFilters(s),[t]),r=Ve((s,n)=>t.applyFilters({[s]:n}),[t]);return{filters:e.filters,set:i,setField:r}}import{jsx as j,jsxs as Et}from"react/jsx-runtime";function ue({className:t,groupClassName:e,hideLabels:i,draft:r,onDraftChange:s}={}){let n=y(),{FilterPanel:o}=T(),{filters:l}=re(),d=r!==void 0&&s!==void 0,p=d?r:l;return j(o,{children:j("div",{className:t??"space-y-5",children:n.filters.list().map(a=>{if(typeof a.render=="string")return j("div",{"data-filter":a.key,className:e},a.key);let f=a.render;return Et("div",{className:e,children:[a.label&&!i&&j("div",{className:"mb-1.5 text-[13px] font-medium text-foreground",children:a.label}),j(f,{value:a.fromParams(p),onChange:L=>d?s(a.toParams(L)):void n.applyFilters(a.toParams(L))})]},a.key)})})})}function K(){return P().results}import{jsx as ne}from"react/jsx-runtime";function xt(t,e){if(t&&typeof t=="object"&&"id"in t){let i=t.id;if(typeof i=="string"||typeof i=="number")return i}return e}function $e({className:t}={}){let e=y(),{items:i}=K(),{pagination:r,selection:s}=P(),{Card:n,Empty:o,Loading:l}=T();return r.loading&&i.length===0?ne(l,{}):i.length===0?ne(o,{}):ne("div",{role:"list",className:t,children:i.map((d,p)=>{let a=xt(d,p);return ne(n,{item:d,selected:s===a,onSelect:()=>e.selectPoint(e.primaryDatasetId,a)},a)})})}import{useEffect as Q,useRef as B,useState as We}from"react";import{createPortal as Nt}from"react-dom";import{jsx as me,jsxs as Qe}from"react/jsx-runtime";var Rt={west:-179.9,south:-85,east:179.9,north:85},qe=.1,je=.02;function Mt(t){if(t.length===0)return null;let e=t[0].lng,i=t[0].lng,r=t[0].lat,s=t[0].lat;for(let{lat:l,lng:d}of t)d<e&&(e=d),d>i&&(i=d),l<r&&(r=l),l>s&&(s=l);let n=s>r?(s-r)*qe:je,o=i>e?(i-e)*qe:je;return{west:e-o,east:i+o,south:r-n,north:s+n}}function Ge(t){let{center:e,zoom:i,fallback:r,mapControls:s}=t,n=y(),o=P(),l=B(null),d=B(null),p=B(null),[a,f]=We(!1),L=B(!1),E=B(!1),C=B(!1),c=n.map;Q(()=>{let b=p.current;if(!c||!b)return;let h=[];for(let u of Object.keys(o.points)){if(o.layers[u]===!1)continue;let g=n.datasets.get(u),R=o.points[u]??[],W={id:u,markers:R.map(k=>({id:k.id,position:k.position,iconUrl:g?.marker.iconUrl?.(k.entity),element:g?.marker.element?.(k.entity)})),clustering:g?.clustering,onMarkerClick:k=>n.selectPoint(u,k)};h.push(c.renderLayer(b,W))}return()=>{h.forEach(u=>u())}},[n,c,a,o.points,o.layers]),Q(()=>{if(!l.current||!c)return;let b=l.current,h=!1,u=null;return(async()=>{let g=await c.mount(b,{center:e,zoom:i,fullscreenTarget:d.current??void 0});if(h){c.destroy(g);return}p.current=g,n.setMapHandle(g),u=c.onBoundsChange(g,R=>{C.current?C.current=!1:E.current=!0,n.loadPoints(R)}),f(!0),n.loadPoints(Rt)})(),()=>{h=!0,u?.(),p.current&&(c.destroy(p.current),p.current=null,n.setMapHandle(null)),f(!1)}},[n,c]),Q(()=>{let b=p.current;if(!c||!b||e||L.current||E.current)return;let h=[];for(let g of Object.keys(o.points))if(o.layers[g]!==!1)for(let R of o.points[g]??[])h.push(R.position);let u=Mt(h);u&&(L.current=!0,C.current=!0,c.fitBounds(b,u))},[c,e,a,o.points,o.layers]),Q(()=>{c?.updateMarkerStates(o.selection,o.hovered)},[c,a,o.selection,o.hovered]);let{Popup:x}=T(),N=x!==ce,S=o.points[n.primaryDatasetId]??[],z=o.selection!=null?S.find(b=>b.id===o.selection):void 0,[w,D]=We(null),Z=B(z);return Z.current=z,Q(()=>{let b=p.current;if(!c||!b||!N)return;let h=Z.current;if(!h)return;let u=c.mountOverlay(h.position);D({entity:h.entity,position:h.position,container:u.container});let g=()=>n.selectPoint(n.primaryDatasetId,null),R=k=>{k.key==="Escape"&&g()};document.addEventListener("keydown",R);let W=c.onMapClick(g);return()=>{document.removeEventListener("keydown",R),W(),u.unmount(),D(null)}},[n,c,a,o.selection,N]),Qe("div",{ref:d,className:"relative h-full min-h-0 w-full",children:[Qe("div",{ref:l,className:!c&&r?"flex h-full min-h-0 w-full items-center justify-center":"h-full min-h-0 w-full",children:[!c&&r,N&&w?Nt(me(x,{entity:w.entity,onClose:()=>n.selectPoint(n.primaryDatasetId,null)}),w.container):null]}),s!=null&&me("div",{className:"pointer-events-none absolute inset-0",children:me("div",{className:"pointer-events-auto",children:s})})]})}import{jsx as Dt}from"react/jsx-runtime";function Ze(){let t=y(),{results:e,pagination:i}=P();return e.nextCursor==null?null:Dt("button",{type:"button",disabled:i.loading,onClick:()=>{t.loadPage()},children:"Load more"})}import{jsx as Ot}from"react/jsx-runtime";function Xe(){let{items:t,total:e}=K(),{ResultHeader:i}=T();return Ot(i,{count:t.length,total:e})}import{useEffect as _t,useRef as Bt}from"react";function Je(t,e){let i=y(),r=Bt(e);r.current=e,_t(()=>i.on(t,s=>r.current(s)),[i,t])}import{useEffect as Ht,useState as Ye}from"react";import{jsx as At}from"react/jsx-runtime";function et(t){let{children:e,...i}=t,[r]=Ye(()=>i),[s,n]=Ye(null);return Ht(()=>{let o=new te({datasets:r.datasets,filters:r.filters,config:r.config,map:r.map,initialFilters:r.initialFilters,primaryDatasetId:r.primaryDatasetId});return r.urlSync&&r.urlSync.start(o),n(o),()=>{r.urlSync&&r.urlSync.stop(),o.dispose(),n(l=>l===o?null:l)}},[r]),s?At(ie.Provider,{value:s,children:e}):null}function V(t){return typeof t!="number"?t:new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:0}).format(t)}import{Fragment as Ut,jsx as O,jsxs as tt}from"react/jsx-runtime";function zt(t){return t?"rle-card rle-card--selected":"rle-card"}function fe({item:t,selected:e,onSelect:i}){let r=t??{},s=zt(e),n=tt(Ut,{children:[r.imageUrl?O("img",{src:r.imageUrl,alt:r.title??"",className:"rle-card-media"}):O("div",{className:"rle-card-media rle-card-media--placeholder","aria-hidden":"true"}),tt("div",{className:"rle-card-body",children:[r.title&&O("span",{className:"rle-card-title",children:r.title}),r.subtitle&&O("span",{className:"rle-card-address",children:r.subtitle}),r.badge&&O("div",{className:"rle-card-info",children:O("span",{className:"rle-card-info-item",children:r.badge})}),r.price!=null&&O("span",{className:"rle-card-price",children:V(r.price)})]})]});return i?O("button",{type:"button",onClick:i,"aria-pressed":e??!1,className:s,children:n}):O("article",{className:s,children:n})}import{jsx as se,jsxs as it}from"react/jsx-runtime";function ge(t){return it("div",{role:"status",className:"rle-empty",children:[it("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",className:"rle-empty-icon","aria-hidden":"true",children:[se("circle",{cx:"11",cy:"11",r:"7"}),se("path",{d:"m21 21-4.3-4.3"})]}),se("p",{className:"rle-empty-title",children:"No results"}),se("p",{className:"rle-empty-hint",children:"Try adjusting your filters or search terms."})]})}import{jsx as Kt}from"react/jsx-runtime";function ye({children:t}){return Kt("div",{className:"rle-filter-panel",children:t})}import{jsx as oe,jsxs as Vt}from"react/jsx-runtime";function he(t){return oe("div",{className:"rle-loading",role:"status","aria-busy":"true","aria-label":"Loading results",children:Array.from({length:3}).map((e,i)=>Vt("div",{className:"rle-loading-item",children:[oe("div",{className:"rle-skeleton",style:{aspectRatio:"4 / 3",width:"100%"}}),oe("div",{className:"rle-skeleton",style:{height:16,width:"65%"}}),oe("div",{className:"rle-skeleton",style:{height:12,width:"35%"}})]},i))})}import{jsx as $t}from"react/jsx-runtime";function ve({point:t}){let e=t.entity??{};return $t("span",{className:"rle-pin",children:e.price!=null?V(e.price):""})}import{jsx as $,jsxs as Le}from"react/jsx-runtime";function be({entity:t,onClose:e}){let i=t??{};return Le("div",{className:"rle-popup",role:"group","aria-label":"Location details",children:[$("button",{type:"button",onClick:e,"aria-label":"Close",className:"rle-popup-close",children:Le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[$("path",{d:"M18 6 6 18"}),$("path",{d:"m6 6 12 12"})]})}),Le("div",{children:[i.title&&$("div",{className:"rle-card-title",children:i.title}),i.subtitle&&$("div",{className:"rle-card-address",children:i.subtitle}),i.price!=null&&$("div",{className:"rle-card-price",children:V(i.price)})]})]})}import{jsx as Wt}from"react/jsx-runtime";function Te({count:t,total:e}){let i=e!=null&&e!==t?`${t} of ${e} results`:`${t} results`;return Wt("div",{className:"rle-result-header",children:i})}import{jsx as qt}from"react/jsx-runtime";function Pe({value:t,onChange:e,placeholder:i}){return qt("input",{type:"search",value:t,placeholder:i,onChange:r=>e(r.target.value),"aria-label":i??"Search",className:"rle-input"})}import{jsx as jt}from"react/jsx-runtime";function Fe({children:t}){return jt("aside",{className:"rle-sidebar",children:t})}import{jsx as Qt}from"react/jsx-runtime";function Ce({children:t}){return Qt("div",{className:"rle-toolbar",children:t})}var rt={Card:fe,Marker:ve,Popup:be,Sidebar:Fe,FilterPanel:ye,Search:Pe,Empty:ge,Loading:he,ResultHeader:Te,Toolbar:Ce};import{jsx as F,jsxs as G}from"react/jsx-runtime";function nt({view:t,onViewChange:e}){return F("nav",{className:"rle-bottom-nav","aria-label":"Listing navigation",children:G("div",{className:"rle-viewtoggle",role:"group","aria-label":"View",children:[G("button",{type:"button",className:`rle-viewtoggle__btn${t==="list"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="list",onClick:()=>e("list"),children:[F(Gt,{}),"List"]}),G("button",{type:"button",className:`rle-viewtoggle__btn${t==="map"?" rle-viewtoggle__btn--active":""}`,"aria-pressed":t==="map",onClick:()=>e("map"),children:[F(Zt,{}),"Map"]})]})})}function Gt(){return G("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[F("line",{x1:"8",y1:"6",x2:"20",y2:"6"}),F("line",{x1:"8",y1:"12",x2:"20",y2:"12"}),F("line",{x1:"8",y1:"18",x2:"20",y2:"18"}),F("line",{x1:"4",y1:"6",x2:"4.01",y2:"6"}),F("line",{x1:"4",y1:"12",x2:"4.01",y2:"12"}),F("line",{x1:"4",y1:"18",x2:"4.01",y2:"18"})]})}function Zt(){return G("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[F("polygon",{points:"1 6 8 3 16 6 23 3 23 18 16 21 8 18 1 21 1 6"}),F("line",{x1:"8",y1:"3",x2:"8",y2:"18"}),F("line",{x1:"16",y1:"6",x2:"16",y2:"21"})]})}import{useEffect as Se,useRef as Xt,useState as st}from"react";import{createPortal as Jt}from"react-dom";import{Fragment as ei,jsx as _,jsxs as ae}from"react/jsx-runtime";function ot({open:t,onOpenChange:e,title:i,children:r,footer:s}){let n=Xt(null),[o,l]=st(!1),[d,p]=st(!1);return Se(()=>{if(!t){p(!1),l(!1);return}l(!0);let a=requestAnimationFrame(()=>p(!0));return()=>cancelAnimationFrame(a)},[t]),Se(()=>{if(!o)return;let a=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=a}},[o]),Se(()=>{if(!o)return;n.current?.focus();function a(f){f.key==="Escape"&&e(!1)}return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[o,e]),!o||typeof document>"u"?null:Jt(ae(ei,{children:[_("div",{className:`rle-sheet-backdrop${d?" rle-sheet-backdrop--open":""}`,onClick:()=>e(!1),"aria-hidden":"true"}),ae("div",{ref:n,className:`rle-sheet${d?" rle-sheet--open":""}`,role:"dialog","aria-modal":"true","aria-label":i,tabIndex:-1,children:[_("div",{className:"rle-sheet__handle","aria-hidden":"true"}),ae("div",{className:"rle-sheet__header",children:[i&&_("div",{className:"rle-sheet__title",children:i}),_("button",{type:"button",className:"rle-sheet__close",onClick:()=>e(!1),"aria-label":"Close",children:_(Yt,{})})]}),_("div",{className:"rle-sheet__body",children:r}),s&&_("div",{className:"rle-sheet__footer",children:s})]})]}),document.body)}function Yt(){return ae("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",width:"16",height:"16","aria-hidden":"true",children:[_("path",{d:"M18 6 6 18"}),_("path",{d:"m6 6 12 12"})]})}import{useEffect as we,useRef as lt,useState as A}from"react";import{jsx as v,jsxs as le}from"react/jsx-runtime";function at({search:t,onFiltersClick:e,filterCount:i=0,action:r}){let{Search:s}=T();return le("header",{className:"rle-mobile-header",children:[t&&v("div",{className:"rle-mobile-header__search",children:v(s,{value:t.value,onChange:t.onChange,placeholder:t.placeholder})}),le("button",{type:"button",className:"rle-btn rle-mobile-header__btn",onClick:e,children:[v(ti,{}),v("span",{children:"Filters"}),i>0&&v("span",{className:"rle-mobile-header__count",children:i})]}),r&&v("button",{type:"button",className:"rle-btn rle-mobile-header__btn rle-mobile-header__btn--icon",onClick:r.onClick,"aria-label":r.label,children:r.icon??v(ii,{})})]})}function ti(){return le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[v("line",{x1:"4",y1:"6",x2:"20",y2:"6"}),v("circle",{cx:"9",cy:"6",r:"2",fill:"currentColor",stroke:"none"}),v("line",{x1:"4",y1:"12",x2:"20",y2:"12"}),v("circle",{cx:"15",cy:"12",r:"2",fill:"currentColor",stroke:"none"}),v("line",{x1:"4",y1:"18",x2:"20",y2:"18"}),v("circle",{cx:"11",cy:"18",r:"2",fill:"currentColor",stroke:"none"})]})}function ii(){return le("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[v("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),v("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}import{Fragment as oi,jsx as m,jsxs as H}from"react/jsx-runtime";var ri=m("div",{className:"rle-empty",children:"Map unavailable"});function ni(){let t=lt(null),[e,i]=A(!0),[r,s]=A(!0);return we(()=>{let n=t.current;if(!n)return;let o=()=>{let{clientWidth:f,scrollLeft:L,scrollWidth:E}=n;i(L<=0),s(L+f>=E-1)},l=0,d=()=>{l||(l=requestAnimationFrame(()=>{l=0,o()}))};o(),n.addEventListener("scroll",o,{passive:!0});let p,a;return typeof ResizeObserver<"u"&&(p=new ResizeObserver(o),p.observe(n)),typeof MutationObserver<"u"&&(a=new MutationObserver(d),a.observe(n,{characterData:!0,childList:!0,subtree:!0})),()=>{n.removeEventListener("scroll",o),p?.disconnect(),a?.disconnect(),l&&cancelAnimationFrame(l)}},[]),{atEnd:r,atStart:e,ref:t}}function si(t,e){if(t===e)return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;let i=t,r=e,s=new Set([...Object.keys(i),...Object.keys(r)]);for(let n of s)if(i[n]!==r[n])return!1;return!0}function dt({search:t,filterBarStart:e,toolbarEnd:i,mobileAction:r,autoFetch:s=!0,hasMap:n,mapCenter:o,mapZoom:l,mapControls:d,mobileSheetFooter:p,className:a}){let f=y(),{Search:L}=T(),E=K(),{filters:C,set:c}=re(),{pagination:x}=P(),N=n??f.map!=null,[S,z]=A("list"),[w,D]=A(!1),{atEnd:Z,atStart:b,ref:h}=ni(),[u,g]=A(C),[R,W]=A(w);w!==R&&(W(w),w&&g(C));let k=pe=>g(ut=>({...ut,...pe})),[Ie,Ee]=A(!1),de=lt(!1);we(()=>{if(Ie){if(x.loading){de.current=!0;return}de.current&&(de.current=!1,Ee(!1),D(!1))}},[Ie,x.loading]);let q=t?{value:String(C[t.filterKey]??""),onChange:pe=>{c({[t.filterKey]:pe||void 0})},placeholder:t.placeholder}:void 0;we(()=>{s!==!1&&f.applyFilters({})},[f,s]);let xe=()=>{k(f.filters.clearedParams())},Ne=()=>{if(si(u,C)){D(!1);return}Ee(!0),f.applyFilters(u)},ct=f.filters.activeKeys(C).length,Re=E.total??E.items.length;return H("div",{className:a?`rle-app ${a}`:"rle-app",children:[H("div",{className:"rle-filter-bar",children:[H("div",{className:"rle-filter-bar__scroll",ref:h,children:[q&&m("div",{className:"rle-filter-bar__search",children:m(L,{value:q.value,onChange:q.onChange,placeholder:q.placeholder})}),e&&m("div",{className:"rle-filter-bar__slot",children:e}),m(ue,{className:"rle-filters-row",groupClassName:"rle-filter-group",hideLabels:!0})]}),!b&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--start","aria-hidden":"true"}),!Z&&m("div",{className:"rle-filter-bar__fade rle-filter-bar__fade--end","aria-hidden":"true"})]}),m(at,{search:q,onFiltersClick:()=>D(!0),filterCount:ct,action:r}),H("div",{className:`rle-body ${N?"rle-split":"rle-body--list-only"}`,"data-mobile-view":S,children:[H("div",{className:"rle-list",children:[H("div",{className:"rle-list-header",children:[m(Xe,{}),i&&m("div",{className:"rle-list-header__toolbar",children:i})]}),m($e,{className:"rle-list-grid"}),m(Ze,{})]}),N&&m("div",{className:"rle-map",children:m(Ge,{center:o,zoom:l,fallback:ri,mapControls:d})})]}),N&&m(nt,{view:S,onViewChange:z}),m(ot,{title:"Filters",open:w,onOpenChange:D,footer:p?p({draft:u,apply:Ne,clear:xe,resultCount:Re,loading:x.loading}):H(oi,{children:[m("button",{type:"button",className:"rle-btn rle-btn--ghost",onClick:xe,children:"Clear all"}),m("button",{type:"button",className:"rle-btn rle-btn--primary rle-sheet__apply",disabled:x.loading,onClick:Ne,children:x.loading?m("span",{className:"rle-spinner","aria-label":"Updating results"}):`Show ${Re} results`})]}),children:m(ue,{className:"rle-filter-stack",groupClassName:"rle-filter-group",draft:u,onDraftChange:k})})]})}import{useEffect as ai,useRef as li,useState as di}from"react";import{jsx as ke,jsxs as ui}from"react/jsx-runtime";function pt(t){return"provider"in t}function pi(t){let e=t!=null&&!pt(t),i=e?t.apiKey:void 0,r=e?t.mapId:void 0,s=e?t.mapOptions:void 0,n=e?t.styles:void 0,[o,l]=di(()=>!t||pt(t)?{ready:!0,provider:t?.provider}:{ready:!1});return ai(()=>{if(!i)return;let d=!1;return import("./maps/google/index.js").then(({googleProvider:p})=>{d||l({ready:!0,provider:p({apiKey:i,mapId:r,mapOptions:s,styles:n})})}),()=>{d=!0}},[i,r]),o}function ci({onFiltersChange:t}){let e=li(t);return e.current=t,Je("FiltersChanged",i=>{i.type==="FiltersChanged"&&e.current(i.filters)}),null}function Rn(t){let{datasets:e,filters:i,map:r,components:s,initialFilters:n,onFiltersChange:o,mobileAction:l,search:d,filterBarStart:p,toolbarEnd:a,mapControls:f,mobileSheetFooter:L,config:E,autoFetch:C,className:c}=t,{ready:x,provider:N}=pi(r);if(!x)return null;let S=[];for(let D of e)S.push(Be(D));i&&S.push(He(i)),N&&S.push(_e(N)),n&&S.push(Ae(n)),E&&S.push(Oe(E));let z=De(...S),w={...rt,...s};return ui(et,{...z,children:[o&&ke(ci,{onFiltersChange:o}),ke(Ue,{...w,children:ke(dt,{className:c,search:d,filterBarStart:p,toolbarEnd:a,mobileAction:l,autoFetch:C,mapCenter:r?.center,mapZoom:r?.zoom,mapControls:f,mobileSheetFooter:L})})]})}export{X as a,U as b,J as c,Y as d,Me as e,ee as f,te as g,De as h,Oe as i,_e as j,Be as k,He as l,ki as m,Ae as n,Ii as o,ce as p,Ue as q,T as r,ie as s,y as t,P as u,re as v,ue as w,K as x,$e as y,Ge as z,Ze as A,Xe as B,Je as C,et as D,fe as E,ge as F,ye as G,he as H,ve as I,be as J,Te as K,Pe as L,Fe as M,Ce as N,rt as O,nt as P,ot as Q,dt as R,Rn as S};
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2;"use client";
|
|
2
|
-
var
|
|
2
|
+
var _chunkE4JVC65Pcjs = require('./chunk-E4JVC65P.cjs');var b=(r=>(r.Paged="paged",r.Infinite="infinite",r))(b||{});var v=(i=>(i.FiltersChanged="FiltersChanged",i.ResultsLoaded="ResultsLoaded",i.PointClicked="PointClicked",i.BoundsChanged="BoundsChanged",i.LayerToggled="LayerToggled",i))(v||{});var d= (_class =class{__init() {this.listeners=new Set}constructor(t={}){;_class.prototype.__init.call(this);this.query={...t}}getQuery(){return{...this.query}}setQuery(t){this.query={...t},this.notify()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(let t of[...this.listeners])t()}}, _class);function F(e,t){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r)if(e[s]!==t[s])return!1;return!0}var h= (_class2 =class{__init2() {this.isSyncing=!1}__init3() {this.unsubscribeEngine=null}__init4() {this.unsubscribeHistory=null}constructor(t){;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);this.history=t.history,this.toQueryFn=t.toQuery,this.toFiltersFn=t.toFilters,this.hydrateOnStart=_nullishCoalesce(t.hydrateOnStart, () => (!0))}start(t){this.stop(),this.unsubscribeEngine=t.subscribe(()=>{this.isSyncing||this.syncEngineToHistory(t)}),this.unsubscribeHistory=this.history.subscribe(()=>{this.isSyncing||this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}),this.hydrateOnStart&&this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}stop(){_optionalChain([this, 'access', _ => _.unsubscribeEngine, 'optionalCall', _2 => _2()]),this.unsubscribeEngine=null,_optionalChain([this, 'access', _3 => _3.unsubscribeHistory, 'optionalCall', _4 => _4()]),this.unsubscribeHistory=null}syncEngineToHistory(t){let r=this.toQueryFn(t.state.filters);F(r,this.history.getQuery())||this.withSyncGuard(()=>this.history.setQuery(r))}applyFiltersSafely(t,r){Promise.resolve(t.applyFilters(r)).catch(()=>{})}withSyncGuard(t){this.isSyncing=!0;try{t()}finally{this.isSyncing=!1}}}, _class2);var f=class{constructor(t={}){this.mode=_nullishCoalesce(t.mode, () => ("replace"))}getQuery(){if(typeof window>"u")return{};let t=new URLSearchParams(window.location.search),r={};for(let[s,o]of t)o!==""&&(r[s]=o);return r}setQuery(t){if(typeof window>"u")return;let r=new URLSearchParams;for(let[c,l]of Object.entries(t))l===void 0||l===""||r.set(c,l);let s=r.toString(),o=s?`?${s}`:"";if(o===window.location.search)return;let i=`${window.location.pathname}${o}${window.location.hash}`;this.mode==="push"?window.history.pushState(window.history.state,"",i):window.history.replaceState(window.history.state,"",i)}subscribe(t){return typeof window>"u"?()=>{}:(window.addEventListener("popstate",t),()=>{window.removeEventListener("popstate",t)})}};var _jsxruntime = require('react/jsx-runtime');function st({children:e}){let{Toolbar:t}=_chunkE4JVC65Pcjs.r.call(void 0, );return _jsxruntime.jsx.call(void 0, t,{children:e})}var _react = require('react');function ut(){let e=_chunkE4JVC65Pcjs.t.call(void 0, ),t=_chunkE4JVC65Pcjs.u.call(void 0, ),r=_react.useCallback.call(void 0, n=>e.loadPoints(n),[e]),s=_react.useCallback.call(void 0, (n,g)=>e.selectPoint(n,g),[e]),o=_react.useCallback.call(void 0, n=>e.setHovered(e.primaryDatasetId,n),[e]),i=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _5 => _5.map, 'optionalAccess', _6 => _6.zoomIn, 'call', _7 => _7()]),[e]),c=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _8 => _8.map, 'optionalAccess', _9 => _9.zoomOut, 'call', _10 => _10()]),[e]),l=_react.useCallback.call(void 0, ()=>_optionalChain([e, 'access', _11 => _11.map, 'optionalAccess', _12 => _12.toggleFullscreen, 'call', _13 => _13()]),[e]),m=_react.useCallback.call(void 0, n=>e.fitBounds(n),[e]);return{bounds:t.bounds,points:t.points,hovered:t.hovered,loadPoints:r,selectPoint:s,setHovered:o,zoomIn:i,zoomOut:c,toggleFullscreen:l,fitBounds:m}}function ht(e){let t=_chunkE4JVC65Pcjs.t.call(void 0, ),r=_chunkE4JVC65Pcjs.u.call(void 0, ),s=_react.useCallback.call(void 0, ()=>t.toggleLayer(e),[t,e]);return{visible:_nullishCoalesce(r.layers[e], () => (!0)),points:_nullishCoalesce(r.points[e], () => ([])),toggle:s}}exports.BrowserHistoryPort = f; exports.DatasetRegistry = _chunkE4JVC65Pcjs.c; exports.FallbackPopup = _chunkE4JVC65Pcjs.p; exports.FilterRegistry = _chunkE4JVC65Pcjs.b; exports.ListingApp = _chunkE4JVC65Pcjs.S; exports.ListingComponentsProvider = _chunkE4JVC65Pcjs.q; exports.ListingConfig = _chunkE4JVC65Pcjs.f; exports.ListingEngine = _chunkE4JVC65Pcjs.g; exports.ListingEngineContext = _chunkE4JVC65Pcjs.s; exports.ListingEventType = v; exports.ListingFilters = _chunkE4JVC65Pcjs.w; exports.ListingList = _chunkE4JVC65Pcjs.y; exports.ListingMap = _chunkE4JVC65Pcjs.z; exports.ListingPagination = _chunkE4JVC65Pcjs.A; exports.ListingProvider = _chunkE4JVC65Pcjs.D; exports.ListingResultHeader = _chunkE4JVC65Pcjs.B; exports.ListingStore = _chunkE4JVC65Pcjs.a; exports.ListingToolbar = st; exports.MemoryHistoryPort = d; exports.PaginationMode = b; exports.TypedEmitter = _chunkE4JVC65Pcjs.d; exports.UrlSyncController = h; exports.composeListingProviders = _chunkE4JVC65Pcjs.h; exports.listingDefaultConfig = _chunkE4JVC65Pcjs.e; exports.useListing = _chunkE4JVC65Pcjs.t; exports.useListingComponents = _chunkE4JVC65Pcjs.r; exports.useListingEvent = _chunkE4JVC65Pcjs.C; exports.useListingFilters = _chunkE4JVC65Pcjs.v; exports.useListingLayer = ht; exports.useListingMap = ut; exports.useListingResults = _chunkE4JVC65Pcjs.x; exports.useListingState = _chunkE4JVC65Pcjs.u; exports.withConfig = _chunkE4JVC65Pcjs.i; exports.withDataset = _chunkE4JVC65Pcjs.k; exports.withFilters = _chunkE4JVC65Pcjs.l; exports.withInitialFilters = _chunkE4JVC65Pcjs.n; exports.withMap = _chunkE4JVC65Pcjs.j; exports.withPrimaryDataset = _chunkE4JVC65Pcjs.o; exports.withUrlSync = _chunkE4JVC65Pcjs.m;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { P as Page, B as Bounds, E as EntityId, M as MapPoint, U as Unsubscribe, a as MapProvider, b as MapHandle, Q as QueryParams, L as LatLng } from './map-provider.interface-l-oTHRTZ.cjs';
|
|
2
2
|
export { c as EntityAdapter, d as MapInitOptions, e as MapOverlayHandle, f as PageRequest, R as RenderedLayer } from './map-provider.interface-l-oTHRTZ.cjs';
|
|
3
|
-
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-
|
|
4
|
-
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, q as MobileSheetFooterContext, u as useListingComponents } from './listing-app-
|
|
3
|
+
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-Bna5fHSA.cjs';
|
|
4
|
+
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, q as MobileSheetFooterContext, u as useListingComponents } from './listing-app-Bna5fHSA.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { P as Page, B as Bounds, E as EntityId, M as MapPoint, U as Unsubscribe, a as MapProvider, b as MapHandle, Q as QueryParams, L as LatLng } from './map-provider.interface-l-oTHRTZ.js';
|
|
2
2
|
export { c as EntityAdapter, d as MapInitOptions, e as MapOverlayHandle, f as PageRequest, R as RenderedLayer } from './map-provider.interface-l-oTHRTZ.js';
|
|
3
|
-
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-
|
|
4
|
-
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, q as MobileSheetFooterContext, u as useListingComponents } from './listing-app-
|
|
3
|
+
import { P as PaginationMode, D as DatasetDefinition, I as IListingConfigOptions, F as FilterRegistry, a as IListingToolbarProps } from './listing-app-D1MWFKTR.js';
|
|
4
|
+
export { C as ClusterOptions, b as FallbackPopup, c as FilterControlProps, d as FilterDefinition, e as IListingCardProps, f as IListingComponents, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, L as ListingApp, o as ListingAppProps, p as ListingComponentsProvider, M as MarkerRenderer, q as MobileSheetFooterContext, u as useListingComponents } from './listing-app-D1MWFKTR.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { ReactNode } from 'react';
|
|
7
7
|
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{A as V,B as W,C as X,D as Y,S as P,a as Q,b as x,c as T,d as L,e as H,f as O,g as E,h as k,i as q,j as C,k as I,l as B,m as U,n as z,o as G,p as R,q as $,r as p,s as j,t as u,u as y,v as A,w as D,x as J,y as K,z as N}from"./chunk-
|
|
2
|
+
import{A as V,B as W,C as X,D as Y,S as P,a as Q,b as x,c as T,d as L,e as H,f as O,g as E,h as k,i as q,j as C,k as I,l as B,m as U,n as z,o as G,p as R,q as $,r as p,s as j,t as u,u as y,v as A,w as D,x as J,y as K,z as N}from"./chunk-NTEMHMCX.js";var b=(r=>(r.Paged="paged",r.Infinite="infinite",r))(b||{});var v=(i=>(i.FiltersChanged="FiltersChanged",i.ResultsLoaded="ResultsLoaded",i.PointClicked="PointClicked",i.BoundsChanged="BoundsChanged",i.LayerToggled="LayerToggled",i))(v||{});var d=class{query;listeners=new Set;constructor(t={}){this.query={...t}}getQuery(){return{...this.query}}setQuery(t){this.query={...t},this.notify()}subscribe(t){return this.listeners.add(t),()=>{this.listeners.delete(t)}}notify(){for(let t of[...this.listeners])t()}};function F(e,t){let r=new Set([...Object.keys(e),...Object.keys(t)]);for(let s of r)if(e[s]!==t[s])return!1;return!0}var h=class{history;toQueryFn;toFiltersFn;hydrateOnStart;isSyncing=!1;unsubscribeEngine=null;unsubscribeHistory=null;constructor(t){this.history=t.history,this.toQueryFn=t.toQuery,this.toFiltersFn=t.toFilters,this.hydrateOnStart=t.hydrateOnStart??!0}start(t){this.stop(),this.unsubscribeEngine=t.subscribe(()=>{this.isSyncing||this.syncEngineToHistory(t)}),this.unsubscribeHistory=this.history.subscribe(()=>{this.isSyncing||this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}),this.hydrateOnStart&&this.withSyncGuard(()=>{this.applyFiltersSafely(t,this.toFiltersFn(this.history.getQuery()))})}stop(){this.unsubscribeEngine?.(),this.unsubscribeEngine=null,this.unsubscribeHistory?.(),this.unsubscribeHistory=null}syncEngineToHistory(t){let r=this.toQueryFn(t.state.filters);F(r,this.history.getQuery())||this.withSyncGuard(()=>this.history.setQuery(r))}applyFiltersSafely(t,r){Promise.resolve(t.applyFilters(r)).catch(()=>{})}withSyncGuard(t){this.isSyncing=!0;try{t()}finally{this.isSyncing=!1}}};var f=class{mode;constructor(t={}){this.mode=t.mode??"replace"}getQuery(){if(typeof window>"u")return{};let t=new URLSearchParams(window.location.search),r={};for(let[s,o]of t)o!==""&&(r[s]=o);return r}setQuery(t){if(typeof window>"u")return;let r=new URLSearchParams;for(let[c,l]of Object.entries(t))l===void 0||l===""||r.set(c,l);let s=r.toString(),o=s?`?${s}`:"";if(o===window.location.search)return;let i=`${window.location.pathname}${o}${window.location.hash}`;this.mode==="push"?window.history.pushState(window.history.state,"",i):window.history.replaceState(window.history.state,"",i)}subscribe(t){return typeof window>"u"?()=>{}:(window.addEventListener("popstate",t),()=>{window.removeEventListener("popstate",t)})}};import{jsx as w}from"react/jsx-runtime";function st({children:e}){let{Toolbar:t}=p();return w(t,{children:e})}import{useCallback as a}from"react";function ut(){let e=u(),t=y(),r=a(n=>e.loadPoints(n),[e]),s=a((n,g)=>e.selectPoint(n,g),[e]),o=a(n=>e.setHovered(e.primaryDatasetId,n),[e]),i=a(()=>e.map?.zoomIn(),[e]),c=a(()=>e.map?.zoomOut(),[e]),l=a(()=>e.map?.toggleFullscreen(),[e]),m=a(n=>e.fitBounds(n),[e]);return{bounds:t.bounds,points:t.points,hovered:t.hovered,loadPoints:r,selectPoint:s,setHovered:o,zoomIn:i,zoomOut:c,toggleFullscreen:l,fitBounds:m}}import{useCallback as S}from"react";function ht(e){let t=u(),r=y(),s=S(()=>t.toggleLayer(e),[t,e]);return{visible:r.layers[e]??!0,points:r.points[e]??[],toggle:s}}export{f as BrowserHistoryPort,T as DatasetRegistry,R as FallbackPopup,x as FilterRegistry,P as ListingApp,$ as ListingComponentsProvider,O as ListingConfig,E as ListingEngine,j as ListingEngineContext,v as ListingEventType,D as ListingFilters,K as ListingList,N as ListingMap,V as ListingPagination,Y as ListingProvider,W as ListingResultHeader,Q as ListingStore,st as ListingToolbar,d as MemoryHistoryPort,b as PaginationMode,L as TypedEmitter,h as UrlSyncController,k as composeListingProviders,H as listingDefaultConfig,u as useListing,p as useListingComponents,X as useListingEvent,A as useListingFilters,ht as useListingLayer,ut as useListingMap,J as useListingResults,y as useListingState,q as withConfig,I as withDataset,B as withFilters,z as withInitialFilters,C as withMap,G as withPrimaryDataset,U as withUrlSync};
|
|
@@ -188,8 +188,8 @@ interface IStyledListingLayoutProps<TFilters = unknown> {
|
|
|
188
188
|
filterKey: string;
|
|
189
189
|
placeholder?: string;
|
|
190
190
|
};
|
|
191
|
-
/** Extra content rendered
|
|
192
|
-
|
|
191
|
+
/** Extra content rendered in the desktop filter bar between the search box and the `<ListingFilters>` row (e.g. an "advanced filters" modal trigger). Scrolls with the bar. Desktop-only by construction -- the whole filter bar is CSS-hidden below the mobile breakpoint. */
|
|
192
|
+
filterBarStart?: ReactNode;
|
|
193
193
|
/** Extra content rendered in `.rle-list-header` (above the list), to the right of `ListingResultHeader` (e.g. a sort control + save-search). */
|
|
194
194
|
toolbarEnd?: ReactNode;
|
|
195
195
|
/** Optional mobile-header action button (e.g. "Save"), forwarded verbatim to `<MobileHeader action={...} />`. Omit to render just the search + Filters button there. */
|
|
@@ -290,7 +290,7 @@ interface IStyledListingLayoutProps<TFilters = unknown> {
|
|
|
290
290
|
* default -- pass `autoFetch={false}`
|
|
291
291
|
* to opt out and drive the first fetch yourself.
|
|
292
292
|
*/
|
|
293
|
-
declare function StyledListingLayout<TFilters = unknown>({ search,
|
|
293
|
+
declare function StyledListingLayout<TFilters = unknown>({ search, filterBarStart, toolbarEnd, mobileAction, autoFetch, hasMap: hasMapProp, mapCenter, mapZoom, mapControls, mobileSheetFooter, className, }: IStyledListingLayoutProps<TFilters>): react.JSX.Element;
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
296
|
* Two-shape `map` prop: pass a ready `MapProvider`, or the `{ apiKey, mapId? }`
|
|
@@ -363,8 +363,8 @@ interface ListingAppProps<TFilters> {
|
|
|
363
363
|
/** The mobile header action (e.g. "Save"/"Add") -- forwarded verbatim to `StyledListingLayout`/`MobileHeader`. */
|
|
364
364
|
mobileAction?: IBottomNavAction;
|
|
365
365
|
search?: IStyledListingLayoutProps['search'];
|
|
366
|
-
/** Forwarded verbatim to `StyledListingLayout`'s `
|
|
367
|
-
|
|
366
|
+
/** Forwarded verbatim to `StyledListingLayout`'s `filterBarStart` -- extra content between the search box and the quick-filters row in the desktop filter bar (see that prop's doc comment). */
|
|
367
|
+
filterBarStart?: IStyledListingLayoutProps['filterBarStart'];
|
|
368
368
|
toolbarEnd?: IStyledListingLayoutProps['toolbarEnd'];
|
|
369
369
|
/**
|
|
370
370
|
* Rendered as an absolutely-positioned overlay floating over the map (e.g. zoom/fullscreen
|
|
@@ -188,8 +188,8 @@ interface IStyledListingLayoutProps<TFilters = unknown> {
|
|
|
188
188
|
filterKey: string;
|
|
189
189
|
placeholder?: string;
|
|
190
190
|
};
|
|
191
|
-
/** Extra content rendered
|
|
192
|
-
|
|
191
|
+
/** Extra content rendered in the desktop filter bar between the search box and the `<ListingFilters>` row (e.g. an "advanced filters" modal trigger). Scrolls with the bar. Desktop-only by construction -- the whole filter bar is CSS-hidden below the mobile breakpoint. */
|
|
192
|
+
filterBarStart?: ReactNode;
|
|
193
193
|
/** Extra content rendered in `.rle-list-header` (above the list), to the right of `ListingResultHeader` (e.g. a sort control + save-search). */
|
|
194
194
|
toolbarEnd?: ReactNode;
|
|
195
195
|
/** Optional mobile-header action button (e.g. "Save"), forwarded verbatim to `<MobileHeader action={...} />`. Omit to render just the search + Filters button there. */
|
|
@@ -290,7 +290,7 @@ interface IStyledListingLayoutProps<TFilters = unknown> {
|
|
|
290
290
|
* default -- pass `autoFetch={false}`
|
|
291
291
|
* to opt out and drive the first fetch yourself.
|
|
292
292
|
*/
|
|
293
|
-
declare function StyledListingLayout<TFilters = unknown>({ search,
|
|
293
|
+
declare function StyledListingLayout<TFilters = unknown>({ search, filterBarStart, toolbarEnd, mobileAction, autoFetch, hasMap: hasMapProp, mapCenter, mapZoom, mapControls, mobileSheetFooter, className, }: IStyledListingLayoutProps<TFilters>): react.JSX.Element;
|
|
294
294
|
|
|
295
295
|
/**
|
|
296
296
|
* Two-shape `map` prop: pass a ready `MapProvider`, or the `{ apiKey, mapId? }`
|
|
@@ -363,8 +363,8 @@ interface ListingAppProps<TFilters> {
|
|
|
363
363
|
/** The mobile header action (e.g. "Save"/"Add") -- forwarded verbatim to `StyledListingLayout`/`MobileHeader`. */
|
|
364
364
|
mobileAction?: IBottomNavAction;
|
|
365
365
|
search?: IStyledListingLayoutProps['search'];
|
|
366
|
-
/** Forwarded verbatim to `StyledListingLayout`'s `
|
|
367
|
-
|
|
366
|
+
/** Forwarded verbatim to `StyledListingLayout`'s `filterBarStart` -- extra content between the search box and the quick-filters row in the desktop filter bar (see that prop's doc comment). */
|
|
367
|
+
filterBarStart?: IStyledListingLayoutProps['filterBarStart'];
|
|
368
368
|
toolbarEnd?: IStyledListingLayoutProps['toolbarEnd'];
|
|
369
369
|
/**
|
|
370
370
|
* Rendered as an absolutely-positioned overlay floating over the map (e.g. zoom/fullscreen
|
package/dist/styled/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
-
var
|
|
2
|
+
var _chunkE4JVC65Pcjs = require('../chunk-E4JVC65P.cjs');var _jsxruntime = require('react/jsx-runtime');function L({children:o}){return _jsxruntime.jsx.call(void 0, _chunkE4JVC65Pcjs.q,{..._chunkE4JVC65Pcjs.O,children:o})}exports.BottomNav = _chunkE4JVC65Pcjs.P; exports.BottomSheet = _chunkE4JVC65Pcjs.Q; exports.ListingApp = _chunkE4JVC65Pcjs.S; exports.StyledCard = _chunkE4JVC65Pcjs.E; exports.StyledComponentsProviderWithDefaults = L; exports.StyledEmpty = _chunkE4JVC65Pcjs.F; exports.StyledFilterPanel = _chunkE4JVC65Pcjs.G; exports.StyledListingLayout = _chunkE4JVC65Pcjs.R; exports.StyledLoading = _chunkE4JVC65Pcjs.H; exports.StyledMarker = _chunkE4JVC65Pcjs.I; exports.StyledPopup = _chunkE4JVC65Pcjs.J; exports.StyledResultHeader = _chunkE4JVC65Pcjs.K; exports.StyledSearch = _chunkE4JVC65Pcjs.L; exports.StyledSidebar = _chunkE4JVC65Pcjs.M; exports.StyledToolbar = _chunkE4JVC65Pcjs.N; exports.styledDefaultComponents = _chunkE4JVC65Pcjs.O;
|
package/dist/styled/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-
|
|
4
|
-
export { B as BottomNav, r as BottomNavView, s as IBottomNavAction, t as IBottomNavProps, v as IStyledListingLayoutProps, L as ListingApp, w as ListingAppMapProp, o as ListingAppProps, q as MobileSheetFooterContext, S as StyledListingLayout } from '../listing-app-
|
|
3
|
+
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-Bna5fHSA.cjs';
|
|
4
|
+
export { B as BottomNav, r as BottomNavView, s as IBottomNavAction, t as IBottomNavProps, v as IStyledListingLayoutProps, L as ListingApp, w as ListingAppMapProp, o as ListingAppProps, q as MobileSheetFooterContext, S as StyledListingLayout } from '../listing-app-Bna5fHSA.cjs';
|
|
5
5
|
import '../map-provider.interface-l-oTHRTZ.cjs';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/styled/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-
|
|
4
|
-
export { B as BottomNav, r as BottomNavView, s as IBottomNavAction, t as IBottomNavProps, v as IStyledListingLayoutProps, L as ListingApp, w as ListingAppMapProp, o as ListingAppProps, q as MobileSheetFooterContext, S as StyledListingLayout } from '../listing-app-
|
|
3
|
+
import { e as IListingCardProps, g as IListingEmptyProps, h as IListingFilterPanelProps, i as IListingLoadingProps, j as IListingMarkerProps, k as IListingPopupProps, l as IListingResultHeaderProps, m as IListingSearchProps, n as IListingSidebarProps, a as IListingToolbarProps, f as IListingComponents } from '../listing-app-D1MWFKTR.js';
|
|
4
|
+
export { B as BottomNav, r as BottomNavView, s as IBottomNavAction, t as IBottomNavProps, v as IStyledListingLayoutProps, L as ListingApp, w as ListingAppMapProp, o as ListingAppProps, q as MobileSheetFooterContext, S as StyledListingLayout } from '../listing-app-D1MWFKTR.js';
|
|
5
5
|
import '../map-provider.interface-l-oTHRTZ.js';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/styled/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import{E as r,F as p,G as i,H as y,I as d,J as l,K as n,L as m,M as s,N as a,O as t,P as S,Q as f,R as P,S as u,q as e}from"../chunk-
|
|
2
|
+
import{E as r,F as p,G as i,H as y,I as d,J as l,K as n,L as m,M as s,N as a,O as t,P as S,Q as f,R as P,S as u,q as e}from"../chunk-NTEMHMCX.js";import{jsx as g}from"react/jsx-runtime";function L({children:o}){return g(e,{...t,children:o})}export{S as BottomNav,f as BottomSheet,u as ListingApp,r as StyledCard,L as StyledComponentsProviderWithDefaults,p as StyledEmpty,i as StyledFilterPanel,P as StyledListingLayout,y as StyledLoading,d as StyledMarker,l as StyledPopup,n as StyledResultHeader,m as StyledSearch,s as StyledSidebar,a as StyledToolbar,t as styledDefaultComponents};
|
package/dist/styles.css
CHANGED
|
@@ -686,9 +686,9 @@
|
|
|
686
686
|
gap: var(--rle-space);
|
|
687
687
|
}
|
|
688
688
|
|
|
689
|
-
/* Consumer slot
|
|
690
|
-
as the row itself, never shrinks into the scroll. */
|
|
691
|
-
.rle-filter-
|
|
689
|
+
/* Consumer slot between the search box and the filters row (`filterBarStart`)
|
|
690
|
+
-- same rhythm as the row itself, never shrinks into the scroll. */
|
|
691
|
+
.rle-filter-bar__slot {
|
|
692
692
|
display: flex;
|
|
693
693
|
flex-shrink: 0;
|
|
694
694
|
align-items: center;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-listing-engine",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Headless, composable listing engine for React: filterable list + Google-Maps multi-layer map, with pluggable data adapters, a filter/dataset registry, injectable components, and a Tailwind-free styled adapter.",
|
|
6
6
|
"funding": [
|