1import{r as t,u as ae,y as ie,A as le,L as ce,z as ue,k as de,G as pe,aD as me,aE as fe,a as j,j as n,E as ge,W as ye,H as he,K as ke,aF as be}from"./index-D4FK4cu3.js";import{L as v,l as Le}from"./leaflet-DnjZDq_r.js";import{O as Se}from"./Map_Outdoor-BzhR7RJw.js";import{I as we}from"./leaflet-routing-machine-5zchNWYf.js";import"./leaflet-routing-machine-Uazy56cT.js";import{P as xe}from"./PositionPrompt-Do1r9-5x.js";import{V as Me,F as je,I as ve}from"./ValhallaRouter-CBLTwXXQ.js";import{M as V}from"./Marker-CIRzy__8.js";import{P as Ie}from"./Polyline-C0eM1cno.js";import"./useGetRebusPost-SN22Yc5q.js";import"./useSyncRebusData-DoBcNfJJ.js";import"./icon_rebustop-BIwiu0X7.js";const J=(a,p)=>v.divIcon({className:`kp kpMarker a${a}`,iconSize:[40,50],iconAnchor:[20,45],html:p?`<div class="kpLabel">${p}</div>`:""}),Q=(a,p,y)=>v.divIcon({className:`kp numberedMarker a${a}`,iconSize:[40,50],iconAnchor:[20,45],html:`${p||1}`+(y?`<div class="kpLabel">${y}</div>`:"")}),ze=()=>{const a=t.useRef(null),{t:p}=ae(),{search:y}=ie(),{presentationCache:e,currentLanguage:b}=t.useContext(le),{geoLocation:w}=t.useContext(ce),{presentationId:x}=ue(),E=t.useRef(null),[P,X]=t.useState(null),[m,C]=t.useState(null),[h,Y]=t.useState(null),[_,A]=t.useState(!1),[O,$]=t.useState(!1),[B,k]=t.useState(),[H,Z]=t.useState(),[D,L]=t.useState(!0),[S,N]=t.useState(),[z,K]=t.useState(!1),[ee,te]=t.useState(0),[I,se]=t.useState([]),[R,re]=t.useState(0),[T,oe]=t.useState(null),[l,U]=t.useState(e?.displayType==="route"),[f,W]=t.useState(e?.displayType==="rebus");de({documentType:"group",ownerId:String(e?.ownerId),ownerSlug:e?.ownerSlug,language:b},{waitFor:["ownerId","ownerSlug"]});const q=t.useCallback(()=>{let s=!0;return S||(N({}),L(!0),pe.getMapDocumentList({location:w,owner_id:e?.ownerId}).then(r=>{s&&(L(!1),N(r?.items))}).catch(r=>{L(!1),Z(r)})),()=>{s=!1}},[w,S,L,e]);t.useEffect(()=>{!m||!e?.map?.routing||E.current||e?.mapType==="indoor"||!l||(E.current=v.Routing?.control({show:!1,router:new Me({serviceUrl:me,costing:"pedestrian",costing_options:{pedestrian:{shortest:!0,use_tracks:1,use_living_streets:1,walkway_factor:1,alley_factor:1}}}),addWaypoints:!1,draggableWaypoints:!1,extendToWaypoints:!1,lineOptions:{styles:[{color:"#3E7FBB90",weight:6,opacity:.9}]}}).on("routesfound",s=>{}).on("routingerror",s=>{console.error("routingerror:",s.error||s)}).addTo(m),X(E.current))},[m,e,l]),t.useEffect(()=>{if(!e?.map?.routing||!P||!I)return;const s=I.filter(r=>Array.isArray(r)&&r.length===2).map(([r,c])=>v.Routing.waypoint(v.latLng(r,c)));s.length>=2&&P.setWaypoints(s)},[I,e,P]),t.useEffect(()=>{w&&e&&q()},[w,q,e]);const M=t.useCallback((s,r,c)=>{if(s?.type==="keydown"&&!(s?.originalEvent?.key==="Enter"||s?.originalEvent?.key===" "))return;document.querySelectorAll(".leaflet-marker-icon").forEach(g=>{g?.classList?.remove("active")}),k(void 0),s?.target?._icon?.classList?.add("active"),k({id:r,type:f?"rebus":c,presentationId:x,scope:l||f?e?.articles?.list:void 0,isSolved:!0,isLocked:!1})},[x,e,l,f]),G=t.useMemo(()=>{if(!O||!S||!e?.articles?.list)return;let s=[],r=[];if(e?.mapType==="indoor"){const c=e?.indoormaps||[],i=c[R]?.indoormap?.markers||[];let g=0;for(let o=0;o<R;o++){const u=c[o]?.indoormap?.markers;Array.isArray(u)&&(g+=u.length)}Symbol.iterator in Object(i)&&(r=i.map((o,u)=>{const d={id:o?.document_id,location:fe(o?.coordinates?.x||50,o?.coordinates?.y||50,T?.width,T?.height)},ne=l?Q(d?.id,u+g+1,j(o.title,b)):J(d?.id,j(o.title,b));return s.push(d.location),n.jsx(V,{position:d?.location,title:o?.name,icon:ne,eventHandlers:{click:F=>{M(F,d?.id,"article")},keydown:F=>{M(F,d?.id,"article")}}},`marker${d?.id}`)}))}else{const c=e?.articles?.list?.map(i=>i?.document_id)||[];Symbol.iterator in Object(S)&&(r=c?.map((i,g)=>{const o=S.filter(u=>u?.id===i)?.[0]||null;if(o?.location?.lat&&o?.location?.lng){s.push([o?.location?.lat,o?.location?.lng]);const u=l?Q(o?.id,g+1,j(o.title,b)):J(o?.id,j(o.title,b));return n.jsx(V,{position:o?.location,title:o?.name,icon:u,eventHandlers:{click:d=>{M(d,i,"article")},keydown:d=>{M(d,i,"article")}}},`marker${i}`)}else return null}))}return se(s),Y(!0),r},[S,O,M,e,l,R,T]);return t.useEffect(()=>{e?.displayType==="route"?U(!0):e?.displayType==="rebus"?W(!0):(U(!1),W(!1))},[e]),t.useEffect(()=>{const s=new URLSearchParams(y),r=s.get("pos")?.split(","),c=s.get("zoom"),i=s.get("id");if(i&&h){const g=Number(i.replace(/\D/g,""));if(i.charAt(0)==="m"?k({id:g,type:"museum"}):k({id:g,type:f?"rebus":"article",presentationId:x,scope:l||f?e?.articles?.list:void 0}),!/^\d+$/.test(i)){const o=new MutationObserver(()=>{const u=document.querySelector(`.${i}`);u&&(u.classList.add("active"),o.disconnect())});return o.observe(document.body,{childList:!0,subtree:!0}),()=>o.disconnect()}}Array.isArray(r)&&r.length===2&&(A(!0),m?.setView([Number(r[0]),Number(r[1])],Number(c)||5))},[h,k,y,m,x,l,f,e]),t.useEffect(()=>
1{const r=new URLSearchParams(y).get("pos")?.split(",");h&&(L(!1),typeof r!="object"&&e?.mapType!=="indoor"&&setTimeout(()=>{try{m?.fitBounds(a?.current?.getBounds())}catch{}},500))},[h,L,m,y,e?.mapType]),t.useEffect(()=>{e?.map?.clusters!==void 0?K(!!e?.map?.clusters):K(!l&&!f)},[e,f,l]),t.useEffect(()=>{if(!h)return;const s=window.setTimeout(()=>{te(r=>r+1)},1e3);return()=>window.clearTimeout(s)},[h]),H?n.jsx(ge,{message:p(H?.message),tryAgain:!0}):n.jsxs(n.Fragment,{children:[n.jsx(ye,{children:e?.title?n.jsxs("title",{children:[j(e?.title,b)," - KulturPunkt"]}):n.jsx("title",{children:"KulturPunkt"})}),n.jsx(he,{showProgress:D}),n.jsx(ke,{visible:!0,presentationId:x,button:"close",layout:"float"}),!w?.lat&&n.jsx(xe,{layout:"float",scope:"presentation"}),e&&n.jsx(n.Fragment,{children:e?.mapType==="indoor"?n.jsx(we,{active:!0,cluster:z,popupData:B,setPopupData:k,setMapIsLoaded:$,map:m,setMap:C,mapIsCentered:_,setMapIsCentered:A,hasHeader:!0,floors:e?.map?.floorplans,setIndoorFloor:re,setIndoorImageSize:oe,children:n.jsx(n.Fragment,{children:G})}):n.jsx(Se,{active:!0,cluster:z,popupData:B,setPopupData:k,setMapIsLoaded:$,map:m,setMap:C,mapIsCentered:_,setMapIsCentered:A,hasHeader:!0,children:n.jsxs(n.Fragment,{children:[e?.map?.overlays?.map((s,r)=>n.jsx(Ee,{overlayData:s},`overlay${r}`)),h&&n.jsxs(je,{ref:a,children:[G,!e?.map?.routing&&(l||f&&e?.rebus?.sequential)&&n.jsx(Ie,{pathOptions:{color:"#10518F90",lineJoin:"round"},positions:I})]},ee)]})})})]})},Ee=({overlayData:a})=>{const[p]=be(a?.image);return!a?.image?.mediaId||!a?.lat1||!a?.lat2||!a?.lng1||!a?.lng2||!p?.url?null:n.jsx(ve,{alt:a?.title||"",url:`${p?.url}?dimension=max&mediaType=image/webp`,bounds:new Le.LatLngBounds([[a?.lat1,a?.lng1],[a?.lat2,a?.lng2]])})};export{ze as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.