import{I as N,L as _,V as R,i as j,a as I}from"./maplibre-gl-worker-BOdO3xHw.js";import{d as $,J as g,o as n,c as i,K as k,g as x,L as B,h as d,a as r,p as T,z as O,N as U,e as A,u as E,s as W,r as q}from"./index-D6fBX2R3.js";const J=["width","height","fill","transform"],K={key:0},Y=r("path",{d:"M228,128a12,12,0,0,1-12,12H40a12,12,0,0,1,0-24H216A12,12,0,0,1,228,128Z"},null,-1),G=[Y],Q={key:1},X=r("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"},null,-1),ee=r("path",{d:"M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z"},null,-1),te=[X,ee],ae={key:2},le=r("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H72a8,8,0,0,1,0-16H184a8,8,0,0,1,0,16Z"},null,-1),oe=[le],re={key:3},ne=r("path",{d:"M222,128a6,6,0,0,1-6,6H40a6,6,0,0,1,0-12H216A6,6,0,0,1,222,128Z"},null,-1),ie=[ne],se={key:4},ue=r("path",{d:"M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z"},null,-1),de=[ue],ce={key:5},pe=r("path",{d:"M220,128a4,4,0,0,1-4,4H40a4,4,0,0,1,0-8H216A4,4,0,0,1,220,128Z"},null,-1),he=[pe],fe={name:"PhMinus"},ge=$({...fe,props:{weight:{type:String},size:{type:[String,Number]},color:{type:String},mirrored:{type:Boolean}},setup(v){const e=v,y=g("weight","regular"),p=g("size","1em"),t=g("color","currentColor"),h=g("mirrored",!1),o=d(()=>e.weight??y),c=d(()=>e.size??p),m=d(()=>e.color??t),w=d(()=>e.mirrored!==void 0?e.mirrored?"scale(-1, 1)":void 0:h?"scale(-1, 1)":void 0);return(f,b)=>(n(),i("svg",B({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",width:c.value,height:c.value,fill:m.value,transform:w.value},f.$attrs),[k(f.$slots,"default"),o.value==="bold"?(n(),i("g",K,G)):o.value==="duotone"?(n(),i("g",Q,te)):o.value==="fill"?(n(),i("g",ae,oe)):o.value==="light"?(n(),i("g",re,ie)):o.value==="regular"?(n(),i("g",se,de)):o.value==="thin"?(n(),i("g",ce,he)):x("",!0)],16,J))}}),ve=["width","height","fill","transform"],me={key:0},ye=r("path",{d:"M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z"},null,-1),we=[ye],be={key:1},xe=r("path",{d:"M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z",opacity:"0.2"},null,-1),He=r("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"},null,-1),$e=[xe,He],ke={key:2},Me=r("path",{d:"M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z"},null,-1),Ve=[Me],ze={key:3},Ze=r("path",{d:"M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z"},null,-1),Ae=[Ze],Ee={key:4},Se=r("path",{d:"M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"},null,-1),Be=[Se],Ce={key:5},Le=r("path",{d:"M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z"},null,-1),Pe=[Le],Fe={name:"PhPlus"},De=$({...Fe,props:{weight:{type:String},size:{type:[String,Number]},color:{type:String},mirrored:{type:Boolean}},setup(v){const e=v,y=g("weight","regular"),p=g("size","1em"),t=g("color","currentColor"),h=g("mirrored",!1),o=d(()=>e.weight??y),c=d(()=>e.size??p),m=d(()=>e.color??t),w=d(()=>e.mirrored!==void 0?e.mirrored?"scale(-1, 1)":void 0:h?"scale(-1, 1)":void 0);return(f,b)=>(n(),i("svg",B({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",width:c.value,height:c.value,fill:m.value,transform:w.value},f.$attrs),[k(f.$slots,"default"),o.value==="bold"?(n(),i("g",me,we)):o.value==="duotone"?(n(),i("g",be,$e)):o.value==="fill"?(n(),i("g",ke,Ve)):o.value==="light"?(n(),i("g",ze,Ae)):o.value==="regular"?(n(),i("g",Ee,Be)):o.value==="thin"?(n(),i("g",Ce,Pe)):x("",!0)],16,ve))}}),Ne={class:"absolute right-2.5 top-2.5 z-[2] flex flex-col gap-1.5"},_e={key:0,class:"absolute left-2.5 top-2.5 z-[2] inline-flex h-[26px] items-center rounded-[7px] bg-white/95 px-2.5 text-[12px] font-medium text-fg-muted shadow-map-control"},Re={class:"absolute bottom-2.5 left-2.5 z-[2] flex gap-1.5"},S="https://tiles.openfreemap.org/styles/positron",Te=$({__name:"LocationMap",props:{lat:{},lon:{},approx:{type:Boolean,default:!1},tone:{default:"primary"},label:{},height:{default:300}},setup(v){const e=v;N()||_(I);const y={primary:"#087F5B",amber:"#B7791F"},p=q(null);let t=null,h=null,o=null;const c=d(()=>e.lat!=null&&e.lon!=null),m=d(()=>y[e.tone]),w=d(()=>e.approx?1500:200),f=d(()=>(e.approx?12:14)-(e.height<200?1:0));let b=null;function C(){return b??(b=fetch(S).then(a=>a.json()).then(a=>{for(const l of a.layers){const s=l.layout;l.type==="symbol"&&(s!=null&&s["text-field"])&&/name/.test(JSON.stringify(s["text-field"]))&&(s["text-field"]=["coalesce",["get","name:cs"],["get","name_int"],["get","name"]]);const u=l.paint;u&&(l.id==="background"?u["background-color"]="#F7F8F7":l.id==="park"?u["fill-color"]="#E6F4EE":l.id==="landcover_wood"?u["fill-color"]="#DDEDE5":l.id==="water"?u["fill-color"]="#D3DEE3":l.id==="waterway"?u["line-color"]="#C3D2D9":l.id==="landuse_residential"&&(u["fill-color"]="#EEF1EF"))}return a}).catch(a=>{throw b=null,a})),b}function L(a,l,s){const u=[],F=s/111320,D=s/(111320*Math.cos(a*Math.PI/180));for(let H=0;H<=64;H++){const Z=H/64*2*Math.PI;u.push([l+D*Math.cos(Z),a+F*Math.sin(Z)])}return{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[u]}}}function P(){const a=document.createElement("div");return e.label?(a.style.cssText="height:26px;padding:0 9px;border-radius:7px;background:#17201C;color:#fff;font:600 12px Nunito,system-ui;display:flex;align-items:center;white-space:nowrap;font-variant-numeric:tabular-nums;box-shadow:0 2px 8px rgba(23,32,28,.25)",a.textContent=e.label):a.style.cssText=`width:14px;height:14px;border-radius:50%;background:${m.value};border:3px solid #fff;box-shadow:0 1px 4px rgba(0,0,0,.3)`,a}function M(){if(!t||!c.value)return;const a=e.lat,l=e.lon,s=L(a,l,w.value),u=t.getSource("area");u?u.setData(s):(t.addSource("area",{type:"geojson",data:s}),t.addLayer({id:"area-fill",type:"fill",source:"area",paint:{"fill-color":m.value,"fill-opacity":e.tone==="amber"?.16:.18}}),t.addLayer({id:"area-line",type:"line",source:"area",paint:{"line-color":m.value,"line-opacity":.6,"line-width":2}})),h==null||h.remove(),h=null,(!e.approx||e.label)&&(h=new j({element:P()}).setLngLat([l,a]).addTo(t)),t.jumpTo({center:[l,a],zoom:f.value})}async function V(){if(!p.value||!c.value||t)return;let a=S;try{a=await C()}catch{}if(!p.value||t)return;const l=new R({container:p.value,style:a,center:[e.lon,e.lat],zoom:f.value,scrollZoom:!1,dragRotate:!1,pitchWithRotate:!1,touchPitch:!1,attributionControl:{compact:!0}});l.touchZoomRotate.disableRotation(),l.on("load",M),t=l,o=new ResizeObserver(()=>t==null?void 0:t.resize()),o.observe(p.value)}const z=a=>t==null?void 0:t.easeTo({zoom:t.getZoom()+a,duration:200});return T(V),O(()=>[e.lat,e.lon,e.approx,e.label],()=>{if(!c.value){t==null||t.remove(),t=null;return}t?t.loaded()&&M():V()},{flush:"post"}),U(()=>{o==null||o.disconnect(),t==null||t.remove(),t=null}),(a,l)=>c.value?(n(),i("div",{key:0,class:"relative overflow-hidden rounded-[10px] bg-[#E8ECE9]",style:W({height:`${v.height}px`})},[r("div",{ref_key:"el",ref:p,class:"!absolute inset-0 h-full w-full"},null,512),r("div",Ne,[r("button",{type:"button","aria-label":"Přiblížit mapu",class:"grid h-8 w-8 place-items-center rounded-lg bg-white text-fg shadow-map-control hover:text-primary",onClick:l[0]||(l[0]=s=>z(1))},[A(E(De),{size:15,weight:"bold"})]),r("button",{type:"button","aria-label":"Oddálit mapu",class:"grid h-8 w-8 place-items-center rounded-lg bg-white text-fg shadow-map-control hover:text-primary",onClick:l[1]||(l[1]=s=>z(-1))},[A(E(ge),{size:15,weight:"bold"})])]),v.approx?(n(),i("span",_e,"Přibližná poloha (střed obce)")):x("",!0),r("div",Re,[k(a.$slots,"default")])],4)):x("",!0)}});export{Te as default};