@opengis/gis 0.2.130 → 0.2.131

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.
@@ -40,5 +40,5 @@
40
40
  ${i??"CartoCSS property (Mapnik)."}`}]}}}))}const kn=e.defineComponent({__name:"MonacoEditor",props:{modelValue:{},language:{},theme:{}},emits:["update:modelValue","load"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(null);let i=null,s=null,c=!1;function p(){return new Promise((x,l)=>{if(s)return x(s);if(window.monaco)return s=window.monaco,x(s);const y=u=>{if([...document.styleSheets].some(f=>{var m;return(m=f==null?void 0:f.href)==null?void 0:m.includes(u)}))return;const b=document.createElement("link");b.rel="stylesheet",b.href=u,document.head.appendChild(b)},d=u=>new Promise((b,f)=>{const m=document.createElement("script");m.src=u,m.onload=()=>b(!0),m.onerror=f,document.body.appendChild(m)});y("https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs/editor/editor.main.min.css"),d("https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs/loader.min.js").then(()=>{window.require.config({paths:{vs:"https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs"}}),window.require(["vs/editor/editor.main"],()=>{s=window.monaco,x(s)})}).catch(l)})}function g(){var u,b;if(!a.value||!s)return;i&&i.dispose();const x=o.language||"yaml",l=s.editor.createModel(o.modelValue||"",x),y=x==="cartocss"?{acceptSuggestionOnCommitCharacter:!1,acceptSuggestionOnEnter:"off",snippetSuggestions:"none",tabCompletion:"off",wordBasedSuggestions:"off"}:{};i=s.editor.create(a.value,{model:l,theme:o.theme||"vs-light",automaticLayout:!0,minimap:{enabled:!1},...y});const d=x;s.editor.setModelLanguage(l,d),d==="css"&&((b=(u=s.languages)==null?void 0:u.css)!=null&&b.cssDefaults)&&s.languages.css.cssDefaults.setDiagnosticsOptions({validate:!1,lint:{}}),i.onDidChangeModelContent(()=>{c||r("update:modelValue",i.getValue())})}return e.watch(()=>o.modelValue,x=>{if(!i)return;const l=i.getModel();if(!l)return;const y=l.getValue();if(x!==y){const d=i.getPosition(),u=i.getSelection(),b=i.getScrollTop(),f=i.getScrollLeft();c=!0,i.executeEdits("external-model-sync",[{range:l.getFullModelRange(),text:x||"",forceMoveMarkers:!0}]),u&&i.setSelection(u),d&&i.setPosition(d),i.setScrollTop(b),i.setScrollLeft(f),c=!1}}),e.watch(()=>o.language,x=>{i&&s&&s.editor.setModelLanguage(i.getModel(),x||"yaml")}),e.watch(()=>o.theme,x=>{i&&s&&s.editor.setTheme(x||"vs-light")}),e.onMounted(async()=>{await p(),Ob(s),g()}),e.onBeforeUnmount(()=>{i&&i.dispose()}),(x,l)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"editorContainer",ref:a,class:"w-full h-full"},null,512))}}),Ub={class:"flex flex-col flex-1 overflow-hidden"},qb={class:"flex justify-end gap-2"},Hb=["href"],Wb={class:"flex flex-col flex-1 overflow-hidden"},Yb={class:"bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden mt-3 flex flex-col flex-1"},Zb={class:"relative bg-gradient-to-br from-slate-50 to-white flex-1"},Gb=e.defineComponent({__name:"vs-tab-style",props:{token:{},styleYaml:{},styleText:{}},emits:["update:style-yaml","update:style-text","update"],setup(t,{emit:n}){const o=t,r=n,a=e.ref("");e.watch(()=>o.styleText,p=>{const g=p??"";a.value!==g&&(a.value=g)},{immediate:!0}),e.watch(a,async p=>{var x,l;const g=p??"";o.styleText!==g&&r("update:style-text",g);try{const y=p?hl(p):null;if((x=y==null?void 0:y.colorAttr)!=null&&x.length&&((l=o.styleYaml)==null?void 0:l.colorAttr)!==y.colorAttr){const d=await i(y.colorAttr);y.colors=d.reduce((b,f,m)=>({...b,[f.id.toString()]:s[m]}),{});const u=xl(y);u!==a.value&&(a.value=u)}JSON.stringify(y)!==JSON.stringify(o.styleYaml)&&r("update:style-yaml",y&&typeof y=="object"?y:null)}catch{o.styleYaml!==null&&r("update:style-yaml",null)}});async function i(p){return(await fetch(`/api/gis-service/${o.token}/${p}`).then(x=>x.json())).rows}const s=["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd"],c=async()=>{const p=o.styleYaml?JSON.stringify(o.styleYaml):o.styleText?o.styleText:"null";try{await fetch(`/api/gis-service/${o.token}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({style:p})}),r("update"),ye.notify({type:"success",title:"Успіх",message:"Стилі збережено"})}catch(g){ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти стилі"}),console.log(g)}};return(p,g)=>(e.openBlock(),e.createElementBlock("div",Ub,[e.createElementVNode("div",qb,[e.createElementVNode("a",{target:"_blank",href:"/api/gis-service/"+o.token+"/col",class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Атрибути ",8,Hb),e.createElementVNode("button",{onClick:c,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"},[...g[1]||(g[1]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-save h-3 w-3 mr-1"},[e.createElementVNode("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"}),e.createElementVNode("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7"}),e.createElementVNode("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})],-1),e.createTextVNode(" Зберегти стилі ",-1)])])]),e.createElementVNode("div",Wb,[e.createElementVNode("div",Yb,[g[2]||(g[2]=e.createElementVNode("div",{class:"bg-gradient-to-r from-gray-50 to-gray-100 px-4 py-2 border-b border-gray-200 flex items-center justify-between"},[e.createElementVNode("div",{class:"text-xs text-gray-400"},"YAML")],-1)),e.createElementVNode("div",Zb,[e.createVNode(kn,{modelValue:a.value,"onUpdate:modelValue":g[0]||(g[0]=x=>a.value=x),language:"yaml",theme:"vs-light"},null,8,["modelValue"])])])])]))}}),Kb={class:"flex flex-col flex-1 min-h-0"},Xb={class:"flex flex-col flex-1 min-h-0"},Qb=e.defineComponent({__name:"vs-tab-popup",props:{token:{},fields:{},columns:{}},emits:["update:columns","save"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(o.columns||[]);e.watch(()=>o.columns,u=>a.value=u||[],{immediate:!0}),e.watch(a,u=>{const b=Ue(o.token);b&&(b.popup=u),r("update:columns",u)});const i=e.ref("list"),s=e.ref(!1),c=e.ref([]),p=[{key:"name",label:"Назва",type:"main"}],g={name:{type:"text",label:"Назва",disabled:!0,validators:["required"]},label:{type:"text",label:"Найменування",validators:["required"]},meta:{type:"radio",label:"Meta",mode:"combo",options:[{text:"Заголовок",id:"title"},{text:"Властивість",id:"feature"},{text:"Бейдж",id:"badge"}]},data:{type:"text",label:"Data"}};function x(){c.value=a.value.map(u=>u.name||u.id),s.value=!0}function l(){var m;const u=[...a.value],b=((m=o.fields)==null?void 0:m.filter(h=>c.value.includes(h.name)))||[],f=Kt(u,b,{selectedKeys:c.value,resolveKey:h=>Tt(h)});a.value=f,s.value=!1,c.value=[]}function y(){s.value=!1,c.value=[]}function d(){let u=[];i.value==="all"?u=o.fields||[]:i.value==="none"?u=[]:u=a.value,u.filter(b=>!b.label).forEach(b=>b.label=b.ua),r("save",u)}return(u,b)=>(e.openBlock(),e.createElementBlock("div",Kb,[e.createElementVNode("div",{class:"flex justify-between mb-3 gap-2"},[e.createElementVNode("button",{onClick:x,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Імпорт "),e.createElementVNode("button",{onClick:d,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Зберегти попап ")]),e.createElementVNode("div",Xb,[i.value==="list"?(e.openBlock(),e.createBlock(At,{key:0,modelValue:a.value,"onUpdate:modelValue":b[0]||(b[0]=f=>a.value=f),"columns-scheme":p,"form-scheme":g,"main-col-width":"250px","add-button":!1},null,8,["modelValue"])):e.createCommentVNode("",!0)]),e.createVNode(Zt,{visible:s.value,"onUpdate:visible":b[1]||(b[1]=f=>s.value=f),selection:c.value,"onUpdate:selection":b[2]||(b[2]=f=>c.value=f),fields:t.fields,title:"Імпорт полів","id-prefix":"import-popup",onConfirm:l,onCancel:y},null,8,["visible","selection","fields"])]))}}),Jb={class:"flex flex-col flex-1 min-h-0"},e1={class:"flex justify-between mb-3 gap-2"},t1={class:"p-4 space-y-4 text-sm"},n1={class:"space-y-1"},o1={class:"space-y-1"},r1={class:"flex items-center gap-3"},l1={class:"flex justify-end gap-2 p-4 border-t"},a1=e.defineComponent({__name:"vs-tab-legend",props:{mapInfo:{},token:{},columns:{}},emits:["update:columns","save"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(o.columns||[]);e.watch(()=>o.columns,u=>{a.value=u||[]}),e.watch(a,u=>{r("update:columns",u)});const i=e.ref(!1),s=e.ref({name:"",color:"#2E86DE"}),c=e.defineAsyncComponent(()=>import("@opengis/core").then(u=>u.VsModal)),p=[{key:"name",label:"Назва"},{key:"color",label:"Колір",type:"color"}],g={name:{type:"text",label:"Назва",validators:["required"]},color:{type:"color",label:"Колір",validators:["required"]}};function x(u){u&&l(),i.value=u}function l(){s.value={name:"",color:"#2E86DE"}}function y(){var m,h;const u=(m=s.value.name)==null?void 0:m.trim();if(!u){ye.notify({type:"warning",title:"Перевірка",message:"Вкажіть назву елементу легенди"});return}const b=((h=s.value.color)==null?void 0:h.trim())||"#2E86DE";if(a.value.some(k=>Tt(k)===Tt({name:u}))){ye.notify({type:"warning",title:"Дубль",message:"Такий елемент легенди вже існує"});return}a.value=[...a.value,{name:u,color:b}],l(),i.value=!1}function d(){r("save",a.value)}return(u,b)=>(e.openBlock(),e.createElementBlock("div",Jb,[e.createElementVNode("div",e1,[e.createElementVNode("button",{onClick:b[0]||(b[0]=f=>i.value=!0),class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Додати "),e.createElementVNode("button",{onClick:d,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Зберегти легенду ")]),e.createVNode(At,{modelValue:a.value,"onUpdate:modelValue":b[1]||(b[1]=f=>a.value=f),"columns-scheme":p,"form-scheme":g,"main-col-width":"250px","add-button":!1},null,8,["modelValue"]),e.createVNode(e.unref(c),{teleport:"#modal",visible:i.value,title:"Новий елемент легенди","onUpdate:visible":x},{footer:e.withCtx(()=>[e.createElementVNode("div",l1,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed",onClick:b[5]||(b[5]=f=>x(!1))}," Скасувати "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed",onClick:y}," Додати ")])]),default:e.withCtx(()=>[e.createElementVNode("div",t1,[e.createElementVNode("div",n1,[b[6]||(b[6]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 uppercase tracking-wide"}," Назва ",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[2]||(b[2]=f=>s.value.name=f),type:"text",class:"w-full rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200",placeholder:"Наприклад, Житлова зона"},null,512),[[e.vModelText,s.value.name]])]),e.createElementVNode("div",o1,[b[7]||(b[7]=e.createElementVNode("label",{class:"block text-xs font-medium text-gray-500 uppercase tracking-wide"}," Колір ",-1)),e.createElementVNode("div",r1,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[3]||(b[3]=f=>s.value.color=f),type:"color",class:"h-10 w-16 rounded border border-gray-300"},null,512),[[e.vModelText,s.value.color]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[4]||(b[4]=f=>s.value.color=f),type:"text",class:"flex-1 rounded-md border border-gray-300 px-3 py-2 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200",placeholder:"#FFFFFF"},null,512),[[e.vModelText,s.value.color]])])])])]),_:1},8,["visible"])]))}}),s1={class:"space-y-3 bg-gradient-to-br from-sky-50 to-blue-50 p-4 rounded-xl border border-sky-100 shadow-sm"},i1=["onClick"],c1=["aria-checked","value"],d1={key:0},u1=e.defineComponent({__name:"view-mode-toggle",props:{modelValue:{},options:{},showHtml:{type:Boolean}},emits:["update:modelValue"],setup(t,{emit:n}){const o=t,r=n,a=s=>r("update:modelValue",s),i=o.options||[{value:"all",label:"All"},{value:"list",label:"List"},{value:"none",label:"None"}];return(s,c)=>(e.openBlock(),e.createElementBlock("div",s1,[c[1]||(c[1]=e.createElementVNode("label",{class:"text-sm font-medium text-gray-600"},"Режим відображення",-1)),e.createElementVNode("div",{role:"radiogroup",class:e.normalizeClass(["grid gap-2",`grid-cols-${e.unref(i).length}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(i),p=>(e.openBlock(),e.createElementBlock("div",{key:p.value,onClick:g=>a(p.value),class:e.normalizeClass(["flex items-center justify-center space-x-2 rounded-lg p-2 border transition-all duration-300 cursor-pointer",[t.modelValue===p.value?"bg-gradient-to-r from-sky-200 to-blue-200 border-transparent shadow-sm":"bg-white border-gray-100 hover:border-sky-200 hover:shadow-sm"]])},[e.createElementVNode("button",{type:"button",role:"radio","aria-checked":t.modelValue===p.value,value:p.value,class:"aspect-square rounded-full border border-primary h-4 w-4 flex items-center justify-center text-sky-500"},[t.modelValue===p.value?(e.openBlock(),e.createElementBlock("span",d1,[...c[0]||(c[0]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-circle h-2.5 w-2.5 fill-current text-current"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10"})],-1)])])):e.createCommentVNode("",!0)],8,c1),e.createElementVNode("label",{class:e.normalizeClass(["text-xs font-medium cursor-pointer",t.modelValue===p.value?"text-gray-700":"text-gray-600"])},e.toDisplayString(p.label),3)],10,i1))),128))],2)]))}}),p1={class:"flex flex-col flex-1 min-h-0"},m1={class:"flex flex-col flex-1 min-h-0"},f1=e.defineComponent({__name:"vs-tab-card",props:{fields:{},columns:{},viewMode:{},html:{}},emits:["update:columns","save"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(o.columns||[]);e.watch(()=>o.columns,f=>a.value=f||[],{immediate:!0}),e.watch(a,f=>r("update:columns",f));const i=e.ref(o.viewMode??"list");e.watch(()=>o.viewMode,f=>{f&&f!==i.value&&(i.value=f)});const s=e.ref(o.html??"");e.watch(()=>o.html,f=>{typeof f=="string"&&f!==s.value&&(s.value=f)},{immediate:!0});const c=e.ref(!1),p=e.ref([]),g=[{key:"name",label:"Name",type:"main"}],x={name:{type:"text",label:"Name",validators:["required"],disabled:!0},label:{type:"text",label:"Label",validators:["required"]},format:{type:"radio",label:"Format",mode:"inline",validators:["required"],options:[{text:"Text",id:"text"},{text:"Number",id:"number"},{text:"Date",id:"date"},{text:"File",id:"file"},{text:"Select",id:"select"},{text:"Tags",id:"tags"}]},is_admin:{type:"Switcher",label:"Тільки для адміністративної частини"},data:{type:"text",label:"Data"}};function l(){p.value=i.value==="html"?[]:a.value.map(f=>f.name||f.id),c.value=!0}function y(){var k;const f=[...a.value],m=((k=o.fields)==null?void 0:k.filter(N=>p.value.includes(N.name)).map(N=>{const{type:$,format:E,...w}=N;return{...w,format:E??$??"text"}}))||[],h=Kt(f,m,{selectedKeys:p.value,resolveKey:N=>Tt(N)});if(a.value=h,i.value==="html"&&m.length){const N=m.map(w=>{const S=w.label??"",A=w.name??w.id??"";return`<dd>${S}</dd>
41
41
  <dt>{{ ${A} }}</dt>`}).join(`
42
42
  `),E=(s.value??"").trimEnd();s.value=E?`${E}
43
- ${N}`:N}c.value=!1,p.value=[]}function d(){c.value=!1,p.value=[]}function u(){const f=i.value==="html"?"html":"list",m={card_mode:f};f==="html"?m.html=s.value:f==="list"&&(m.list=a.value),r("save","card",m)}const b=[{value:"all",label:"Всі"},{value:"list",label:"Список"},{value:"none",label:"Жодне"},{value:"html",label:"HTML"}];return(f,m)=>(e.openBlock(),e.createElementBlock("div",p1,[e.createElementVNode("div",{class:"flex justify-between mb-3 gap-2"},[e.createElementVNode("button",{onClick:l,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Імпорт "),e.createElementVNode("button",{onClick:u,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Зберегти ")]),e.createVNode(u1,{modelValue:i.value,"onUpdate:modelValue":m[0]||(m[0]=h=>i.value=h),options:b},null,8,["modelValue"]),e.createElementVNode("div",m1,[i.value==="list"?(e.openBlock(),e.createBlock(At,{key:0,modelValue:a.value,"onUpdate:modelValue":m[1]||(m[1]=h=>a.value=h),"columns-scheme":g,"form-scheme":x,"main-col-width":"250px","add-button":!1},null,8,["modelValue"])):i.value==="html"?(e.openBlock(),e.createBlock(kn,{key:1,modelValue:s.value,"onUpdate:modelValue":m[2]||(m[2]=h=>s.value=h),language:"html",theme:"vs-light",class:"flex-1 min-h-0"},null,8,["modelValue"])):e.createCommentVNode("",!0)]),e.createVNode(Zt,{visible:c.value,"onUpdate:visible":m[3]||(m[3]=h=>c.value=h),selection:p.value,"onUpdate:selection":m[4]||(m[4]=h=>p.value=h),fields:t.fields,title:"Імпорт полів для картки","id-prefix":"import-card",onConfirm:y,onCancel:d},null,8,["visible","selection","fields"])]))}}),g1={class:"flex flex-col flex-1 min-h-0"},y1=e.defineComponent({__name:"vs-tab-filter",props:{fields:{},columns:{}},emits:["update:columns","save"],setup(t,{emit:n}){const o=t,r=n;console.log(o.columns);const a=e.ref(o.columns||[]);e.watch(()=>o.columns,u=>a.value=u||[],{immediate:!0}),e.watch(a,u=>r("update:columns",u),{deep:!0,immediate:!0});const i=e.ref("list"),s=e.ref(!1),c=e.ref([]),p=[{key:"id",label:"Name"},{key:"label",label:"UA"}],g={name:{type:"text",label:"Name",disabled:!0,validators:["required"]},label:{type:"text",label:"UA",validators:["required"]},type:{type:"radio",label:"Тип",position:"horizontal",validators:["required"],options:[{text:"Check",id:"check"},{text:"Range",id:"range"},{text:"Date",id:"date"},{text:"Text",id:"text"},{text:"Select",id:"autocomplete"}]},hidden:{label:"Приховати",type:"Switcher"},data:{type:"text",label:"Класифікатор",conditions:["type","in",["autocomplete","select","check"]],validators:["required"]}};function x(){c.value=a.value.map(u=>u.name||u.id),s.value=!0}function l(){var m;const u=[...a.value],b=((m=o.fields)==null?void 0:m.filter(h=>c.value.includes(h.name)))||[],f=Kt(u,b,{selectedKeys:c.value,resolveKey:h=>Tt(h)});a.value=f,s.value=!1,c.value=[]}function y(){s.value=!1,c.value=[]}function d(){let u=[];i.value==="all"?u=o.fields||[]:i.value==="none"?u=[]:u=a.value,r("save",u)}return(u,b)=>(e.openBlock(),e.createElementBlock("div",g1,[e.createElementVNode("div",{class:"flex justify-between mb-3 gap-2"},[e.createElementVNode("button",{onClick:x,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Імпорт "),e.createElementVNode("button",{onClick:d,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Зберегти фільтр ")]),i.value==="list"?(e.openBlock(),e.createBlock(At,{key:0,modelValue:a.value,"onUpdate:modelValue":b[0]||(b[0]=f=>a.value=f),"columns-scheme":p,"form-scheme":g,"main-col-width":"250px","add-button":!1},null,8,["modelValue"])):e.createCommentVNode("",!0),e.createVNode(Zt,{visible:s.value,"onUpdate:visible":b[1]||(b[1]=f=>s.value=f),selection:c.value,"onUpdate:selection":b[2]||(b[2]=f=>c.value=f),fields:t.fields,title:"Імпорт полів","id-prefix":"import-filter",onConfirm:l,onCancel:y},null,8,["visible","selection","fields"])]))}}),h1=e.defineComponent({__name:"MapDataLayer",props:{id:{},layer:{},styleSpec:{},autoCenter:{type:[Boolean,null]}},setup(t,{expose:n}){var u,b,f,m;const{map:o,flyTo:r,setZoom:a}=tt(),i=((b=(u=e.getCurrentInstance())==null?void 0:u.appContext.config.globalProperties)==null?void 0:b.$settings)||null,s=t,c=s.id;String(s.id);const p=`${location.origin}/api/vtile/${s.id}/ua/{z}/{x}/{y}.vmt?all=1`,g=Ue(c,{source:{type:"vector",tiles:[p],minzoom:0,maxzoom:14},popup:s.layer.popup,layer:{style:(f=s.layer)==null?void 0:f.style}});n({layerHandle:g}),(s.autoCenter??!0)&&r({center:s.layer.center||((m=i==null?void 0:i.map)==null?void 0:m.center)||[30,50],animate:!1});let x=null;function l(){if(!(g!=null&&g.setTiles))return;const h=p.includes("?")?"&":"?",k=`${p}${h}_=${Date.now()}`;g.setTiles([k])}function y(){x&&clearTimeout(x),x=setTimeout(()=>{x=null,d().catch(h=>console.error("Failed to update map layer",h))},300)}async function d(){o.value&&(l(),g.setStyle(s.styleSpec??null))}return e.watch(()=>s.styleSpec,y,{deep:!0}),e.onBeforeUnmount(()=>{g.remove()}),(h,k)=>null}}),x1={class:"flex h-full bg-gradient-to-br from-slate-50 to-white"},b1={class:"flex-1 relative overflow-hidden"},k1={class:"absolute top-0 left-0 w-full z-20"},w1={class:"px-4 sm:px-6 py-4 border-b border-gray-200 bg-white shadow-sm"},_1={class:"flex items-start justify-between gap-4"},E1={class:"flex-1 min-w-0"},C1={class:"flex items-center text-sm text-gray-500 mb-3"},N1={class:"text-gray-900 font-medium truncate max-w-xs"},V1={class:"flex items-center justify-between gap-4"},B1={class:"flex-1 min-w-0"},$1={class:"flex items-center gap-3 mb-1"},S1={class:"text-base font-semibold text-gray-900 truncate"},v1={key:0,class:"px-2 py-0.5 bg-green-50 border border-green-200 rounded flex-shrink-0"},L1={class:"text-xs font-medium text-green-700"},A1=["title"],T1={class:"w-full h-full bg-gradient-to-br from-sky-50 via-white to-blue-50 flex items-center justify-center relative pt-[115px]"},M1={class:"relative w-full h-full"},F1={style:{top:"17px",left:"230px",position:"absolute","z-index":"1"}},D1={class:"absolute top-4 left-4 z-20"},z1={class:"absolute top-[6.5rem] right-2 space-y-1 z-20"},I1={class:"absolute bottom-4 left-4 z-20"},P1={class:"flex-1 flex flex-col h-full"},j1={class:"px-3 pt-3 pb-2 border-b border-gray-100"},R1={class:"items-center justify-center text-muted-foreground grid w-full grid-cols-6 h-12 p-1 bg-gray-50 rounded-xl shadow-sm"},O1=["aria-selected","onClick"],U1={class:"leading-none"},q1={class:"flex flex-col flex-1 overflow-y-hidden p-3"},H1="OpenGIS",Nl=2,Rn=5,W1=1e3,Y1=Object.freeze(Object.defineProperty({__proto__:null,default:Ce(e.defineComponent({__name:"service",props:{hideServiceKey:{type:Boolean,default:!1}},setup(t){var Ke,wt;const n=t,o=e.toRef(n,"hideServiceKey"),r=Fe.useRoute(),a=Fe.useRouter(),{id:i}=r.params,s=e.ref(null),c=e.ref(null),p=e.ref({}),g=e.ref(null),x=((wt=(Ke=e.getCurrentInstance())==null?void 0:Ke.appContext.config.globalProperties)==null?void 0:wt.$settings)||null;function l(G){typeof document>"u"||(document.title=G?`${G} — Сервіс`:H1)}let y=null;const d=e.ref(!1);function u(){var G;return(G=s.value)==null?void 0:G.ctx}function b(G){typeof window>"u"||window.dispatchEvent(new CustomEvent(vn,{detail:G}))}function f(G){var Te,ke,He;const ee=(ke=(Te=u())==null?void 0:Te.map)==null?void 0:ke.value;if(!ee||!G)return[];const be=(He=g.value)!=null&&He.service_id?String(g.value.service_id):null;return(ee.queryRenderedFeatures(G)||[]).filter(ve=>{var X,le,de,xe,P,O;const lt=((X=ve==null?void 0:ve.properties)==null?void 0:X.id)??(ve==null?void 0:ve.id);if(lt==null||!(ve!=null&&ve.source)||be&&String(ve.source)!==be)return!1;const W=Ue(ve.source)||Ue((le=ve.layer)==null?void 0:le.id);if(!W)return!1;const B=(xe=(de=W==null?void 0:W.opts)==null?void 0:de.source)==null?void 0:xe.type,M=(O=(P=W==null?void 0:W.opts)==null?void 0:P.layer)==null?void 0:O.type;return B!=="raster"&&M!=="raster"})}function m(G){const ee=f(G==null?void 0:G.point);b({features:ee,externalItems:[]})}function h(G){if(Array.isArray(G))return h(G[0]);if(typeof G!="string"&&typeof G!="number")return null;const ee=typeof G=="number"?G:Number(G.trim());return Number.isFinite(ee)?ee:null}function k(G,ee){return G.toFixed(ee)}function N(G,ee,be){const Pe=.5*10**-be;return Math.abs(G-ee)>Pe}function $(){var ve,lt,W,B;const G=(lt=(ve=u())==null?void 0:ve.map)==null?void 0:lt.value;if(!G)return;const ee=h(r.query.z),be=h(r.query.x),Pe=h(r.query.y);if(ee==null||be==null||Pe==null)return;const Te=(W=G.getCenter)==null?void 0:W.call(G),ke=(B=G.getZoom)==null?void 0:B.call(G);(!Te||N(Te.lng,be,Rn)||N(Te.lat,Pe,Rn)||N(ke??0,ee,Nl))&&(d.value=!0,G.jumpTo({center:[be,Pe],zoom:ee}),d.value=!1)}function E(){var Te,ke,He,ve;if(d.value)return;const G=(ke=(Te=u())==null?void 0:Te.map)==null?void 0:ke.value;if(!G)return;const ee=(He=G.getCenter)==null?void 0:He.call(G),be=(ve=G.getZoom)==null?void 0:ve.call(G);if(!ee||be==null)return;const Pe={...r.query,z:k(be,Nl),x:k(ee.lng,Rn),y:k(ee.lat,Rn)};r.query.z===Pe.z&&r.query.x===Pe.x&&r.query.y===Pe.y||a.replace({query:Pe})}const w=e.ref(null),S=e.ref(""),A=e.ref([]),R=e.ref([]),Z=e.ref([]),I=e.ref("list"),K=e.ref(""),q=e.ref([]),ne=e.ref(!0);let Y=null;const D=e.computed(()=>{var G,ee;return((G=g.value)==null?void 0:G.id)??((ee=g.value)==null?void 0:ee.service_id)??null}),v=e.computed(()=>{const G=(x==null?void 0:x.map)||null,ee=(G==null?void 0:G.boundary)??null,be=(G==null?void 0:G.katottg)??null;return!ee&&!be?null:{boundary:ee,katottg:be}}),F=e.computed(()=>{const G=g.value;if(!G)return"";const ee=[];!o.value&&G.service_key&&ee.push(`Сервіс: ${G.service_key}`),G.description&&ee.push(G.description);const be=G.group_name||G.group_id;return be&&ee.push(`Група: ${be}`),typeof G.is_public<"u"&&ee.push(G.is_public?"Публічний":"Не публічний"),typeof G.is_active<"u"&&ee.push(G.is_active?"Активний":"Неактивний"),ee.join(", ")}),V=e.computed(()=>{const G=g.value,ee=(G==null?void 0:G.group_name)||(G==null?void 0:G.group_id);return ee?String(ee).toUpperCase():""}),_=[{key:"style",label:"Стиль",icon:kl},{key:"popup",label:"Попап",icon:lb},{key:"filter",label:"Фільтр",icon:cb},{key:"legend",label:"Легенда",icon:Qx},{key:"card",label:"Картка",icon:wl},{key:"metadata",label:"Метадані",icon:Bo}],T=_.map(G=>G.key),z=e.ref("style");e.onMounted(async()=>{const G=r.query.tab;G&&T.includes(G)&&(z.value=G),await ie(),Q()});async function Q(){var Pe;const G=u();if(!(G!=null&&G.ready))return;await G.ready(),$();const ee=(Pe=G.map)==null?void 0:Pe.value;if(!ee)return;const be=()=>E();ee.on("moveend",be),ee.on("zoomend",be),ee.on("click",m),y=()=>{ee.off("moveend",be),ee.off("zoomend",be),ee.off("click",m)}}e.watch(()=>[r.query.z,r.query.x,r.query.y],()=>{$()}),e.watch(z,G=>{r.query.tab!==G&&a.replace({query:{...r.query,tab:G}})}),e.watch(()=>r.query.tab,G=>{G&&T.includes(G)&&z.value!==G&&(z.value=G)}),e.watch(()=>{var G;return(G=g.value)==null?void 0:G.name},G=>l(G),{immediate:!0});function se(G){if(!G)return null;try{return JSON.parse(JSON.stringify(G))}catch(ee){return console.warn("Failed to clone style",ee),null}}function te(G){if(!G)return null;if(typeof G=="string")try{return Jn(bl.load(G)||null)}catch(ee){return console.warn("Failed to parse style yaml",ee),null}return Jn(se(G))}function oe(G,ee){try{return JSON.stringify(G)===JSON.stringify(ee)}catch{return!1}}function fe(){var ee;if(!g.value)return;const G=te(w.value);oe(G,((ee=g.value)==null?void 0:ee.style)??null)||(g.value={...g.value,style:G})}function he(){Y&&clearTimeout(Y),Y=setTimeout(()=>{Y=null,fe()},W1)}const ie=async()=>{try{const G=await fetch(`/api/gis-service/${i}`);if(!G.ok)throw new Error(`${G.status}`);const ee=await G.json();p.value=ee||{},c.value=i;const be=te(ee.style);g.value=ee?{...ee,style:se(be)}:null,w.value=be,S.value=typeof(ee==null?void 0:ee.style)=="string"?ee.style:be?bl.dump(be):"",R.value=(ee==null?void 0:ee.popup)||[],I.value=ee.card_mode==="html"?"html":"list",Z.value=ee.card,K.value=ee.html,A.value=(ee==null?void 0:ee.legend)||[],q.value=(ee==null?void 0:ee.filters)||[]}catch(G){console.error("Failed to fetch map info",G)}};e.watch(()=>{var G;return(G=g.value)==null?void 0:G.style},G=>{w.value=te(G)},{deep:!0}),e.watch(()=>w.value,()=>{he()},{deep:!0}),e.onBeforeUnmount(()=>{Y&&(clearTimeout(Y),Y=null),y==null||y(),y=null});async function Be(G){try{const ee=await fetch(`/api/gis-clear-vtile/${G}`),{message:be,error:Pe,code:Te}=await ee.json();if(Te===200)return ye.notify({type:"success",title:"Успіх",message:be});ye.notify({type:"error",title:"Помилка",message:Pe})}catch(ee){ye.notify({type:"error",title:"Помилка",message:"Не вдалося очистити тайли"}),console.error(ee)}}async function We(G,ee){await Re({[G]:ee},G)}function qe(){const G=se(w.value);g.value=g.value?{...g.value,style:G}:g.value}async function Re(G,ee){if(g.value={...g.value||{},...G},typeof G.html<"u"&&(p.value={...p.value||{},html:G.html}),!!D.value)try{if(!(await fetch(`/api/gis-service/${D.value}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)})).ok)throw new Error("Save failed");ye.notify({type:"success",title:"Успіх",message:`${ee} saved`}),await ie()}catch(be){ye.notify({type:"error",title:"Помилка",message:`Failed to save ${ee}`}),console.error(be)}}async function Ge(G,ee){if(G!=="card"){await We(G,ee);return}const be=(ee==null?void 0:ee.card_mode)==="html"?"html":"list",Pe=be==="html"&&typeof(ee==null?void 0:ee.html)=="string"?ee.html:"",Te=(be==="html"?[]:null)||(Array.isArray(ee==null?void 0:ee.list)?ee.list:[]);Z.value=Te,I.value=be,K.value=Pe;const ke={card_mode:be};be==="html"&&(ke.html=Pe),be==="list"&&(ke.card=Te),await Re(ke,"card")}return(G,ee)=>{var be,Pe,Te;return e.openBlock(),e.createElementBlock("div",x1,[e.createElementVNode("div",b1,[e.createElementVNode("div",k1,[e.createElementVNode("div",w1,[e.createElementVNode("div",_1,[e.createElementVNode("div",E1,[e.createElementVNode("div",C1,[e.createElementVNode("button",{type:"button",class:"hover:text-gray-700 cursor-pointer transition-colors",onClick:ee[0]||(ee[0]=ke=>e.unref(a).push("/gis.datasets"))}," Datasets "),ee[11]||(ee[11]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-chevron-right w-4 h-4 mx-1"},[e.createElementVNode("path",{d:"m9 18 6-6-6-6"})],-1)),e.createElementVNode("span",N1,e.toDisplayString(((be=g.value)==null?void 0:be.name)||"Dataset"),1)]),e.createElementVNode("div",V1,[e.createElementVNode("div",B1,[e.createElementVNode("div",$1,[e.createElementVNode("h1",S1,e.toDisplayString(((Pe=g.value)==null?void 0:Pe.name)||"Dataset"),1),V.value?(e.openBlock(),e.createElementBlock("div",v1,[e.createElementVNode("span",L1,e.toDisplayString(V.value),1)])):e.createCommentVNode("",!0)]),F.value?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-xs text-gray-500 truncate",title:F.value},e.toDisplayString(F.value),9,A1)):e.createCommentVNode("",!0)])])]),D.value?(e.openBlock(),e.createBlock(So,{key:0,class:"flex-shrink-0","entity-id":D.value,"entity-info":{name:(Te=g.value)==null?void 0:Te.name},table:"gis.services.table","entity-label":"Сервіс","save-method":"put","show-xml-item":!1,"clear-tiles-handler":Be,onSaved:ie},null,8,["entity-id","entity-info"])):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",T1,[e.createElementVNode("div",M1,[e.createVNode(Bn,{ref_key:"mapViewRef",ref:s},{default:e.withCtx(()=>{var ke,He,ve,lt,W,B,M;return[(ke=g.value)!=null&&ke.service_id?(e.openBlock(),e.createBlock(h1,{key:0,id:(He=g.value)==null?void 0:He.service_id,layer:g.value,"style-spec":((ve=g.value)==null?void 0:ve.style)||null,autoCenter:!1},null,8,["id","layer","style-spec"])):e.createCommentVNode("",!0),D.value?(e.openBlock(),e.createBlock(or,{key:1,"layer-id":D.value,boundary:((lt=g.value)==null?void 0:lt.boundary)||((W=v.value)==null?void 0:W.boundary)||null,katottg:((B=g.value)==null?void 0:B.katottg)||((M=v.value)==null?void 0:M.katottg)||null},null,8,["layer-id","boundary","katottg"])):e.createCommentVNode("",!0),e.createElementVNode("div",F1,[D.value?(e.openBlock(),e.createBlock(uo,{key:0,"layer-id":D.value,filters:q.value},null,8,["layer-id","filters"])):e.createCommentVNode("",!0)]),ee[12]||(ee[12]=e.createElementVNode("div",{id:"map-filter-popover-host",class:"map-widget__filter-host"},null,-1)),e.createElementVNode("div",D1,[e.createVNode(Wt)]),e.createElementVNode("div",z1,[e.createVNode(It),p.value.center?(e.openBlock(),e.createBlock(It,{key:0,targetCenter:p.value.center,targetLabel:"Ценр даних"},null,8,["targetCenter"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",I1,[e.createVNode(co,{items:A.value||null},null,8,["items"])]),e.createVNode(Zo),e.createVNode(io,{html:p.value.html},null,8,["html"])]}),_:1},512)])]),e.createVNode(Vo,{open:ne.value,onToggle:ee[1]||(ee[1]=ke=>ne.value=!ne.value),"top-class":"top-4"},null,8,["open"])]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white border-l border-gray-100 flex flex-col overflow-hidden shadow-lg flex-shrink-0 transition-[width] duration-100 ease-in-out",ne.value?"w-[650px]":"w-0"])},[e.createElementVNode("div",P1,[e.createElementVNode("div",j1,[e.createElementVNode("div",R1,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(_,ke=>e.createElementVNode("button",{key:ke.key,type:"button",role:"tab","aria-selected":z.value===ke.key,class:e.normalizeClass(["whitespace-nowrap flex flex-col items-center justify-center gap-0.5 py-1 px-1 text-[9px] font-medium transition-all duration-300 hover:bg-white/70 rounded-lg group",z.value===ke.key?"bg-white shadow-sm text-gray-700":""]),onClick:He=>z.value=ke.key},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(ke.icon),{class:"h-3.5 w-3.5 mb-0.5"})),e.createElementVNode("span",U1,e.toDisplayString(ke.label),1)],10,O1)),64))])]),e.createElementVNode("div",q1,[z.value==="style"?(e.openBlock(),e.createBlock(Gb,{key:0,token:D.value,"style-text":S.value,"style-yaml":w.value,"onUpdate:styleYaml":ee[2]||(ee[2]=ke=>w.value=ke),"onUpdate:styleText":ee[3]||(ee[3]=ke=>S.value=ke),onUpdate:qe},null,8,["token","style-text","style-yaml"])):z.value==="legend"?(e.openBlock(),e.createBlock(a1,{key:1,token:D.value,columns:A.value,"onUpdate:columns":ee[4]||(ee[4]=ke=>A.value=ke),onSave:ee[5]||(ee[5]=ke=>We("legend",ke))},null,8,["token","columns"])):z.value==="popup"?(e.openBlock(),e.createBlock(Qb,{key:2,token:D.value,columns:R.value,fields:p.value.fields,"onUpdate:columns":ee[6]||(ee[6]=ke=>R.value=ke),onSave:ee[7]||(ee[7]=ke=>We("popup",ke))},null,8,["token","columns","fields"])):z.value==="card"?(e.openBlock(),e.createBlock(f1,{key:3,token:D.value,columns:Z.value,fields:p.value.fields,"view-mode":I.value,html:K.value,"onUpdate:columns":ee[8]||(ee[8]=ke=>Z.value=ke),onSave:Ge},null,8,["token","columns","fields","view-mode","html"])):z.value==="filter"?(e.openBlock(),e.createBlock(y1,{key:4,token:D.value,fields:p.value.fields,columns:q.value,"onUpdate:columns":ee[9]||(ee[9]=ke=>q.value=ke),onSave:ee[10]||(ee[10]=ke=>We("filters",ke))},null,8,["token","fields","columns"])):z.value==="metadata"?(e.openBlock(),e.createBlock($o,{key:5,data:g.value,"entity-id":String(e.unref(i)),"entity-type":"service",onSaved:ie},null,8,["data","entity-id"])):e.createCommentVNode("",!0)])])],2)])}}}),[["__scopeId","data-v-008c5939"]])},Symbol.toStringTag,{value:"Module"})),Z1={class:"flex-1 flex flex-col bg-gray-50 h-screen overflow-hidden p-0 m-0"},G1={href:"/api/gis-create-xml",target:"_blank",rel:"noreferrer",class:"flex h-[2rem] items-center gap-1.5 px-3 py-1.5 bg-slate-50 text-slate-700 rounded-md border border-slate-200 hover:bg-slate-100 transition-colors text-sm"},K1={class:"flex-1 px-4 sm:px-6 pb-4 overflow-y-auto overflow-x-visible"},X1={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-visible"},Q1={class:"p-3 border-b border-gray-200"},J1={class:"flex flex-col sm:flex-row gap-2"},ek={class:"entity-table-root"},tk={class:"gap-2 inline-flex"},nk=["onClick"],ok={key:0,class:"flex flex-col gap-3 border-t border-gray-200 px-4 py-3 sm:flex-row sm:items-center sm:justify-between bg-gray-50"},rk={class:"text-sm text-gray-500"},lk={class:"font-medium text-gray-700"},ak={class:"font-medium text-gray-700"},sk={class:"font-medium text-gray-700"},ik={class:"flex items-center justify-end gap-3"},ck=Object.freeze(Object.defineProperty({__proto__:null,default:Ce(e.defineComponent({__name:"RastersTablePage",props:{entityKey:{default:"rasters"},entityBasePath:{default:"/gis.rasters"},columnsConfig:{default:()=>[]}},setup(t){const n=e.defineAsyncComponent(()=>import("@opengis/table")),o=Fe.useRoute(),r=Fe.useRouter(),a=t,i=e.computed(()=>{var v;return String(((v=o.meta)==null?void 0:v.title)||"Растри")}),s=e.computed(()=>{var v;return String(((v=o.meta)==null?void 0:v.description)||"")}),c=e.computed(()=>`Пошук ${String(i.value).trim()}...`),p=e.computed(()=>a.entityKey||"rasters"),g=e.computed(()=>a.entityBasePath||"/gis.rasters"),x=e.ref([]),l=e.ref(!0),y=e.ref([]),d=e.ref([]),u=e.ref({}),b=e.ref([]),f=e.ref(String(o.query.search??"")),m=e.ref(Math.max(1,Number(o.query.page)||1)),h=e.ref(15),k=e.ref(0),N=e.computed(()=>k.value>0),$=e.computed(()=>k.value?(m.value-1)*h.value+1:0),E=e.computed(()=>k.value?Math.min(m.value*h.value,k.value):0);function w(v){const F=new URLSearchParams;return Object.entries(v).forEach(([V,_])=>{if(!(_==null||_==="")){if(Array.isArray(_)){_.forEach(T=>{T!=null&&T!==""&&F.append(V,String(T))});return}F.append(V,String(_))}}),F.toString()}function S(){return`${g.value}/new`}function A(v){return`${g.value}/${v}/edit`}async function R(){try{l.value=!0;const v=`/api/data/gis.${p.value}.table`,F=w({...u.value,page:m.value,limit:h.value}),V=await fetch(F?`${v}?${F}`:v);if(!V.ok)throw new Error(`Rows fetch failed: ${V.status}`);const _=await V.json();x.value=_.rows||[],k.value=Number(_.filtered??_.total??_.count??x.value.length)||0,y.value=a.columnsConfig.length?a.columnsConfig:_.columns||[],d.value=_.filters||[],b.value=_.actions||[],y.value.length&&!y.value[0].link?y.value[0].link=`${g.value}/{id}`:y.value.length&&(y.value[0].link=`${g.value}/{id}`)}catch{x.value=[],k.value=0}finally{l.value=!1}}function Z(v){u.value=v,m.value=1,D(),R()}async function I(v,F,V){const _=await fetch(`/api/form/gis.${p.value}.table/${v.id}`);if(!_.ok)throw new Error(`Form fetch failed: ${_.status}`);const z=(await _.json()).token,Q=await fetch(`/api/table/${z}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({[F]:V})});if(!Q.ok)throw ye.notify({type:"error",title:"Помилка збереження",message:`Поле "${F}" не оновлено`}),new Error(`Save failed: ${Q.status}`);ye.notify({title:"Збережено",message:`Поле "${F}" оновлено`})}function K(v,F){u.value={...u.value,[v]:F},m.value=1,D(),R()}function q(v){K((v==null?void 0:v.name)||"search",(v==null?void 0:v.value)??f.value)}function ne(v){f.value="",K(v||"search",void 0)}function Y(v){!v||v===m.value||(m.value=v,D(),R())}function D(){const v={...o.query,page:String(m.value),...f.value?{search:f.value}:{}};f.value||delete v.search,delete v.view,r.replace({query:v})}return e.onMounted(()=>{R(),document.title=i.value}),e.watch(()=>o.name,()=>{m.value=1,f.value="",R(),document.title=i.value}),e.watch(()=>o.query,v=>{const F=Math.max(1,Number(v.page)||1),V=String(v.search??""),_=F!==m.value,T=V!==f.value;!_&&!T||(m.value=F,f.value=V,u.value={...u.value,search:V||void 0},R())}),(v,F)=>(e.openBlock(),e.createElementBlock("div",Z1,[e.createVNode(Yt,{variant:"table"},e.createSlots({title:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.value),1)]),actions:e.withCtx(()=>[e.createElementVNode("a",G1,[e.createVNode(e.unref(ce.RefreshCw),{size:16}),F[2]||(F[2]=e.createTextVNode(" Оновити растри ",-1))]),e.createElementVNode("a",{onClick:F[0]||(F[0]=V=>e.unref(r).push(S())),class:"hover:cursor-pointer flex items-center gap-1.5 px-3 py-1.5 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors text-sm"},[e.createVNode(e.unref(ce.Plus),{size:16}),F[3]||(F[3]=e.createTextVNode(" Додати ",-1))])]),_:2},[s.value?{name:"description",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),key:"0"}:void 0]),1024),e.createElementVNode("div",K1,[e.createElementVNode("div",X1,[e.createElementVNode("div",Q1,[e.createElementVNode("div",J1,[e.createVNode(e.unref(Nn.FilterField),{modelValue:f.value,"onUpdate:modelValue":F[1]||(F[1]=V=>f.value=V),name:"search",type:"text",layout:"inline",class:"flex-1",width:"100%",cleanable:!0,onChange:q,onClear:ne,placeholder:c.value},null,8,["modelValue","placeholder"]),e.createVNode(e.unref(Nn.Filter),{schema:d.value,value:u.value,onChange:Z,layout:"inline",mode:"soft",view:"popover",limit:8,class:"flex-shrink-0"},null,8,["schema","value"])])]),e.createElementVNode("div",ek,[e.createVNode(e.unref(n),{rows:x.value,columns:y.value,loading:l.value,router:e.unref(r),selectable:!1,onCellUpdate:I,classWrapper:"overflow-x-auto overflow-y-visible",TableStyle:"w-full",classTable:"w-full min-w-[640px]",classThead:"bg-gray-50 border-b border-gray-200",classTh:"px-3 sm:px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",classTbody:"bg-white divide-y divide-gray-200",classTr:"hover:bg-gray-50 transition-colors",classTd:"px-3 sm:px-4 py-2.5 whitespace-nowrap",classLink:"text-sm font-medium text-blue-600 hover:text-blue-800 hover:underline text-left"},{action:e.withCtx(({row:V})=>[e.createElementVNode("div",tk,[e.createElementVNode("button",{onClick:_=>e.unref(r).push(A(V.id)),class:"inline-flex items-center justify-center bg-white border rounded-md size-7 gap-x-2 hover:bg-gray-100",title:"Редагувати","aria-label":"Редагувати"},[e.createVNode(Vn)],8,nk)])]),_:1},8,["rows","columns","loading","router"])]),N.value?(e.openBlock(),e.createElementBlock("div",ok,[e.createElementVNode("div",rk,[F[4]||(F[4]=e.createTextVNode(" Показано ",-1)),e.createElementVNode("span",lk,e.toDisplayString($.value),1),F[5]||(F[5]=e.createTextVNode(" - ",-1)),e.createElementVNode("span",ak,e.toDisplayString(E.value),1),F[6]||(F[6]=e.createTextVNode(" з ",-1)),e.createElementVNode("span",sk,e.toDisplayString(k.value),1)]),e.createElementVNode("div",ik,[e.createVNode(e.unref(ye.VsPagination),{total:k.value,page:m.value,"page-size":h.value,showPageSizes:!1,pageRange:5,view:"button",color:"gray","onUpdate:page":Y,onPageChange:Y},null,8,["total","page","page-size"])])])):e.createCommentVNode("",!0)])])]))}}),[["__scopeId","data-v-63309b89"]])},Symbol.toStringTag,{value:"Module"})),dk={class:"flex-1 overflow-y-auto p-4 sm:p-6"},uk={class:"space-y-3"},pk={class:"bg-white p-3 rounded-xl border border-gray-200 shadow-sm"},mk={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2"},fk={class:"text-xs text-gray-500 mb-1"},gk={key:0,class:"text-base text-md font-semibold text-gray-900"},yk={key:1,class:"text-base text-md font-semibold text-gray-900"},hk={class:"bg-white p-3 rounded-xl border border-gray-200 shadow-sm"},xk={class:"space-y-2"},bk={class:"bg-gradient-to-br from-blue-50 to-blue-100/30 p-4 rounded-lg border border-blue-200"},kk={class:"text-sm font-semibold text-gray-900"},wk={class:"text-xs text-gray-600 mt-1"},_k={class:"grid grid-cols-2 gap-3"},Ek={class:"text-xs text-gray-500 mb-1"},Ck={class:"text-sm font-semibold text-gray-900"},Nk={class:"bg-gray-50 p-4 rounded-lg"},Vk={class:"grid grid-cols-2 gap-4"},Bk={class:"text-xs text-gray-500 mb-1"},$k={class:"text-sm font-semibold text-gray-900"},Sk=e.defineComponent({directives:{tooltip:ye.TooltipDirective},__name:"raster-info-tab",props:{details:{}},setup(t){return(n,o)=>{const r=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("div",dk,[e.createElementVNode("div",uk,[e.createElementVNode("div",pk,[o[0]||(o[0]=e.createElementVNode("div",{class:"mb-4"},[e.createElementVNode("h4",{class:"text-sm font-semibold text-gray-900 uppercase tracking-wide"},"Основні параметри")],-1)),e.createElementVNode("div",mk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.details.baseParams,a=>(e.openBlock(),e.createElementBlock("div",{key:a.label,class:"bg-gray-50 p-2 rounded-lg"},[e.createElementVNode("p",fk,e.toDisplayString(a.label),1),a.tooltip?e.withDirectives((e.openBlock(),e.createElementBlock("p",gk,[e.createTextVNode(e.toDisplayString(a.value),1)])),[[r,a.tooltip]]):(e.openBlock(),e.createElementBlock("p",yk,e.toDisplayString(a.value),1))]))),128))])]),e.createElementVNode("div",hk,[o[3]||(o[3]=e.createElementVNode("div",{class:"mb-2"},[e.createElementVNode("h4",{class:"text-sm font-semibold text-gray-900 uppercase tracking-wide"},"Просторова інформація")],-1)),e.createElementVNode("div",xk,[e.createElementVNode("div",null,[o[1]||(o[1]=e.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"},"Система координат",-1)),e.createElementVNode("div",bk,[e.createElementVNode("p",kk,e.toDisplayString(t.details.spatial.crs.code),1),e.createElementVNode("p",wk,e.toDisplayString(t.details.spatial.crs.description),1)])]),e.createElementVNode("div",null,[o[2]||(o[2]=e.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"},"Межі покриття",-1)),e.createElementVNode("div",_k,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.details.spatial.bounds,a=>(e.openBlock(),e.createElementBlock("div",{key:a.label,class:"bg-gray-50 p-2 rounded-lg border border-gray-200"},[e.createElementVNode("p",Ek,e.toDisplayString(a.label),1),e.createElementVNode("p",Ck,e.toDisplayString(a.value),1)]))),128))])]),e.createElementVNode("div",Nk,[e.createElementVNode("div",Vk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.details.spatial.resolution,a=>(e.openBlock(),e.createElementBlock("div",{key:a.label},[e.createElementVNode("p",Bk,e.toDisplayString(a.label),1),e.createElementVNode("p",$k,e.toDisplayString(a.value),1)]))),128))])])])])])])}}}),vk={class:"flex-1 overflow-y-auto space-y-3 pr-1"},Lk={class:"font-medium text-sm text-gray-800"},Ak={class:"text-xs text-gray-500"},Tk=e.defineComponent({__name:"raster-files-tab",props:{files:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",vk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.files,r=>(e.openBlock(),e.createElementBlock("div",{key:r.name,class:"border border-gray-100 rounded-xl p-4 shadow-sm bg-white flex items-start justify-between"},[e.createElementVNode("div",null,[e.createElementVNode("p",Lk,e.toDisplayString(r.name),1),e.createElementVNode("p",Ak,e.toDisplayString(r.resolution)+" • "+e.toDisplayString(r.size)+"MB",1)]),e.createElementVNode("span",{class:e.normalizeClass(["text-[11px] font-semibold px-2 py-0.5 rounded-full",r.statusClass])},e.toDisplayString(r.status),3)]))),128))]))}}),Mk={},Fk={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function Dk(t,n){return e.openBlock(),e.createElementBlock("svg",Fk,[...n[0]||(n[0]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"8"},null,-1),e.createElementVNode("path",{d:"M11 12h1v4h1"},null,-1)])])}const zk=Ce(Mk,[["render",Dk]]),Ik={class:"absolute top-[5.5rem] left-4 z-30 flex flex-col items-start gap-2"},Pk={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},jk={class:"flex items-center gap-2"},Rk={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},Ok={class:"inline-flex items-center gap-2 text-[11px] text-slate-600"},Uk=["checked"],qk=e.defineComponent({__name:"RasterLayer",props:{tileUrl:{},extent:{},layerId:{},beforeId:{},showRasterExtent:{type:Boolean}},emits:["toggle-extent"],setup(t){const n=t,o=n.layerId||"raster-preview-layer",r=`${o}-source`,a=n.extent&&n.extent.length===4?[...n.extent]:void 0,i=Ue(o,{sourceId:r,source:{type:"raster",tiles:n.tileUrl?[n.tileUrl+"?nottl=1"]:[],tileSize:256,...a?{bounds:a}:{}},layer:{id:`${o}-raster`,type:"raster",paint:{"raster-opacity":1}},beforeId:n.beforeId??null}),{fitBounds:s}=tt(),c=e.ref(1);e.watch(()=>n.tileUrl,l=>{if(!l){i.setVisible(!1);return}i.setVisible(!0),i.setTiles([l])},{immediate:!0}),e.watch(()=>c.value,l=>{i.setOpacity(l)},{immediate:!0});let p=null,g=!1;e.watch(()=>n.extent,l=>{if(!l||l.length!==4)return;const y=l.join(",");if(y!==p){if(p=y,!g){g=!0;return}s==null||s([[l[0],l[1]],[l[2],l[3]]],{padding:40,maxZoom:17})}},{immediate:!0});const x=e.computed(()=>`${Math.round(c.value*100)}%`);return(l,y)=>(e.openBlock(),e.createElementBlock("div",Ik,[e.createElementVNode("div",Pk,[e.createElementVNode("div",jk,[y[2]||(y[2]=e.createElementVNode("span",null,"Прозорість:",-1)),e.withDirectives(e.createElementVNode("input",{type:"range",min:"0",max:"1",step:"0.01","onUpdate:modelValue":y[0]||(y[0]=d=>c.value=d),class:"h-1 w-28 cursor-pointer appearance-none rounded-full bg-slate-300 focus:outline-none",style:{"accent-color":"#3b82f6"}},null,512),[[e.vModelText,c.value,void 0,{number:!0}]]),e.createElementVNode("span",null,e.toDisplayString(x.value),1)])]),e.createElementVNode("div",Rk,[e.createElementVNode("label",Ok,[e.createElementVNode("input",{type:"checkbox",class:"h-3.5 w-3.5 rounded border-slate-300 text-blue-600 focus:ring-blue-200",checked:t.showRasterExtent,onChange:y[1]||(y[1]=d=>l.$emit("toggle-extent",d.target.checked))},null,40,Uk),y[3]||(y[3]=e.createElementVNode("span",null,"Межі растру",-1))])])]))}}),On=e.defineComponent({__name:"ExtentOutlineLayer",props:{extent:{},layerId:{},beforeId:{},lineColor:{},lineWidth:{}},setup(t){const n=t,o=n.layerId||"extent-outline-layer",r=`${o}-source`,a=e.computed(()=>{const{extent:c}=n;if(!c||c.length!==4)return null;const[p,g,x,l]=c;return[p,g,x,l].some(y=>typeof y!="number"||Number.isNaN(y))?null:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[p,g],[x,g],[x,l],[p,l],[p,g]]]}}]}}),i=tt(),s=Ue(o,{sourceId:r,source:{type:"geojson",data:a.value||{type:"FeatureCollection",features:[]}},layer:{id:o,type:"line",paint:{"line-color":n.lineColor??"#ef4444","line-width":n.lineWidth??2}},beforeId:n.beforeId??null});return e.watch(()=>a.value,c=>{var g;if(!c){s.setVisible(!1),s.setData({type:"FeatureCollection",features:[]});return}s.setVisible(!0),s.setData(c);const p=(g=i.map)==null?void 0:g.value;p!=null&&p.moveLayer&&p.getLayer(o)&&p.moveLayer(o)},{immediate:!0}),(c,p)=>e.createCommentVNode("",!0)}}),Hk={class:"flex h-full bg-gradient-to-br from-slate-50 to-white"},Wk={class:"flex-1 relative overflow-hidden"},Yk={class:"absolute top-0 left-0 w-full z-20"},Zk={class:"px-4 sm:px-6 py-4 border-b border-gray-200 bg-white shadow-sm"},Gk={class:"flex items-start justify-between gap-4"},Kk={class:"flex-1 min-w-0"},Xk={class:"flex items-center text-sm text-gray-500 mb-3"},Qk={class:"text-gray-900 font-medium truncate max-w-xs"},Jk={class:"flex items-center justify-between gap-4"},ew={class:"flex-1 min-w-0"},tw={class:"flex items-center gap-3 mb-1"},nw={class:"text-base font-semibold text-gray-900 truncate"},ow=["title"],rw={class:"flex items-center gap-4 min-w-0"},lw={class:"flex-1 min-w-0"},aw=["title"],sw={class:"w-full h-full bg-gradient-to-br from-sky-50 via-white to-blue-50 flex items-center justify-center relative pt-[105px]"},iw={class:"relative w-full h-full"},cw={class:"absolute top-4 left-4 z-20"},dw={key:1,class:"absolute bottom-4 left-1/2 z-30 -translate-x-1/2 rounded-2xl border border-sky-200 bg-white/95 px-4 py-2 text-xs font-medium text-slate-700 shadow-lg backdrop-blur"},uw={class:"absolute top-[6.5rem] right-2 space-y-1 z-20"},pw={class:"flex-1 flex flex-col h-full"},mw={class:"px-3 pt-3 pb-2 border-b border-gray-100"},fw={class:"items-center justify-center text-muted-foreground grid w-full grid-cols-3 h-12 p-1 bg-gray-50 rounded-xl shadow-sm"},gw=["aria-selected","onClick"],yw={class:"leading-none"},hw={class:"flex flex-col flex-1 overflow-y-hidden p-3"},xw={key:0,class:"mb-3 text-xs text-slate-500"},bw={key:1,class:"mb-3 text-xs text-rose-600"},kw="OpenGIS",Vl=2,Un=5,ww=5,_w=Object.freeze(Object.defineProperty({__proto__:null,default:e.defineComponent({__name:"raster",setup(t){const n=[{cardClass:"bg-gradient-to-br from-green-50 to-green-100/30 border-green-200",titleClass:"text-green-900"},{cardClass:"bg-gradient-to-br from-blue-50 to-blue-100/30 border-blue-200",titleClass:"text-blue-900"},{cardClass:"bg-gradient-to-br from-purple-50 to-purple-100/30 border-purple-200",titleClass:"text-purple-900"},{cardClass:"bg-gradient-to-br from-gray-50 to-gray-100/30 border-gray-200",titleClass:"text-gray-900"}],o=Fe.useRouter(),r=Fe.useRoute(),a=e.ref(null),i=e.computed(()=>{var M;const B=(M=r.params)==null?void 0:M.id;return typeof B=="string"?B:void 0}),s=e.ref(null),c=e.ref(!1),p=e.ref(!1),g=e.ref(null),x=e.ref(!0),l=e.ref(!1),y=e.ref(null);let d=null,u=null;const b=e.ref(!1);let f=null,m=!1;function h(B){if(Array.isArray(B))return h(B[0]);if(typeof B!="string"&&typeof B!="number")return null;const M=typeof B=="number"?B:Number(B.trim());return Number.isFinite(M)?M:null}function k(B,M){return B.toFixed(M)}function N(B,M,X){const le=.5*10**-X;return Math.abs(B-M)>le}function $(){var B;return(B=a.value)==null?void 0:B.ctx}function E(){var O,H,ae,ge;const B=(H=(O=$())==null?void 0:O.map)==null?void 0:H.value;if(!B)return;const M=h(r.query.z),X=h(r.query.x),le=h(r.query.y);if(M==null||X==null||le==null)return;const de=(ae=B.getCenter)==null?void 0:ae.call(B),xe=(ge=B.getZoom)==null?void 0:ge.call(B);(!de||N(de.lng,X,Un)||N(de.lat,le,Un)||N(xe??0,M,Vl))&&(b.value=!0,B.jumpTo({center:[X,le],zoom:M}),b.value=!1)}function w(){var de,xe,P,O;if(b.value)return;const B=(xe=(de=$())==null?void 0:de.map)==null?void 0:xe.value;if(!B)return;const M=(P=B.getCenter)==null?void 0:P.call(B),X=(O=B.getZoom)==null?void 0:O.call(B);if(!M||X==null)return;const le={...r.query,z:k(X,Vl),x:k(M.lng,Un),y:k(M.lat,Un)};r.query.z===le.z&&r.query.x===le.x&&r.query.y===le.y||o.replace({query:le})}function S(){var M;if(typeof document>"u")return;const B=(M=te.value)==null?void 0:M.name;document.title=B?`${B} — Растер`:kw}function A(B){return Number(B.toFixed(ww))}function R(B,M){const[X,le]=B,[de,xe]=M;return[A(Math.min(X,de)),A(Math.min(le,xe)),A(Math.max(X,de)),A(Math.max(le,xe))]}function Z(B){const[M,X,le,de]=B;return{type:"Polygon",coordinates:[[[M,X],[le,X],[le,de],[M,de],[M,X]]]}}function I(B){var le,de,xe;const M=(de=(le=$())==null?void 0:le.map)==null?void 0:de.value,X=(xe=M==null?void 0:M.getCanvas)==null?void 0:xe.call(M);X!=null&&X.style&&(X.style.cursor=B)}async function K(B,M){if(!(!i.value||!s.value))try{const X=Z(B),le=await fetch(`/api/gis-metadata/raster/${encodeURIComponent(i.value)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({geom:X})});if(!le.ok)throw new Error(`Failed to save raster metadata geom: ${le.status}`);ye.notify({type:"success",title:"Extent збережено",message:"Нові межі успішно збережено."}),await Ke()}catch(X){console.error("Failed to save raster extent",X),s.value&&(s.value={...s.value,extent:M?[...M]:void 0}),ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти Extent"})}}function q(B){var X,le,de;const M=(le=(X=$())==null?void 0:X.map)==null?void 0:le.value;if((de=M==null?void 0:M.dragPan)!=null&&de.enable&&M.dragPan.enable(),(B==null?void 0:B.length)===4&&s.value){const xe=Array.isArray(s.value.extent)?[...s.value.extent]:null;s.value={...s.value,extent:[...B]},K(B,xe)}f=null,m=!1,y.value=null,l.value=!1,I("")}function ne(){q(null)}function Y(){var xe,P;const B=(P=(xe=$())==null?void 0:xe.map)==null?void 0:P.value;if(!B)return;const M=O=>{var ae,ge,Ne;if(!l.value||((ae=O==null?void 0:O.originalEvent)==null?void 0:ae.button)!=null&&O.originalEvent.button!==0)return;const H=O==null?void 0:O.lngLat;H&&(f=[H.lng,H.lat],m=!0,y.value=[H.lng,H.lat,H.lng,H.lat],(Ne=(ge=B.dragPan)==null?void 0:ge.disable)==null||Ne.call(ge))},X=O=>{if(!l.value||!m||!f)return;const H=O==null?void 0:O.lngLat;H&&(y.value=R(f,[H.lng,H.lat]))},le=O=>{if(!l.value||!m||!f)return;const H=O==null?void 0:O.lngLat;if(!H){ne();return}const ae=R(f,[H.lng,H.lat]),[ge,Ne,Le,Se]=ae;if(!(Math.abs(Le-ge)>0&&Math.abs(Se-Ne)>0)){ye.notify({type:"warning",title:"Bounds не змінено",message:"Потрібно протягнути прямокутник з ненульовою площею."}),ne();return}q(ae)},de=O=>{l.value&&O.key==="Escape"&&(O.preventDefault(),ne())};B.on("mousedown",M),B.on("mousemove",X),B.on("mouseup",le),window.addEventListener("keydown",de),u=()=>{B.off("mousedown",M),B.off("mousemove",X),B.off("mouseup",le),window.removeEventListener("keydown",de)}}async function D(){var X;if(l.value)return;const B=$();!(B!=null&&B.ready)||(await B.ready(),!((X=B.map)==null?void 0:X.value))||(u||Y(),l.value=!0,m=!1,f=null,y.value=null,I("crosshair"),ye.notify({type:"info",title:"Редагування Bounds",message:"Протягніть прямокутник на карті, щоб задати нові межі."}))}const v=e.computed(()=>{var M;const B=(M=s.value)==null?void 0:M.url;return B?/^https?:\/\//i.test(B)||typeof window>"u"||typeof location>"u"?B:`${location.origin}${B}`:""}),F=e.computed(()=>{var B;return((B=s.value)==null?void 0:B.extent)??null}),V=e.computed(()=>i.value?`raster-${i.value}`:void 0),_=e.computed(()=>i.value?`raster-extent-${i.value}`:"raster-extent"),T=e.computed(()=>i.value?`raster-extent-draft-${i.value}`:"raster-extent-draft"),z=e.computed(()=>{const B=V.value??"raster",M=F.value&&F.value.length===4?F.value.join(","):"no-extent";return`${B}-${M}`}),Q=e.computed(()=>!!v.value),se=e.computed(()=>{const B=F.value;if(!B||B.length!==4)return null;const[M,X,le,de]=B;return[M,X,le,de].some(xe=>typeof xe!="number"||Number.isNaN(xe))?null:[(M+le)/2,(X+de)/2]}),te=e.computed(()=>{var xe,P;const B=s.value,M=B==null?void 0:B.extent,le=i.value??"—",de=[B!=null&&B.extension?`Формат ${String(B.extension).toUpperCase()}`:null,(B==null?void 0:B.resolution)||null].filter(Boolean).join(", ");return{id:le,name:(B==null?void 0:B.name)||((P=(xe=B==null?void 0:B.files)==null?void 0:xe[0])==null?void 0:P.name),description:(B==null?void 0:B.description)||de||"Попередній перегляд растрового шару.",coverage:M&&M.length===4?`${W(M[0])}, ${W(M[1])} → ${W(M[2])}, ${W(M[3])}`:"Покриття уточнюється",crs:B!=null&&B.srid?`EPSG:${B.srid}`:"EPSG:4326",source:B!=null&&B.proj4?B.proj4:"Джерело: Mapnik",updatedAt:B!=null&&B.cache?"Дані кешовано":"Нові дані"}}),oe=e.computed(()=>{const B=s.value;return B?[B.source_path,B.srid?`SRID: ${B.srid}`:null,B.is_public?"Публічна":"Не публічна",B.is_active?"Активна":"Неактивна",B.cache?"Кешовано":null].filter(M=>M).join(", "):""}),fe=[{key:"info",label:"Інформація",icon:zk},{key:"files",label:"Файли",icon:Vn},{key:"metadata",label:"Метадані",icon:Bo}],he=fe.map(B=>B.key),ie=e.ref(he.includes(r.query.tab)?r.query.tab:"info"),Be=e.ref(!0);e.watch(()=>r.query.tab,B=>{B&&he.includes(B)&&ie.value!==B&&(ie.value=B)}),e.watch(ie,B=>{r.query.tab!==B&&o.replace({query:{...r.query,tab:B}})});const We=e.computed(()=>G(s.value)),qe=e.computed(()=>be(s.value));e.watch(()=>s.value,()=>{S()},{immediate:!0});async function Re(){var le;const B=$();if(!(B!=null&&B.ready))return;await B.ready(),E();const M=(le=B.map)==null?void 0:le.value;if(!M)return;const X=()=>w();M.on("moveend",X),M.on("zoomend",X),d=()=>{M.off("moveend",X),M.off("zoomend",X)}}e.watch(()=>[r.query.z,r.query.x,r.query.y],()=>{E()}),e.onMounted(()=>{Re()}),e.onBeforeUnmount(()=>{d==null||d(),d=null,u==null||u(),u=null,I("")}),e.watch(i,()=>{Ke()},{immediate:!0});async function Ge(B){var M;Ke(),((M=s.value)==null?void 0:M.srid)!==B.srid&&(ye.notify({title:"XML start",type:"info",message:"зміна системи координат, оновлюємо карту ..."}),await wt(`/api/gis-xml/${encodeURIComponent(i.value)}`),ye.notify({title:"XML created",type:"info",message:"карта створена"}),location.reload())}async function Ke(){const B=i.value;if(!B){s.value=null,g.value=null;return}c.value=!0,g.value=null;try{const M=await fetch(`/api/gis-raster/${encodeURIComponent(B)}`);if(!M.ok)throw new Error(`HTTP ${M.status}`);const X=await M.json();X.xml&&(p.value=!0),s.value=X,X.xml||(ye.notify({title:"XML not found",type:"info",message:"йде створення xml ... зачекайте"}),await wt(`/api/gis-xml/${encodeURIComponent(B)}`),ye.notify({title:"XML created",type:"info",message:"карта створена"}),fetch(`/api/gis-raster/${encodeURIComponent(B)}?nocache=1`),p.value=!0)}catch(M){console.error("Failed to load raster info",M),s.value=null,g.value=M instanceof Error?M.message:String(M)}finally{c.value=!1}}function wt(B){return new Promise((M,X)=>{const le=new EventSource(B),de=[];le.onmessage=xe=>{de.push(xe.data),console.log("Received:",xe.data)},le.addEventListener("end",()=>{le.close(),M(de)}),le.onerror=xe=>{le.close(),M(xe)}})}function G(B){var M;return(M=B==null?void 0:B.files)!=null&&M.length?B.files.map(X=>({name:X.name,resolution:ee(X.name,B),size:X.size||"—",status:"Готово",statusClass:"bg-emerald-50 text-emerald-600 border border-emerald-100"})):[]}function ee(B,M){const X=B.toLowerCase();return X.endsWith(".tfw")?"Georeference":X.endsWith(".xml")?"Опис":X.endsWith(".tif")||X.endsWith(".tiff")?M!=null&&M.resolution?M.resolution:"Растер":(M==null?void 0:M.resolution)??"Файл"}function be(B){return B?{baseParams:Te(B),spatial:{crs:{code:B.srid?`EPSG:${B.srid}`:"EPSG:4326",description:B.proj4||"WGS 84 — World Geodetic System 1984"},bounds:ke(B.extent),resolution:He(B)},statistics:ve(B),technical:lt(B)}:null}function Pe(B){return B!=null&&B.length?B.map(X=>{var de;if(!X)return"";const le=X.trim().split(/\s+/)[0];return((de=le==null?void 0:le[0])==null?void 0:de.toUpperCase())||""}).filter(Boolean).join(""):""}function Te(B){var xe,P;const M=B.bands_count??((xe=B.bands)==null?void 0:xe.length)??"—",X=Pe(B.bands),le=(B.bands??[]).map(O=>O.trim()).filter(O=>O.length>0),de=le.length?le.join(", "):void 0;return[{label:"Розмір растру, px",value:B.width&&B.height?`${B.width}×${B.height}`:"—"},{label:"Формат файлу",value:((P=B.extension)==null?void 0:P.toUpperCase())??"—"},{label:"Розмір файлу, mb",value:B.total_size?`${B.total_size}`:"—"},{label:"Кількість каналів",value:typeof M=="number"?`${M}${X?` (${X})`:""}`:`${M}${X?` (${X})`:""}`,tooltip:de},{label:"Глибина кольору",value:B.color_depth?`${B.color_depth} біт/канал`:"—"},{label:"Стиснення",value:B.compression||"—"}]}function ke(B){return!B||B.length!==4?[]:[{label:"Північ",value:W(B[3],"N")},{label:"Схід",value:W(B[2],"E")},{label:"Південь",value:W(B[1],"S")},{label:"Захід",value:W(B[0],"W")}]}function He(B){const M=[{label:"Роздільна здатність",value:B.resolution||"—"}];return B.width&&B.height&&M.push({label:"Розмір пікселя",value:`${B.width} × ${B.height} px`}),M}function ve(B){var M;return(M=B.bands)!=null&&M.length?B.bands.map((X,le)=>{const de=n[le%n.length];return{label:`Канал ${le+1}${X?` (${X})`:""}`,cardClass:de.cardClass,titleClass:de.titleClass,metrics:[{label:"Назва",value:X||`Канал ${le+1}`},{label:"Глибина",value:B.color_depth?`${B.color_depth} біт`:"—"},{label:"Статус",value:B.cache?"Кешовано":"Готово"}]}}):[]}function lt(B){var M;return[{label:"Тип даних",value:B.color_depth?`Unsigned Integer ${B.color_depth}-bit`:"—"},{label:"Компресія",value:B.compression||"—"},{label:"Кольорова інтерпретація",value:((M=B.bands)==null?void 0:M.join(", "))||"—"},{label:"SRID",value:B.srid?`EPSG:${B.srid}`:"—"},{label:"Проекція (proj4)",value:B.proj4||"—"},{label:"URL тайла",value:B.url||"—"}]}function W(B,M){if(B==null||Number.isNaN(B))return"—";const X=`${B.toFixed(5)}°`;return M?`${X} ${M}`:X}return(B,M)=>(e.openBlock(),e.createElementBlock("div",Hk,[e.createElementVNode("div",Wk,[e.createElementVNode("div",Yk,[e.createElementVNode("div",Zk,[e.createElementVNode("div",Gk,[e.createElementVNode("div",Kk,[e.createElementVNode("div",Xk,[e.createElementVNode("button",{type:"button",class:"hover:text-gray-700 cursor-pointer transition-colors",onClick:M[0]||(M[0]=X=>e.unref(o).push("/gis.rasters"))}," Растри "),M[3]||(M[3]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-chevron-right w-4 h-4 mx-1"},[e.createElementVNode("path",{d:"m9 18 6-6-6-6"})],-1)),e.createElementVNode("span",Qk,e.toDisplayString(te.value.name||"Растер"),1)]),e.createElementVNode("div",Jk,[e.createElementVNode("div",ew,[e.createElementVNode("div",tw,[e.createElementVNode("h1",nw,e.toDisplayString(te.value.name||"Растер"),1)]),oe.value?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-xs text-gray-500 truncate",title:oe.value},e.toDisplayString(oe.value),9,ow)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",rw,[e.createElementVNode("div",lw,[e.createElementVNode("div",{class:"w-full text-xs text-gray-600 truncate",title:te.value.description},e.toDisplayString(te.value.description),9,aw)]),e.createVNode(So,{"entity-id":i.value||"","entity-info":{name:te.value.name},table:"gis.rasters.table","entity-label":"Растер","save-method":"put","edit-button-text":"Редагувати",onSaved:Ge},null,8,["entity-id","entity-info"])])])])]),e.createElementVNode("div",sw,[e.createElementVNode("div",iw,[e.createVNode(Bn,{ref_key:"mapViewRef",ref:a},{default:e.withCtx(()=>[Q.value&&p.value?(e.openBlock(),e.createBlock(qk,{key:z.value,"tile-url":v.value,extent:F.value,"layer-id":V.value,"show-raster-extent":x.value,onToggleExtent:M[1]||(M[1]=X=>x.value=X)},null,8,["tile-url","extent","layer-id","show-raster-extent"])):e.createCommentVNode("",!0),e.createVNode(On,{extent:x.value?F.value:null,"layer-id":_.value},null,8,["extent","layer-id"]),e.createVNode(On,{extent:y.value,"layer-id":T.value,"line-color":"#0ea5e9","line-width":3},null,8,["extent","layer-id"]),e.createElementVNode("div",cw,[e.createVNode(Wt)]),l.value?(e.openBlock(),e.createElementBlock("div",dw," Потягніть на карті, щоб намалювати нові Bounds. Esc скасовує редагування. ")):e.createCommentVNode("",!0),e.createElementVNode("div",uw,[e.createVNode(It),se.value?(e.openBlock(),e.createBlock(It,{key:0,targetCenter:se.value,targetLabel:"Центр даних",targetAriaLabel:"Перейти до центру даних"},null,8,["targetCenter"])):e.createCommentVNode("",!0)])]),_:1},512)])]),e.createVNode(Vo,{open:Be.value,onToggle:M[2]||(M[2]=X=>Be.value=!Be.value)},null,8,["open"])]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white border-l border-gray-100 flex flex-col overflow-hidden shadow-lg flex-shrink-0 transition-[width] duration-100 ease-in-out",Be.value?"w-[650px]":"w-0"])},[e.createElementVNode("div",pw,[e.createElementVNode("div",mw,[e.createElementVNode("div",fw,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(fe,X=>e.createElementVNode("button",{key:X.key,type:"button",role:"tab","aria-selected":ie.value===X.key,class:e.normalizeClass(["whitespace-nowrap flex flex-col items-center justify-center gap-0.5 py-1 px-1 text-[9px] font-medium transition-all duration-300 hover:bg-white/70 rounded-lg group",ie.value===X.key?"bg-white shadow-sm text-gray-700":""]),onClick:le=>ie.value=X.key},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(X.icon),{class:"h-3.5 w-3.5 mb-0.5"})),e.createElementVNode("span",yw,e.toDisplayString(X.label),1)],10,gw)),64))])]),e.createElementVNode("div",hw,[c.value?(e.openBlock(),e.createElementBlock("div",xw," Завантаження метаданих растру… ")):g.value?(e.openBlock(),e.createElementBlock("div",bw," Не вдалося отримати дані: "+e.toDisplayString(g.value),1)):e.createCommentVNode("",!0),ie.value==="files"?(e.openBlock(),e.createBlock(Tk,{key:2,files:We.value},null,8,["files"])):ie.value==="metadata"?(e.openBlock(),e.createBlock($o,{key:3,data:s.value,"entity-id":i.value,"entity-type":"raster",onSaved:Ke,onEditCssBounds:D},null,8,["data","entity-id"])):qe.value?(e.openBlock(),e.createBlock(Sk,{key:4,details:qe.value},null,8,["details"])):e.createCommentVNode("",!0)])])],2)]))}})},Symbol.toStringTag,{value:"Module"})),Ew={},Cw={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-table"};function Nw(t,n){return e.openBlock(),e.createElementBlock("svg",Cw,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M12 3v18"},null,-1),e.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"},null,-1),e.createElementVNode("path",{d:"M3 9h18"},null,-1),e.createElementVNode("path",{d:"M3 15h18"},null,-1)])])}const Vw=Ce(Ew,[["render",Nw]]),Bw={class:"flex flex-col h-full"},$w={class:"flex justify-end mb-3 gap-2"},Sw=e.defineComponent({__name:"cartocss-css-tab",props:{modelValue:{}},emits:["update:modelValue","save"],setup(t,{emit:n}){const o=t,r=n,a=e.computed({get:()=>o.modelValue,set:i=>r("update:modelValue",i)});return(i,s)=>(e.openBlock(),e.createElementBlock("div",Bw,[e.createElementVNode("div",$w,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium bg-gradient-to-r from-sky-400 to-blue-400 hover:from-sky-500 hover:to-blue-500 text-white shadow-sm px-4 py-2 h-9 text-xs transition-all duration-300",onClick:s[0]||(s[0]=c=>i.$emit("save"))},[...s[2]||(s[2]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"h-3.5 w-3.5"},[e.createElementVNode("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a 2 2 0 0 1-2-2V5a 2 2 0 0 1 2-2z"}),e.createElementVNode("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a 1 1 0 0 0-1 1v7"}),e.createElementVNode("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})],-1),e.createTextVNode(" Зберегти ",-1)])])]),e.createVNode(kn,{modelValue:a.value,"onUpdate:modelValue":s[1]||(s[1]=c=>a.value=c),language:"cartocss",class:"flex-1 rounded-lg overflow-hidden"},null,8,["modelValue"])]))}}),vw={class:"flex flex-col flex-1 min-h-0"},Lw={class:"flex justify-between mb-3 gap-2"},Aw={class:"text-left"},Tw={class:"font-medium text-gray-900"},Mw={class:"text-xs text-gray-500"},Fw={class:"flex justify-center gap-2"},Dw=["checked","onChange"],zw={class:"text-sm font-medium text-gray-900"},Iw=e.defineComponent({__name:"cartocss-data-tab",props:{modelValue:{default:[]},modelModifiers:{}},emits:e.mergeModels(["save"],["update:modelValue"]),setup(t,{emit:n}){const o=[{key:"table",label:"Таблиця",slot:"datasetCell"},{key:"active",label:"Активний",slot:"activeCell",width:"140px"},{key:"zoom",label:"Min Зум",slot:"zoomCell",width:"140px"}],r=e.defineAsyncComponent(()=>import("@opengis/core").then(u=>u.VsModal)),a=e.defineAsyncComponent(()=>import("@opengis/form")),i=e.useModel(t,"modelValue"),s=n,c=e.ref(!1),p=e.ref({table:"",query:"",srid:"",key:"",columns:"",minzoom:"",maxzoom:"",proj4text:"",active:!0}),g={table:{type:"text",label:"Таблиця",validators:["required"]},key:{type:"text",label:"Ключ",validators:["required"]},query:{type:"text",label:"Query"},columns:{type:"text",label:"Колонки"},srid:{type:"number",label:"SRID"},proj4text:{type:"text",label:"PROJ4"},active:{type:"switcher",label:"Активна"},minzoom:{type:"number",label:"Min Зум",col:6},maxzoom:{type:"number",label:"Max Зум",col:6}};function x(){p.value={table:"",query:"",srid:"",key:"",columns:"",minzoom:"",maxzoom:"",proj4text:"",active:!0},c.value=!0}function l(){c.value=!1}function y(){var f,m;const u=(f=p.value.table)==null?void 0:f.trim(),b=(m=p.value.key)==null?void 0:m.trim();if(!u||!b){ye.notify({type:"warning",title:"Перевірка",message:"Вкажіть таблицю та підпис"});return}i.value=[...Array.isArray(i.value)?i.value:[],{...p.value,table:u,key:b}],c.value=!1}function d(u,b){var m;const f=((m=b==null?void 0:b.target)==null?void 0:m.checked)??!1;u.active=f,i.value=Array.isArray(i.value)?[...i.value]:[]}return(u,b)=>(e.openBlock(),e.createElementBlock("div",vw,[e.createElementVNode("div",Lw,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium bg-gradient-to-r from-gray-500 to-gray-400 text-white h-9 px-4 py-2 hover:from-gray-600 hover:to-gray-500",onClick:x}," Додати таблицю "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium bg-gradient-to-r from-sky-400 to-blue-400 hover:from-sky-500 hover:to-blue-500 text-white shadow-sm px-4 py-2 h-9 text-xs transition-all duration-300",onClick:b[0]||(b[0]=f=>s("save"))}," Зберегти ")]),e.createVNode(At,{modelValue:i.value,"onUpdate:modelValue":b[1]||(b[1]=f=>i.value=f),"columns-scheme":o,"form-scheme":g,"add-button":!1,"main-col-width":"260px"},{datasetCell:e.withCtx(({row:f})=>[e.createElementVNode("div",Aw,[e.createElementVNode("div",Tw,e.toDisplayString(f.table),1),e.createElementVNode("div",Mw,e.toDisplayString(f.key),1)])]),activeCell:e.withCtx(({row:f})=>[e.createElementVNode("label",Fw,[e.createElementVNode("input",{type:"checkbox",class:"h-4 w-4 text-sky-500 border-gray-300 rounded focus:ring-sky-300",checked:f.active,onChange:m=>d(f,m)},null,40,Dw)])]),zoomCell:e.withCtx(({row:f})=>[e.createElementVNode("div",zw,e.toDisplayString(f.zoom),1)]),_:1},8,["modelValue"]),e.createVNode(e.unref(r),{teleport:"#modal",visible:c.value,"onUpdate:visible":b[3]||(b[3]=f=>c.value=f),title:"Нова таблиця CartoCSS"},{footer:e.withCtx(()=>[e.createElementVNode("div",{class:"flex justify-end gap-2 p-4 border-т"},[e.createElementVNode("button",{type:"button",class:"px-4 py-2 rounded bg-gray-100 text-gray-700",onClick:l}," Скасувати "),e.createElementVNode("button",{type:"button",class:"px-4 py-2 rounded bg-blue-600 text-white",onClick:y}," Додати ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(a),{values:p.value,"onUpdate:values":b[2]||(b[2]=f=>p.value=f),schema:g},null,8,["values"])]),_:1},8,["visible"])]))}}),Pw={class:"flex flex-col flex-1 min-h-0 gap-4"},jw={class:"h-[calc(100vh-230px)] rounded-md border border-gray-200 bg-white"},Rw=e.defineComponent({__name:"cartocss-card-tab",props:{card:{},table:{}},emits:["save"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(o.table),i=e.ref(o.card),s=e.defineAsyncComponent(()=>import("@opengis/form").then(p=>p.VsInputText));function c(){r("save",{card_html:i.value,card_table:a.value})}return(p,g)=>(e.openBlock(),e.createElementBlock("div",Pw,[e.createElementVNode("div",{class:"flex items-center justify-end gap-3"},[e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium bg-gradient-to-r from-sky-400 to-blue-400 hover:from-sky-500 hover:to-blue-500 text-white shadow-sm px-4 py-2 h-9 text-xs transition-all duration-300",onClick:c},[...g[2]||(g[2]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"h-3.5 w-3.5"},[e.createElementVNode("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a 2 2 0 0 1-2-2V5a 2 2 0 0 1 2-2z"}),e.createElementVNode("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a 1 1 0 0 0-1 1v7"}),e.createElementVNode("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})],-1),e.createTextVNode(" Зберегти картку ",-1)])])]),e.createElementVNode("div",null,[e.createVNode(e.unref(s),{modelValue:a.value,"onUpdate:modelValue":g[0]||(g[0]=x=>a.value=x)},null,8,["modelValue"])]),e.createElementVNode("div",jw,[e.createVNode(kn,{modelValue:i.value,"onUpdate:modelValue":g[1]||(g[1]=x=>i.value=x),language:"html",theme:"vs-light",class:"h-full w-full rounded-md"},null,8,["modelValue"])])]))}}),Ow=e.defineComponent({__name:"CartocssLayerLoader",props:{layerId:{type:String,required:!0},tileUrl:{type:String,default:""},title:{type:String,default:""},active:{type:Boolean,default:!1},owner:{type:String,default:""},opacity:{type:Number,default:1}},setup(t){const n=t,o=tt(),{activateTemporaryLayer:r,deactivateTemporaryLayer:a,setTemporaryLayerOpacity:i}=lo(o.map),s=e.computed(()=>{var l;const x=`${(l=n==null?void 0:n.tileUrl)==null?void 0:l.trim()}`;return x?typeof window>"u"||typeof location>"u"||/^https?:\/\//i.test(x)?x:x.startsWith("//")?`${window.location.protocol}${x}`:x.startsWith("/")?`${location.origin}${x}`:`${location.origin}/${x}`:""});let c="",p="";function g(){const x=n.active&&!!s.value;c&&(!x||c!==n.layerId)&&(a(c,p||void 0),c="",p=""),x&&(r({id:n.layerId,title:n.title||n.layerId,url:s.value,opacity:n.opacity},{},n.owner),c=n.layerId,p=n.owner||"")}return e.watch(()=>[n.layerId,s.value,n.active,n.owner],g,{immediate:!0}),e.watch(()=>n.opacity,x=>{!c||!n.active||i(c,x,p||void 0)},{immediate:!0}),e.onUnmounted(()=>{c&&(a(c,p||void 0),c="",p="")}),(x,l)=>e.createCommentVNode("",!0)}}),Uw=e.defineComponent({__name:"CartocssMapClickListener",props:{cartocssId:{},infoEnabled:{type:[Boolean,null]}},setup(t){const n=t,o=e.computed(()=>n.cartocssId??null),r=e.computed(()=>!!n.infoEnabled),{map:a,ready:i}=tt(),s=d=>{!d||typeof window>"u"||window.dispatchEvent(new CustomEvent(so,{detail:d}))},c=async d=>{const u=await fetch(`/api/map-format?${d.toString()}`);if(!u.ok)throw new Error(`API returned ${u.status}`);return u.json()};let p=null,g=null;const x=d=>{if(!d)return null;if(typeof d=="string")try{return JSON.parse(d)}catch{return null}return d},l=async(d,u)=>{var m;const b=o.value?`external:${o.value},${String(d)}`:null,f=new URLSearchParams({layer:o.value??"",id:String(d)});try{const h=await c(f),k=typeof h.html=="string"?h.html:null,N=x(((m=h==null?void 0:h.data)==null?void 0:m.geom)??(h==null?void 0:h.geom)??null);(k||N)&&s({html:k,geometry:N??u,infoToken:b})}catch(h){console.warn("CartoCSS map-format (id) error",h)}},y=async d=>{var m,h,k,N;if(!o.value)return;if(!r.value){ye.notify({type:"error",title:"CartoCSS",message:"Картка не налаштована"});return}const u=(m=d==null?void 0:d.lngLat)==null?void 0:m.lng,b=(h=d==null?void 0:d.lngLat)==null?void 0:h.lat;if(typeof u!="number"||typeof b!="number")return;const f=new URLSearchParams({layer:o.value,lat:b.toFixed(6),lng:u.toFixed(6)});try{const $=await c(f),E=x(((k=$==null?void 0:$.data)==null?void 0:k.geom)??($==null?void 0:$.geom)??null),w=((N=$==null?void 0:$.data)==null?void 0:N.id)??($==null?void 0:$.id);if(w!=null){await l(w,E);return}Ko({html:$==null?void 0:$.html})&&s({html:$==null?void 0:$.html,geometry:E,infoToken:null})}catch($){console.warn("CartoCSS map-format error",$)}};return i().then(()=>{g=a.value,g&&(g.on("click",y),p=()=>g==null?void 0:g.off("click",y))}),e.onBeforeUnmount(()=>{p==null||p(),p=null,g=null}),()=>{}}}),qw={class:"flex h-full bg-gradient-to-br from-slate-50 to-white"},Hw={class:"flex-1 relative overflow-hidden"},Ww={class:"absolute top-0 left-0 w-full z-20"},Yw={class:"px-4 sm:px-6 py-4 border-b border-gray-200 bg-white shadow-sm"},Zw={class:"flex items-start justify-between gap-4"},Gw={class:"flex-1 min-w-0"},Kw={class:"flex items-center text-sm text-gray-500 mb-3"},Xw={class:"text-gray-900 font-medium truncate max-w-xs"},Qw={class:"flex items-center justify-between gap-4"},Jw={class:"flex-1 min-w-0"},e2={class:"flex items-center gap-3 mb-1"},t2={class:"text-base font-semibold text-gray-900 truncate"},n2={key:0,class:"px-2 py-0.5 bg-green-50 border border-green-200 rounded flex-shrink-0"},o2={class:"text-xs font-medium text-green-700"},r2=["title"],l2={class:"w-full h-full bg-gradient-to-br from-sky-50 via-white to-blue-50 flex items-center justify-center relative pt-[115px]"},a2={class:"relative w-full h-full"},s2={class:"absolute top-[5.5rem] left-4 z-30 flex flex-col items-start gap-2"},i2={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},c2={class:"flex items-center gap-2"},d2={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},u2={class:"inline-flex items-center gap-2 text-[11px] text-slate-600"},p2=["checked"],m2={class:"absolute top-4 left-4 z-20"},f2={class:"absolute top-[6.5rem] right-2 space-y-1 z-20"},g2={key:0,class:"absolute bottom-4 left-1/2 z-30 -translate-x-1/2 rounded-2xl border border-sky-200 bg-white/95 px-4 py-2 text-xs font-medium text-slate-700 shadow-lg backdrop-blur"},y2={class:"flex-1 flex flex-col h-full"},h2={key:0,class:"px-3 pt-3 pb-2 border-b border-gray-100"},x2=["aria-selected","onClick"],b2={class:"leading-none"},k2={class:"flex flex-col flex-1 overflow-y-hidden p-3"},w2={key:0,class:"flex-1 flex items-center justify-center text-sm text-gray-500"},_2="cartocss-demo-001",E2="OpenGIS",Bl=2,qn=5,C2=5,N2=Object.freeze(Object.defineProperty({__proto__:null,default:e.defineComponent({__name:"cartocss",setup(t){const n=Fe.useRouter(),o=Fe.useRoute(),r=e.ref(null),a=[{key:"css",label:"CSS",icon:kl},{key:"data",label:"Дані",icon:Vw},{key:"metadata",label:"Метадані",icon:Bo},{key:"card",label:"Картка",icon:wl}],i=a.map(W=>W.key),s=e.ref(i.includes(o.query.tab)?o.query.tab:"css"),c=e.ref(!0),p=e.ref(null),g=e.computed(()=>{var W;return(W=p.value)!=null&&W.source_path?a.filter(B=>B.key==="card"||B.key==="metadata"):a}),x=e.computed(()=>o.params.id||_2),l=e.ref({id:x.value,name:"",description:""});let y=null;const d=e.ref(!1);function u(W){if(Array.isArray(W))return u(W[0]);if(typeof W!="string"&&typeof W!="number")return null;const B=typeof W=="number"?W:Number(W.trim());return Number.isFinite(B)?B:null}function b(W,B){return W.toFixed(B)}function f(W,B,M){const X=.5*10**-M;return Math.abs(W-B)>X}function m(){var W;return(W=r.value)==null?void 0:W.ctx}function h(){var P,O,H,ae;const W=(O=(P=m())==null?void 0:P.map)==null?void 0:O.value;if(!W)return;const B=u(o.query.z),M=u(o.query.x),X=u(o.query.y);if(B==null||M==null||X==null)return;const le=(H=W.getCenter)==null?void 0:H.call(W),de=(ae=W.getZoom)==null?void 0:ae.call(W);(!le||f(le.lng,M,qn)||f(le.lat,X,qn)||f(de??0,B,Bl))&&(d.value=!0,W.jumpTo({center:[M,X],zoom:B}),d.value=!1)}function k(){var le,de,xe,P;if(d.value)return;const W=(de=(le=m())==null?void 0:le.map)==null?void 0:de.value;if(!W)return;const B=(xe=W.getCenter)==null?void 0:xe.call(W),M=(P=W.getZoom)==null?void 0:P.call(W);if(!B||M==null)return;const X={...o.query,z:b(M,Bl),x:b(B.lng,qn),y:b(B.lat,qn)};o.query.z===X.z&&o.query.x===X.x&&o.query.y===X.y||n.replace({query:X})}function N(W){typeof document>"u"||(document.title=W?`${W} — CartoCSS`:E2)}const $=e.ref(""),E=e.ref([]),w=e.ref(!1),S=e.ref(!1),A=e.ref(""),R=e.ref(0),Z=e.ref(!1),I=e.ref(1),K=e.ref(!0),q=e.ref(!1),ne=e.ref(null),Y=e.computed(()=>`cartocss-layer-${x.value}`),D=e.computed(()=>`${Math.round(I.value*100)}%`),v=e.computed(()=>`cartocss-extent-${x.value}`),F=e.computed(()=>`cartocss-extent-draft-${x.value}`),V=e.computed(()=>{var le;const W=(le=A.value)==null?void 0:le.trim();if(!W)return"";const B=W.includes("?")?"&":"?",M=`${W}${B}nottl=1`,X=R.value;return X?`${W}${B}ts=${X}&nocache=1`:M}),_=e.ref(""),T=e.ref(""),z=e.computed(()=>{var de;const W=(de=p.value)==null?void 0:de.bounds;if(!Array.isArray(W)||W.length<4)return null;const[B,M,X,le]=W;return[B,M,X,le].some(xe=>typeof xe!="number"||Number.isNaN(xe))?null:[(B+X)/2,(M+le)/2]}),Q=e.computed(()=>{var de;const W=(de=p.value)==null?void 0:de.bounds;if(!Array.isArray(W)||W.length<4)return null;const[B,M,X,le]=W;return[B,M,X,le].some(xe=>typeof xe!="number"||Number.isNaN(xe))?null:[B,M,X,le]}),se=e.computed(()=>{const W=p.value;return W?[W.description,W.group_id?`Група: ${W.group_id}`:null,W.source_path?`Шлях: ${W.source_path}`:null,W.is_public===!0?"Публічний":"Не публічний",W.enabled===!0?"Активний":"Неактивний"].filter(Boolean).join(", "):""}),te=e.computed(()=>{var B;const W=(B=p.value)==null?void 0:B.group_id;return W?String(W).toUpperCase():""});let oe=null,fe=!1,he=null;function ie(W){return Number(W.toFixed(C2))}function Be(W,B){const[M,X]=W,[le,de]=B;return[ie(Math.min(M,le)),ie(Math.min(X,de)),ie(Math.max(M,le)),ie(Math.max(X,de))]}function We(W){const[B,M,X,le]=W;return{type:"Polygon",coordinates:[[[B,M],[X,M],[X,le],[B,le],[B,M]]]}}function qe(W){var X,le,de;const B=(le=(X=m())==null?void 0:X.map)==null?void 0:le.value,M=(de=B==null?void 0:B.getCanvas)==null?void 0:de.call(B);M!=null&&M.style&&(M.style.cursor=W)}async function Re(W,B){if(!(!x.value||!p.value)){S.value=!0;try{const M=We(W),X=await fetch(`/api/gis-css/${x.value}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({geom:M})});if(!X.ok)throw new Error(`Failed to save cartocss bounds: ${X.status}`);ye.notify({type:"success",title:"Bounds збережено",message:"Нові межі успішно збережено."}),await He(x.value,{bustCache:!0})}catch(M){console.error("Failed to save CartoCSS bounds",M),p.value&&(p.value={...p.value,bounds:B?[...B]:null}),ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти Bounds"})}finally{S.value=!1}}}function Ge(W){var M,X,le;const B=(X=(M=m())==null?void 0:M.map)==null?void 0:X.value;if((le=B==null?void 0:B.dragPan)!=null&&le.enable&&B.dragPan.enable(),(W==null?void 0:W.length)===4&&p.value){const de=Array.isArray(p.value.bounds)?[...p.value.bounds]:null;p.value={...p.value,bounds:[...W]},Re(W,de)}oe=null,fe=!1,ne.value=null,q.value=!1,qe("")}function Ke(){Ge(null)}function wt(){var de,xe;const W=(xe=(de=m())==null?void 0:de.map)==null?void 0:xe.value;if(!W)return;const B=P=>{var H,ae,ge;if(!q.value||((H=P==null?void 0:P.originalEvent)==null?void 0:H.button)!=null&&P.originalEvent.button!==0)return;const O=P==null?void 0:P.lngLat;O&&(oe=[O.lng,O.lat],fe=!0,ne.value=[O.lng,O.lat,O.lng,O.lat],(ge=(ae=W.dragPan)==null?void 0:ae.disable)==null||ge.call(ae))},M=P=>{if(!q.value||!fe||!oe)return;const O=P==null?void 0:P.lngLat;O&&(ne.value=Be(oe,[O.lng,O.lat]))},X=P=>{if(!q.value||!fe||!oe)return;const O=P==null?void 0:P.lngLat;if(!O){Ke();return}const H=Be(oe,[O.lng,O.lat]),[ae,ge,Ne,Le]=H;if(!(Math.abs(Ne-ae)>0&&Math.abs(Le-ge)>0)){ye.notify({type:"warning",title:"Bounds не змінено",message:"Потрібно протягнути прямокутник з ненульовою площею."}),Ke();return}Ge(H)},le=P=>{q.value&&P.key==="Escape"&&(P.preventDefault(),Ke())};W.on("mousedown",B),W.on("mousemove",M),W.on("mouseup",X),window.addEventListener("keydown",le),he=()=>{W.off("mousedown",B),W.off("mousemove",M),W.off("mouseup",X),window.removeEventListener("keydown",le)}}async function G(){var M;const W=m();!(W!=null&&W.ready)||(await W.ready(),!((M=W.map)==null?void 0:M.value))||(he||wt(),q.value=!0,fe=!1,oe=null,ne.value=null,qe("crosshair"),ye.notify({type:"info",title:"Редагування Bounds",message:"Протягніть прямокутник на карті, щоб задати нові межі."}))}e.watch(x,W=>{W&&He(W)},{immediate:!0}),e.watch(()=>{var W;return(W=l.value)==null?void 0:W.name},W=>N(W),{immediate:!0});async function ee(){var X;const W=m();if(!(W!=null&&W.ready))return;await W.ready(),h();const B=(X=W.map)==null?void 0:X.value;if(!B)return;const M=()=>k();B.on("moveend",M),B.on("zoomend",M),y=()=>{B.off("moveend",M),B.off("zoomend",M)}}e.watch(()=>[o.query.z,o.query.x,o.query.y],()=>{h()}),e.onMounted(()=>{ee()}),e.onBeforeUnmount(()=>{y==null||y(),y=null,he==null||he(),he=null,qe("")}),e.watch(()=>o.query.tab,W=>{W&&g.value.some(B=>B.key===W)&&s.value!==W&&(s.value=W)}),e.watch(g,W=>{W.length&&!W.some(B=>B.key===s.value)&&(s.value=W[0].key)},{immediate:!0}),e.watch(s,W=>{o.query.tab!==W&&g.value.some(B=>B.key===W)&&n.replace({query:{...o.query,tab:W}})}),e.watch(()=>p.value,W=>{const B=W==null?void 0:W.card_html;_.value=B,T.value=W==null?void 0:W.card_table},{immediate:!0});function be(){x.value&&He(x.value,{bustCache:!0})}async function Pe(W,B){if(x.value){S.value=!0;try{const M=await fetch(`/api/gis-css/${x.value}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)});if(!M.ok)throw new Error(`Failed to save cartocss: ${M.status}`);ye.notify({type:"success",title:"Збережено",message:B}),await He(x.value,{bustCache:!0})}catch(M){console.error("Failed to save CartoCSS",M),ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти CartoCSS"})}finally{S.value=!1}}}function Te(W){if(!W)return null;if(typeof W=="string")try{return JSON.parse(W)}catch(B){return console.warn("Failed to parse CartoCSS config",B),null}return typeof W=="object"?W:null}function ke(W){const B=Array.isArray(W)?W:W==null?void 0:W.datasets;return Array.isArray(B)?B.map((M,X)=>({table:(M==null?void 0:M.table)||(M==null?void 0:M.id)||`dataset_${X+1}`,query:(M==null?void 0:M.query)||"",srid:(M==null?void 0:M.srid)||"",key:(M==null?void 0:M.key)||(M==null?void 0:M.label)||"Без підпису",active:typeof(M==null?void 0:M.active)=="boolean"?M.active:!0,minzoom:typeof(M==null?void 0:M.zoom)>"u"?"":String(M.zoom),maxzoom:typeof(M==null?void 0:M.maxzoom)>"u"?"":String(M.maxzoom),columns:(M==null?void 0:M.columns)||"",proj4text:(M==null?void 0:M.proj4text)||""})):[]}async function He(W,B){w.value=!0;try{const M=await fetch(`/api/gis-css/${W}`);if(!M.ok)throw new Error(`Failed to load cartocss: ${M.status}`);const X=await M.json(),le=(X==null?void 0:X.message)||X||{};p.value=le,l.value={id:le.cartocss_key||W,name:le.name||l.value.name,description:le.description||l.value.description},$.value=typeof le.style=="string"?le.style:"";const de=Te(le.config??[]);E.value=ke(de);const xe=typeof le.url=="string"?le.url:"";A.value=xe,Z.value=!!(xe&&le.enabled!==!1),R.value=B!=null&&B.bustCache?Date.now():0}catch(M){console.error("Failed to fetch CartoCSS",M),Z.value=!1,A.value="",R.value=0,p.value=null}finally{w.value=!1}}async function ve(){await Pe({style:$.value||"",config:E.value},"CartoCSS оновлено")}async function lt(W){const B=await fetch(`/api/gis-css/${x.value}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)});if(!B.ok)throw new Error(`Failed to save cartocss: ${B.status}`);ye.notify({type:"success",title:"Збережено",message:"Картка CartoCSS оновлена"})}return(W,B)=>(e.openBlock(),e.createElementBlock("div",qw,[e.createElementVNode("div",Hw,[e.createElementVNode("div",Ww,[e.createElementVNode("div",Yw,[e.createElementVNode("div",Zw,[e.createElementVNode("div",Gw,[e.createElementVNode("div",Kw,[e.createElementVNode("button",{type:"button",class:"hover:text-gray-700 cursor-pointer transition-colors",onClick:B[0]||(B[0]=M=>e.unref(n).push("/gis.cartocss"))}," CartoCSS "),B[6]||(B[6]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-chevron-right w-4 h-4 mx-1"},[e.createElementVNode("path",{d:"m9 18 6-6-6-6"})],-1)),e.createElementVNode("span",Xw,e.toDisplayString(l.value.name||"CartoCSS"),1)]),e.createElementVNode("div",Qw,[e.createElementVNode("div",Jw,[e.createElementVNode("div",e2,[e.createElementVNode("h1",t2,e.toDisplayString(l.value.name||"CartoCSS"),1),te.value?(e.openBlock(),e.createElementBlock("div",n2,[e.createElementVNode("span",o2,e.toDisplayString(te.value),1)])):e.createCommentVNode("",!0)]),se.value?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-xs text-gray-500 truncate",title:se.value},e.toDisplayString(se.value),9,r2)):e.createCommentVNode("",!0)])])]),e.createVNode(So,{class:"flex-shrink-0","entity-id":x.value,"entity-info":l.value,"form-endpoint":M=>`/api/form/gis.cartocss.table/${M}`,"save-endpoint":M=>`/api/gis-css/${M}`,"entity-label":"CartoCSS","save-method":"post",onSaved:be},null,8,["entity-id","entity-info","form-endpoint","save-endpoint"])])])]),e.createElementVNode("div",l2,[e.createElementVNode("div",a2,[e.createVNode(Bn,{ref_key:"mapViewRef",ref:r},{default:e.withCtx(()=>{var M,X;return[e.createElementVNode("div",s2,[e.createElementVNode("div",i2,[e.createElementVNode("div",c2,[B[7]||(B[7]=e.createElementVNode("span",null,"Прозорість:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[1]||(B[1]=le=>I.value=le),type:"range",min:"0",max:"1",step:"0.01",class:"h-1 w-28 cursor-pointer appearance-none rounded-full bg-slate-300 focus:outline-none",style:{"accent-color":"#3b82f6"}},null,512),[[e.vModelText,I.value,void 0,{number:!0}]]),e.createElementVNode("span",null,e.toDisplayString(D.value),1)])]),e.createElementVNode("div",d2,[e.createElementVNode("label",u2,[e.createElementVNode("input",{type:"checkbox",class:"h-3.5 w-3.5 rounded border-slate-300 text-blue-600 focus:ring-blue-200",checked:K.value,onChange:B[2]||(B[2]=le=>K.value=le.target.checked)},null,40,p2),B[8]||(B[8]=e.createElementVNode("span",null,"Межі css",-1))])])]),e.createElementVNode("div",m2,[e.createVNode(Wt)]),e.createElementVNode("div",f2,[e.createVNode(It),z.value?(e.openBlock(),e.createBlock(It,{key:0,targetCenter:z.value,targetLabel:"Центр даних",targetAriaLabel:"Перейти до центру даних"},null,8,["targetCenter"])):e.createCommentVNode("",!0)]),q.value?(e.openBlock(),e.createElementBlock("div",g2," Потягніть на карті, щоб намалювати нові Bounds. Esc скасовує редагування. ")):e.createCommentVNode("",!0),V.value?(e.openBlock(),e.createBlock(Ow,{key:1,"layer-id":Y.value,"tile-url":V.value,active:Z.value,opacity:I.value,title:l.value.name,owner:x.value},null,8,["layer-id","tile-url","active","opacity","title","owner"])):e.createCommentVNode("",!0),e.createVNode(On,{extent:K.value?Q.value:null,"layer-id":v.value},null,8,["extent","layer-id"]),e.createVNode(On,{extent:ne.value,"layer-id":F.value,"line-color":"#0ea5e9","line-width":3},null,8,["extent","layer-id"]),e.createVNode(Uw,{"cartocss-id":x.value,bounds:((M=p.value)==null?void 0:M.bounds)??null,active:Z.value&&!q.value,"info-enabled":(X=p.value)==null?void 0:X.info},null,8,["cartocss-id","bounds","active","info-enabled"]),e.createVNode(io,{"map-id":x.value},null,8,["map-id"])]}),_:1},512)])]),p.value?(e.openBlock(),e.createBlock(Vo,{key:0,open:c.value,onToggle:B[3]||(B[3]=M=>c.value=!c.value)},null,8,["open"])):e.createCommentVNode("",!0)]),p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["bg-white border-l border-gray-100 flex flex-col overflow-hidden shadow-lg flex-shrink-0 transition-[width] duration-100 ease-in-out",c.value?"w-[650px]":"w-0"])},[e.createElementVNode("div",y2,[g.value.length>1?(e.openBlock(),e.createElementBlock("div",h2,[e.createElementVNode("div",{class:"items-center justify-center text-muted-foreground grid w-full h-12 p-1 bg-gray-50 rounded-xl shadow-sm",style:e.normalizeStyle({gridTemplateColumns:`repeat(${g.value.length}, minmax(0, 1fr))`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,M=>(e.openBlock(),e.createElementBlock("button",{key:M.key,type:"button",role:"tab","aria-selected":s.value===M.key,class:e.normalizeClass(["whitespace-nowrap flex flex-col items-center justify-center gap-0.5 py-1 px-1 text-[9px] font-medium transition-all duration-300 hover:bg-white/70 rounded-lg group",s.value===M.key?"bg-white shadow-sm text-gray-700":""]),onClick:X=>s.value=M.key},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(M.icon),{class:"h-3.5 w-3.5 mb-0.5"})),e.createElementVNode("span",b2,e.toDisplayString(M.label),1)],10,x2))),128))],4)])):e.createCommentVNode("",!0),e.createElementVNode("div",k2,[w.value?(e.openBlock(),e.createElementBlock("div",w2," Завантаження стилю… ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[s.value==="css"?(e.openBlock(),e.createBlock(Sw,{key:0,modelValue:$.value,"onUpdate:modelValue":B[4]||(B[4]=M=>$.value=M),class:"flex-1 min-h-0",onSave:ve},null,8,["modelValue"])):s.value==="data"?(e.openBlock(),e.createBlock(Iw,{key:1,modelValue:E.value,"onUpdate:modelValue":B[5]||(B[5]=M=>E.value=M),class:"flex-1 min-h-0 flex flex-col",onSave:ve},null,8,["modelValue"])):s.value==="card"?(e.openBlock(),e.createBlock(Rw,{key:2,card:_.value,table:T.value,class:"flex-1 min-h-0",onSave:lt},null,8,["card","table"])):s.value==="metadata"?(e.openBlock(),e.createBlock($o,{key:3,data:p.value,"entity-id":x.value,"entity-type":"css",onSaved:be,onEditCssBounds:G},null,8,["data","entity-id"])):e.createCommentVNode("",!0)],64))])])],2)):e.createCommentVNode("",!0)]))}})},Symbol.toStringTag,{value:"Module"})),V2={class:"rounded-lg border border-gray-200 bg-[rgba(252,252,252,0.8)] p-6"},B2=e.defineComponent({__name:"GeneralSettings",props:{schema:{},modelValue:{},loading:{type:Boolean},form:{}},emits:["update:modelValue","update:form"],setup(t,{emit:n}){const o=e.defineAsyncComponent(()=>import("@opengis/form")),r=t,a=n,i=e.computed({get:()=>r.modelValue,set:c=>a("update:modelValue",c)}),s=e.computed({get:()=>r.form,set:c=>a("update:form",c)});return(c,p)=>(e.openBlock(),e.createElementBlock("section",V2,[p[2]||(p[2]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-800 mb-4"}," Основна інформація ",-1)),t.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(o),{key:0,schema:t.schema,values:i.value,"onUpdate:values":p[0]||(p[0]=g=>i.value=g),form:s.value,"onUpdate:form":p[1]||(p[1]=g=>s.value=g)},null,8,["schema","values","form"]))]))}}),$2={class:"rounded-lg border border-gray-200 bg-[rgba(252,252,252,0.8)] p-6"},S2=e.defineComponent({__name:"LayerSettings",props:{layerIDs:{},options:{}},emits:["update:layerIDs"],setup(t,{emit:n}){const o=t,r=n,a=e.computed({get:()=>o.layerIDs,set:i=>r("update:layerIDs",i)});return(i,s)=>(e.openBlock(),e.createElementBlock("section",$2,[s[1]||(s[1]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-800 mb-4"},"Шари",-1)),s[2]||(s[2]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Доступні шари",-1)),e.createVNode(e.unref(Do.VsInputArraySelect),{data:"layer_list",api:"/api/suggest/layer_list",modelValue:a.value,"onUpdate:modelValue":s[0]||(s[0]=c=>a.value=c),placeholder:"Шари"},null,8,["modelValue"])]))}}),v2={class:"w-full"},L2=e.defineComponent({__name:"MapPreview",props:{id:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",v2,[e.createVNode(Tn,{class:"w-full h-[calc(100vh-200px)]",height:"h-[calc(100vh-200px)]",id:t.id},null,8,["id"])]))}}),A2={class:"bg-white rounded-lg shadow-xl w-full max-w-4xl flex flex-col h-[80vh] m-4"},T2={class:"flex items-center justify-between px-6 py-4 border-b border-gray-200"},M2={key:0,class:"absolute top-0 left-0 right-0 bg-red-100 text-red-700 text-sm px-4 py-2 z-10 border-b border-red-200"},F2={class:"flex-1 overflow-hidden relative bg-[#fffffe]"},D2={class:"px-6 py-4 border-t border-gray-200 flex justify-end gap-3"},z2=["disabled"],I2=e.defineComponent({__name:"ConfigEditor",props:{modelValue:{}},emits:["update:modelValue","save"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(""),i=e.ref(null);e.watch(()=>o.modelValue,p=>{if(p){try{a.value=JSON.stringify(p,null,2)}catch{a.value="{}"}i.value=null}},{immediate:!0}),e.watch(a,p=>{if(!p.trim()){i.value=null;return}try{JSON.parse(p),i.value=null}catch(g){i.value=g.message}}),e.watch(()=>o.modelValue,()=>{setTimeout(()=>{const{monaco:p}=window;if(p&&p.editor){const g=p.editor.getEditors();g.length>0&&g[g.length-1].updateOptions({wordWrap:"on"})}},300)},{immediate:!0});function s(){r("update:modelValue",null),a.value="",i.value=null}function c(){if(!i.value)try{const p=JSON.parse(a.value);r("save",p),s()}catch(p){console.error("Failed to parse JSON",p)}}return(p,g)=>t.modelValue!==null?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e.withModifiers(s,["self"])},[e.createElementVNode("div",A2,[e.createElementVNode("div",T2,[g[1]||(g[1]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-800"}," Редагування конфігурації (JSON) ",-1)),e.createElementVNode("button",{onClick:s,class:"text-gray-500 hover:text-gray-700 transition-colors"},[e.createVNode(e.unref(ce.X),{size:20})])]),i.value?(e.openBlock(),e.createElementBlock("div",M2," Помилка JSON: "+e.toDisplayString(i.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",F2,[e.createVNode(kn,{modelValue:a.value,"onUpdate:modelValue":g[0]||(g[0]=x=>a.value=x),language:"json",theme:"vs-light",class:"w-full h-full"},null,8,["modelValue"])]),e.createElementVNode("div",D2,[e.createElementVNode("button",{onClick:s,class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors"}," Скасувати "),e.createElementVNode("button",{onClick:c,disabled:!!i.value,class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"}," Зберегти ",8,z2)])])])):e.createCommentVNode("",!0)}}),P2={key:0,class:"text-center py-8 text-gray-500 border rounded-lg bg-[rgba(252,252,252,0.8)]"},j2={key:1,class:"rounded-lg border border-gray-200 overflow-hidden"},R2={class:"w-full text-sm"},O2={class:"divide-y divide-gray-200"},U2={class:"px-4 py-3"},q2=["onUpdate:modelValue","onChange"],H2=["value"],W2={class:"px-4 py-3"},Y2=["onUpdate:modelValue","onChange"],Z2=["value"],G2={class:"px-4 py-3 text-center"},K2=["checked","onChange"],X2={class:"px-4 py-3"},Q2={key:0,class:"flex items-center gap-2"},J2=["onClick"],e_=["onClick"],t_={key:1},n_=["onClick"],o_={class:"px-4 py-3 text-right"},r_=["onClick"],l_=e.defineComponent({__name:"WidgetSettings",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:n}){const o=t,r=n,a=["catalog","legend","basemaps","info","layers","dataset","filters","search"],i=["top-left","top-right","bottom-left","bottom-right"],s=e.ref(null),c=e.ref(-1),p=e.computed(()=>o.modelValue||[]);function g(){const m=[...p.value,{type:"info",position:"top-left",visible:!0,config:{}}];r("update:modelValue",m)}function x(m){ye.confirm({title:"Видалити віджет?",message:"Ви впевнені, що хочете видалити цей віджет?",type:"warning",onConfirm:()=>{const h=p.value.filter((k,N)=>N!==m);r("update:modelValue",h)}})}function l(m,h,k){const N=[...p.value];N[m]={...N[m],[h]:k},r("update:modelValue",N)}function y(m){return!!m&&Object.keys(m).length>0}function d(m,h){c.value=m,s.value=h||{}}function u(m){d(m,{})}function b(m){ye.confirm({title:"Видалити конфігурацію?",message:"Ви впевнені, що хочете видалити конфігурацію цього віджета?",type:"warning",onConfirm:()=>{l(m,"config",void 0)}})}function f(m){c.value>-1&&l(c.value,"config",m),s.value=null,c.value=-1}return(m,h)=>{var k;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",{class:"flex items-center justify-between mb-4"},[h[1]||(h[1]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-800"},"Віджети",-1)),e.createElementVNode("button",{onClick:g,class:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"}," + Додати віджет ")]),(k=p.value)!=null&&k.length?(e.openBlock(),e.createElementBlock("div",j2,[e.createElementVNode("table",R2,[h[2]||(h[2]=e.createElementVNode("thead",{class:"bg-[rgba(252,252,252,0.8)] border-b border-gray-200"},[e.createElementVNode("tr",null,[e.createElementVNode("th",{class:"px-4 py-3 text-left font-medium text-gray-700 w-1/4"},"Тип"),e.createElementVNode("th",{class:"px-4 py-3 text-left font-medium text-gray-700 w-1/4"},"Розташування"),e.createElementVNode("th",{class:"px-4 py-3 text-center font-medium text-gray-700 w-24"},"Видимість"),e.createElementVNode("th",{class:"px-4 py-3 text-left font-medium text-gray-700"},"Конфігурація"),e.createElementVNode("th",{class:"px-4 py-3 text-right font-medium text-gray-700 w-24"},"Дії")])],-1)),e.createElementVNode("tbody",O2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(N,$)=>(e.openBlock(),e.createElementBlock("tr",{key:$,class:"hover:bg-gray-50"},[e.createElementVNode("td",U2,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E=>N.type=E,onChange:E=>l($,"type",N.type),class:"w-full px-2 py-1.5 bg-white border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 text-gray-700"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,E=>e.createElementVNode("option",{key:E,value:E},e.toDisplayString(E),9,H2)),64))],40,q2),[[e.vModelSelect,N.type]])]),e.createElementVNode("td",W2,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E=>N.position=E,onChange:E=>l($,"position",N.position),class:"w-full px-2 py-1.5 bg-white border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 text-gray-700"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(i,E=>e.createElementVNode("option",{key:E,value:E},e.toDisplayString(E),9,Z2)),64))],40,Y2),[[e.vModelSelect,N.position]])]),e.createElementVNode("td",G2,[e.createElementVNode("input",{type:"checkbox",checked:N.visible!==!1,onChange:E=>l($,"visible",E.target.checked),class:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"},null,40,K2)]),e.createElementVNode("td",X2,[y(N.config)?(e.openBlock(),e.createElementBlock("div",Q2,[e.createElementVNode("button",{onClick:E=>d($,N.config),class:"p-1 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded transition-colors",title:"Редагувати конфігурацію"},[e.createVNode(e.unref(ce.Pen),{size:16})],8,J2),e.createElementVNode("button",{onClick:E=>b($),class:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded transition-colors",title:"Видалити конфігурацію"},[e.createVNode(e.unref(ce.X),{size:16})],8,e_)])):(e.openBlock(),e.createElementBlock("div",t_,[e.createElementVNode("button",{onClick:E=>u($),class:"p-1 text-green-600 hover:text-green-800 hover:bg-green-50 rounded transition-colors",title:"Додати конфігурацію"},[e.createVNode(e.unref(ce.Plus),{size:16})],8,n_)]))]),e.createElementVNode("td",o_,[e.createElementVNode("button",{onClick:E=>x($),class:"p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Видалити віджет"},[e.createVNode(e.unref(ce.Trash2),{size:16})],8,r_)])]))),128))])])])):(e.openBlock(),e.createElementBlock("div",P2," Немає віджетів. Додайте перший віджет. ")),e.createVNode(I2,{teleport:"#modal",modelValue:s.value,"onUpdate:modelValue":h[0]||(h[0]=N=>s.value=N),onSave:f},null,8,["modelValue"])])}}}),a_={class:"relative h-full flex flex-col flex-1 min-h-0 overflow-hidden mx-auto w-full"},s_={class:"mx-1"},i_={class:"text-gray-900 font-semibold"},c_=["disabled"],d_={key:0,class:"text-center py-12 mt-6 px-[24px]"},u_={key:1,class:"px-[24px] overflow-y-auto"},p_={class:"space-y-6"},m_={class:"space-y-6"},f_={class:"space-y-6"},g_=Object.freeze(Object.defineProperty({__proto__:null,default:Ce(e.defineComponent({__name:"MapSettings",setup(t){const n=Fe.useRouter(),o=Fe.useRoute(),r=e.computed(()=>{var E;return((E=n.resolve("/gis.maps").meta)==null?void 0:E.title)??"Карти"}),a=e.ref(!0),i=e.ref(!1),s=e.ref({}),c=e.ref({}),p=[{name:"Загальна",id:"general"},{name:"Шари",id:"layers"},{name:"Віджети",id:"widgets"},{name:"Карта",id:"map"}],g=p.map(E=>E.id),x=E=>E?Array.isArray(E)?E[0]:E:null,l=(()=>{const E=x(o.query.tab);return E&&g.includes(E)?E:"general"})(),y=e.ref(l);e.watch(()=>o.query.tab,E=>{const w=x(E);w&&g.includes(w)&&y.value!==w&&(y.value=w)}),e.watch(y,E=>{o.query.tab!==E&&n.replace({query:{...o.query,tab:E}})});const d=e.ref({name:"",map_key:"",description:"",holder:"",image:"",keywords:[],center:null,zoom:11,widgets:[],layers:[]}),u=e.computed({get:()=>(d.value.layers||[]).map(E=>E.id||E),set:E=>{d.value.layers=E}});async function b(E){if(!E.length){c.value={};return}try{const w=new URLSearchParams({json:"1",val:Array.from(new Set(E)).join(",")}),S=await fetch(`/api/suggest/layer_list?${w.toString()}`);if(!S.ok)return;const A=await S.json(),R=(A==null?void 0:A.data)??A??[],Z=Array.isArray(R)?R:[],I={...c.value};Z.forEach(K=>{const q=K.id!=null?String(K.id):"";q&&(I[q]=K.text??K.name??q)}),c.value=I}catch(w){console.error("Failed to fetch layer labels:",w)}}const f=e.computed({get:()=>u.value.map(E=>c.value[E]??E),set:E=>{const w=Object.entries(c.value).reduce((A,[R,Z])=>(A[Z]=R,A),{}),S=E.map(A=>w[A]??null).filter(A=>A!=null);u.value=S}}),m=e.computed(()=>{const E=d.value.center;if(!Array.isArray(E)||E.length<2)return"Не задано";const[w,S]=E;return w===void 0||S===void 0||w===null||S===null||Number.isNaN(Number(w))||Number.isNaN(Number(S))?"Не задано":`Lng ${Number(w).toFixed(6)}, Lat ${Number(S).toFixed(6)}`}),h=e.computed(()=>{const E=d.value.zoom;if(E==null||E==="")return"Не задано";const w=Number(E);return Number.isNaN(w)?"Не задано":w.toFixed(2)}),k=[{name:"name",type:"text",label:"Назва",col:6,validators:["required"]},{name:"map_key",type:"text",label:"Унікальний ключ",col:6,validators:["required"]},{name:"description",type:"textarea",label:"Опис",col:12},{name:"holder",type:"text",label:"Власник/Утримувач/Відповідальний",col:6},{name:"keywords",type:"Tags",label:"Ключові слова",placeholder:"Введіть тег та натисніть Enter",col:6},{name:"center",type:"array",label:"Центр",inputType:"number",limit:2,count:2,col:6},{name:"zoom",type:"number",label:"Зум",col:6,validators:["required"]},{name:"is_public",type:"switcher",label:"Чи публічна карта?",col:6,data:"yes_no"},{name:"is_active",type:"switcher",label:"Чи активна?",col:6,data:"yes_no"},{name:"image",type:"File",label:"Фото",col:12}];async function N(){try{const w=await(await fetch(`/api/gis-map/${o.params.id}?original=1`)).json();d.value={...w,keywords:w.keywords||[],center:w.center??null,widgets:Array.isArray(w.widgets)?w.widgets:[],layers:(w.layers||[]).map(S=>S.id||S)},await b(d.value.layers??[])}catch(E){console.error("Failed to load map:",E),ye.notify({type:"error",title:"Помилка",message:"Не вдалося завантажити карту"})}finally{a.value=!1}}async function $(){var w,S;const E=(S=(w=s.value)==null?void 0:w.validate)==null?void 0:S.call(w);if(E){ye.notify({type:"warning",title:"Валідація",message:Object.entries(E).map(([A,R])=>`${A}: ${R}`).join(`
43
+ ${N}`:N}c.value=!1,p.value=[]}function d(){c.value=!1,p.value=[]}function u(){const f=i.value==="html"?"html":"list",m={card_mode:f};f==="html"?m.html=s.value:f==="list"&&(m.list=a.value),r("save","card",m)}const b=[{value:"all",label:"Всі"},{value:"list",label:"Список"},{value:"none",label:"Жодне"},{value:"html",label:"HTML"}];return(f,m)=>(e.openBlock(),e.createElementBlock("div",p1,[e.createElementVNode("div",{class:"flex justify-between mb-3 gap-2"},[e.createElementVNode("button",{onClick:l,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Імпорт "),e.createElementVNode("button",{onClick:u,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Зберегти ")]),e.createVNode(u1,{modelValue:i.value,"onUpdate:modelValue":m[0]||(m[0]=h=>i.value=h),options:b},null,8,["modelValue"]),e.createElementVNode("div",m1,[i.value==="list"?(e.openBlock(),e.createBlock(At,{key:0,modelValue:a.value,"onUpdate:modelValue":m[1]||(m[1]=h=>a.value=h),"columns-scheme":g,"form-scheme":x,"main-col-width":"250px","add-button":!1},null,8,["modelValue"])):i.value==="html"?(e.openBlock(),e.createBlock(kn,{key:1,modelValue:s.value,"onUpdate:modelValue":m[2]||(m[2]=h=>s.value=h),language:"html",theme:"vs-light",class:"flex-1 min-h-0"},null,8,["modelValue"])):e.createCommentVNode("",!0)]),e.createVNode(Zt,{visible:c.value,"onUpdate:visible":m[3]||(m[3]=h=>c.value=h),selection:p.value,"onUpdate:selection":m[4]||(m[4]=h=>p.value=h),fields:t.fields,title:"Імпорт полів для картки","id-prefix":"import-card",onConfirm:y,onCancel:d},null,8,["visible","selection","fields"])]))}}),g1={class:"flex flex-col flex-1 min-h-0"},y1=e.defineComponent({__name:"vs-tab-filter",props:{fields:{},columns:{}},emits:["update:columns","save"],setup(t,{emit:n}){const o=t,r=n;console.log(o.columns);const a=e.ref(o.columns||[]);e.watch(()=>o.columns,u=>a.value=u||[],{immediate:!0}),e.watch(a,u=>r("update:columns",u),{deep:!0,immediate:!0});const i=e.ref("list"),s=e.ref(!1),c=e.ref([]),p=[{key:"id",label:"Name"},{key:"label",label:"UA"}],g={name:{type:"text",label:"Name",disabled:!0,validators:["required"]},label:{type:"text",label:"UA",validators:["required"]},type:{type:"radio",label:"Тип",position:"horizontal",validators:["required"],options:[{text:"Check",id:"check"},{text:"Range",id:"range"},{text:"Date",id:"date"},{text:"Text",id:"text"},{text:"Select",id:"autocomplete"}]},hidden:{label:"Приховати",type:"Switcher"},data:{type:"text",label:"Класифікатор",conditions:["type","in",["autocomplete","select","check"]],validators:["required"]}};function x(){c.value=a.value.map(u=>u.name||u.id),s.value=!0}function l(){var m;const u=[...a.value],b=((m=o.fields)==null?void 0:m.filter(h=>c.value.includes(h.name)))||[],f=Kt(u,b,{selectedKeys:c.value,resolveKey:h=>Tt(h)});a.value=f,s.value=!1,c.value=[]}function y(){s.value=!1,c.value=[]}function d(){let u=[];i.value==="all"?u=o.fields||[]:i.value==="none"?u=[]:u=a.value,r("save",u)}return(u,b)=>(e.openBlock(),e.createElementBlock("div",g1,[e.createElementVNode("div",{class:"flex justify-between mb-3 gap-2"},[e.createElementVNode("button",{onClick:x,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Імпорт "),e.createElementVNode("button",{onClick:d,class:"inline-flex items-center justify-center gap-1 px-3 py-1.5 rounded-md bg-sky-100 hover:bg-sky-200 text-sky-700 font-medium text-sm transition disabled:opacity-70 disabled:cursor-not-allowed"}," Зберегти фільтр ")]),i.value==="list"?(e.openBlock(),e.createBlock(At,{key:0,modelValue:a.value,"onUpdate:modelValue":b[0]||(b[0]=f=>a.value=f),"columns-scheme":p,"form-scheme":g,"main-col-width":"250px","add-button":!1},null,8,["modelValue"])):e.createCommentVNode("",!0),e.createVNode(Zt,{visible:s.value,"onUpdate:visible":b[1]||(b[1]=f=>s.value=f),selection:c.value,"onUpdate:selection":b[2]||(b[2]=f=>c.value=f),fields:t.fields,title:"Імпорт полів","id-prefix":"import-filter",onConfirm:l,onCancel:y},null,8,["visible","selection","fields"])]))}}),h1=e.defineComponent({__name:"MapDataLayer",props:{id:{},layer:{},styleSpec:{},autoCenter:{type:[Boolean,null]}},setup(t,{expose:n}){var u,b,f,m;const{map:o,flyTo:r,setZoom:a}=tt(),i=((b=(u=e.getCurrentInstance())==null?void 0:u.appContext.config.globalProperties)==null?void 0:b.$settings)||null,s=t,c=s.id;String(s.id);const p=`${location.origin}/api/vtile/${s.id}/ua/{z}/{x}/{y}.vmt?all=1`,g=Ue(c,{source:{type:"vector",tiles:[p],minzoom:0,maxzoom:14},popup:s.layer.popup,layer:{style:(f=s.layer)==null?void 0:f.style}});n({layerHandle:g}),(s.autoCenter??!0)&&r({center:s.layer.center||((m=i==null?void 0:i.map)==null?void 0:m.center)||[30,50],animate:!1});let x=null;function l(){if(!(g!=null&&g.setTiles))return;const h=p.includes("?")?"&":"?",k=`${p}${h}_=${Date.now()}`;g.setTiles([k])}function y(){x&&clearTimeout(x),x=setTimeout(()=>{x=null,d().catch(h=>console.error("Failed to update map layer",h))},300)}async function d(){o.value&&(l(),g.setStyle(s.styleSpec??null))}return e.watch(()=>s.styleSpec,y,{deep:!0}),e.onBeforeUnmount(()=>{g.remove()}),(h,k)=>null}}),x1={class:"flex h-full bg-gradient-to-br from-slate-50 to-white"},b1={class:"flex-1 relative overflow-hidden"},k1={class:"absolute top-0 left-0 w-full z-20"},w1={class:"px-4 sm:px-6 py-4 border-b border-gray-200 bg-white shadow-sm"},_1={class:"flex items-start justify-between gap-4"},E1={class:"flex-1 min-w-0"},C1={class:"flex items-center text-sm text-gray-500 mb-3"},N1={class:"text-gray-900 font-medium truncate max-w-xs"},V1={class:"flex items-center justify-between gap-4"},B1={class:"flex-1 min-w-0"},$1={class:"flex items-center gap-3 mb-1"},S1={class:"text-base font-semibold text-gray-900 truncate"},v1={key:0,class:"px-2 py-0.5 bg-green-50 border border-green-200 rounded flex-shrink-0"},L1={class:"text-xs font-medium text-green-700"},A1=["title"],T1={class:"w-full h-full bg-gradient-to-br from-sky-50 via-white to-blue-50 flex items-center justify-center relative pt-[115px]"},M1={class:"relative w-full h-full"},F1={style:{top:"17px",left:"230px",position:"absolute","z-index":"1"}},D1={class:"absolute top-4 left-4 z-20"},z1={class:"absolute top-[6.5rem] right-2 space-y-1 z-20"},I1={class:"absolute bottom-4 left-4 z-20"},P1={class:"flex-1 flex flex-col h-full"},j1={class:"px-3 pt-3 pb-2 border-b border-gray-100"},R1={class:"items-center justify-center text-muted-foreground grid w-full grid-cols-6 h-12 p-1 bg-gray-50 rounded-xl shadow-sm"},O1=["aria-selected","onClick"],U1={class:"leading-none"},q1={class:"flex flex-col flex-1 overflow-y-hidden p-3"},H1="OpenGIS",Nl=2,Rn=5,W1=1e3,Y1=Object.freeze(Object.defineProperty({__proto__:null,default:Ce(e.defineComponent({__name:"service",props:{hideServiceKey:{type:Boolean,default:!1}},setup(t){var Ke,wt;const n=t,o=e.toRef(n,"hideServiceKey"),r=Fe.useRoute(),a=Fe.useRouter(),{id:i}=r.params,s=e.ref(null),c=e.ref(null),p=e.ref({}),g=e.ref(null),x=((wt=(Ke=e.getCurrentInstance())==null?void 0:Ke.appContext.config.globalProperties)==null?void 0:wt.$settings)||null;function l(G){typeof document>"u"||(document.title=G?`${G} — Сервіс`:H1)}let y=null;const d=e.ref(!1);function u(){var G;return(G=s.value)==null?void 0:G.ctx}function b(G){typeof window>"u"||window.dispatchEvent(new CustomEvent(vn,{detail:G}))}function f(G){var Te,ke,He;const ee=(ke=(Te=u())==null?void 0:Te.map)==null?void 0:ke.value;if(!ee||!G)return[];const be=(He=g.value)!=null&&He.service_id?String(g.value.service_id):null;return(ee.queryRenderedFeatures(G)||[]).filter(ve=>{var X,le,de,xe,P,O;const lt=((X=ve==null?void 0:ve.properties)==null?void 0:X.id)??(ve==null?void 0:ve.id);if(lt==null||!(ve!=null&&ve.source)||be&&String(ve.source)!==be)return!1;const W=Ue(ve.source)||Ue((le=ve.layer)==null?void 0:le.id);if(!W)return!1;const B=(xe=(de=W==null?void 0:W.opts)==null?void 0:de.source)==null?void 0:xe.type,M=(O=(P=W==null?void 0:W.opts)==null?void 0:P.layer)==null?void 0:O.type;return B!=="raster"&&M!=="raster"})}function m(G){const ee=f(G==null?void 0:G.point);b({features:ee,externalItems:[]})}function h(G){if(Array.isArray(G))return h(G[0]);if(typeof G!="string"&&typeof G!="number")return null;const ee=typeof G=="number"?G:Number(G.trim());return Number.isFinite(ee)?ee:null}function k(G,ee){return G.toFixed(ee)}function N(G,ee,be){const Pe=.5*10**-be;return Math.abs(G-ee)>Pe}function $(){var ve,lt,W,B;const G=(lt=(ve=u())==null?void 0:ve.map)==null?void 0:lt.value;if(!G)return;const ee=h(r.query.z),be=h(r.query.x),Pe=h(r.query.y);if(ee==null||be==null||Pe==null)return;const Te=(W=G.getCenter)==null?void 0:W.call(G),ke=(B=G.getZoom)==null?void 0:B.call(G);(!Te||N(Te.lng,be,Rn)||N(Te.lat,Pe,Rn)||N(ke??0,ee,Nl))&&(d.value=!0,G.jumpTo({center:[be,Pe],zoom:ee}),d.value=!1)}function E(){var Te,ke,He,ve;if(d.value)return;const G=(ke=(Te=u())==null?void 0:Te.map)==null?void 0:ke.value;if(!G)return;const ee=(He=G.getCenter)==null?void 0:He.call(G),be=(ve=G.getZoom)==null?void 0:ve.call(G);if(!ee||be==null)return;const Pe={...r.query,z:k(be,Nl),x:k(ee.lng,Rn),y:k(ee.lat,Rn)};r.query.z===Pe.z&&r.query.x===Pe.x&&r.query.y===Pe.y||a.replace({query:Pe})}const w=e.ref(null),S=e.ref(""),A=e.ref([]),R=e.ref([]),Z=e.ref([]),I=e.ref("list"),K=e.ref(""),q=e.ref([]),ne=e.ref(!0);let Y=null;const D=e.computed(()=>{var G,ee;return((G=g.value)==null?void 0:G.id)??((ee=g.value)==null?void 0:ee.service_id)??null}),v=e.computed(()=>{const G=(x==null?void 0:x.map)||null,ee=(G==null?void 0:G.boundary)??null,be=(G==null?void 0:G.katottg)??null;return!ee&&!be?null:{boundary:ee,katottg:be}}),F=e.computed(()=>{const G=g.value;if(!G)return"";const ee=[];!o.value&&G.service_key&&ee.push(`Сервіс: ${G.service_key}`),G.description&&ee.push(G.description);const be=G.group_name||G.group_id;return be&&ee.push(`Група: ${be}`),typeof G.is_public<"u"&&ee.push(G.is_public?"Публічний":"Не публічний"),typeof G.is_active<"u"&&ee.push(G.is_active?"Активний":"Неактивний"),ee.join(", ")}),V=e.computed(()=>{const G=g.value,ee=(G==null?void 0:G.group_name)||(G==null?void 0:G.group_id);return ee?String(ee).toUpperCase():""}),_=[{key:"style",label:"Стиль",icon:kl},{key:"popup",label:"Попап",icon:lb},{key:"filter",label:"Фільтр",icon:cb},{key:"legend",label:"Легенда",icon:Qx},{key:"card",label:"Картка",icon:wl},{key:"metadata",label:"Метадані",icon:Bo}],T=_.map(G=>G.key),z=e.ref("style");e.onMounted(async()=>{const G=r.query.tab;G&&T.includes(G)&&(z.value=G),await ie(),Q()});async function Q(){var Pe;const G=u();if(!(G!=null&&G.ready))return;await G.ready(),$();const ee=(Pe=G.map)==null?void 0:Pe.value;if(!ee)return;const be=()=>E();ee.on("moveend",be),ee.on("zoomend",be),ee.on("click",m),y=()=>{ee.off("moveend",be),ee.off("zoomend",be),ee.off("click",m)}}e.watch(()=>[r.query.z,r.query.x,r.query.y],()=>{$()}),e.watch(z,G=>{r.query.tab!==G&&a.replace({query:{...r.query,tab:G}})}),e.watch(()=>r.query.tab,G=>{G&&T.includes(G)&&z.value!==G&&(z.value=G)}),e.watch(()=>{var G;return(G=g.value)==null?void 0:G.name},G=>l(G),{immediate:!0});function se(G){if(!G)return null;try{return JSON.parse(JSON.stringify(G))}catch(ee){return console.warn("Failed to clone style",ee),null}}function te(G){if(!G)return null;if(typeof G=="string")try{return Jn(bl.load(G)||null)}catch(ee){return console.warn("Failed to parse style yaml",ee),null}return Jn(se(G))}function oe(G,ee){try{return JSON.stringify(G)===JSON.stringify(ee)}catch{return!1}}function fe(){var ee;if(!g.value)return;const G=te(w.value);oe(G,((ee=g.value)==null?void 0:ee.style)??null)||(g.value={...g.value,style:G})}function he(){Y&&clearTimeout(Y),Y=setTimeout(()=>{Y=null,fe()},W1)}const ie=async()=>{try{const G=await fetch(`/api/gis-service/${i}`);if(!G.ok)throw new Error(`${G.status}`);const ee=await G.json();p.value=ee||{},c.value=i;const be=te(ee.style);g.value=ee?{...ee,style:se(be)}:null,w.value=be,S.value=typeof(ee==null?void 0:ee.style)=="string"?ee.style:be?bl.dump(be):"",R.value=(ee==null?void 0:ee.popup)||[],I.value=ee.card_mode==="html"?"html":"list",Z.value=ee.card,K.value=ee.html,A.value=(ee==null?void 0:ee.legend)||[],q.value=(ee==null?void 0:ee.filters)||[]}catch(G){console.error("Failed to fetch map info",G)}};e.watch(()=>{var G;return(G=g.value)==null?void 0:G.style},G=>{w.value=te(G)},{deep:!0}),e.watch(()=>w.value,()=>{he()},{deep:!0}),e.onBeforeUnmount(()=>{Y&&(clearTimeout(Y),Y=null),y==null||y(),y=null});async function Be(G){try{const ee=await fetch(`/api/gis-clear-vtile/${G}`),{message:be,error:Pe,code:Te}=await ee.json();if(Te===200)return ye.notify({type:"success",title:"Успіх",message:be});ye.notify({type:"error",title:"Помилка",message:Pe})}catch(ee){ye.notify({type:"error",title:"Помилка",message:"Не вдалося очистити тайли"}),console.error(ee)}}async function We(G,ee){await Re({[G]:ee},G)}function qe(){const G=se(w.value);g.value=g.value?{...g.value,style:G}:g.value}async function Re(G,ee){if(g.value={...g.value||{},...G},typeof G.html<"u"&&(p.value={...p.value||{},html:G.html}),!!D.value)try{if(!(await fetch(`/api/gis-service/${D.value}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)})).ok)throw new Error("Save failed");ye.notify({type:"success",title:"Успіх",message:`${ee} saved`}),await ie()}catch(be){ye.notify({type:"error",title:"Помилка",message:`Failed to save ${ee}`}),console.error(be)}}async function Ge(G,ee){if(G!=="card"){await We(G,ee);return}const be=(ee==null?void 0:ee.card_mode)==="html"?"html":"list",Pe=be==="html"&&typeof(ee==null?void 0:ee.html)=="string"?ee.html:"",Te=(be==="html"?[]:null)||(Array.isArray(ee==null?void 0:ee.list)?ee.list:[]);Z.value=Te,I.value=be,K.value=Pe;const ke={card_mode:be};be==="html"&&(ke.html=Pe),be==="list"&&(ke.card=Te),await Re(ke,"card")}return(G,ee)=>{var be,Pe,Te;return e.openBlock(),e.createElementBlock("div",x1,[e.createElementVNode("div",b1,[e.createElementVNode("div",k1,[e.createElementVNode("div",w1,[e.createElementVNode("div",_1,[e.createElementVNode("div",E1,[e.createElementVNode("div",C1,[e.createElementVNode("button",{type:"button",class:"hover:text-gray-700 cursor-pointer transition-colors",onClick:ee[0]||(ee[0]=ke=>e.unref(a).push("/gis.datasets"))}," Datasets "),ee[11]||(ee[11]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-chevron-right w-4 h-4 mx-1"},[e.createElementVNode("path",{d:"m9 18 6-6-6-6"})],-1)),e.createElementVNode("span",N1,e.toDisplayString(((be=g.value)==null?void 0:be.name)||"Dataset"),1)]),e.createElementVNode("div",V1,[e.createElementVNode("div",B1,[e.createElementVNode("div",$1,[e.createElementVNode("h1",S1,e.toDisplayString(((Pe=g.value)==null?void 0:Pe.name)||"Dataset"),1),V.value?(e.openBlock(),e.createElementBlock("div",v1,[e.createElementVNode("span",L1,e.toDisplayString(V.value),1)])):e.createCommentVNode("",!0)]),F.value?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-xs text-gray-500 truncate",title:F.value},e.toDisplayString(F.value),9,A1)):e.createCommentVNode("",!0)])])]),D.value?(e.openBlock(),e.createBlock(So,{key:0,class:"flex-shrink-0","entity-id":D.value,"entity-info":{name:(Te=g.value)==null?void 0:Te.name},table:"gis.services.table","entity-label":"Сервіс","save-method":"put","show-xml-item":!1,"clear-tiles-handler":Be,onSaved:ie},null,8,["entity-id","entity-info"])):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",T1,[e.createElementVNode("div",M1,[e.createVNode(Bn,{ref_key:"mapViewRef",ref:s},{default:e.withCtx(()=>{var ke,He,ve,lt,W,B,M;return[(ke=g.value)!=null&&ke.service_id?(e.openBlock(),e.createBlock(h1,{key:0,id:(He=g.value)==null?void 0:He.service_id,layer:g.value,"style-spec":((ve=g.value)==null?void 0:ve.style)||null,autoCenter:!1},null,8,["id","layer","style-spec"])):e.createCommentVNode("",!0),D.value?(e.openBlock(),e.createBlock(or,{key:1,"layer-id":D.value,boundary:((lt=g.value)==null?void 0:lt.boundary)||((W=v.value)==null?void 0:W.boundary)||null,katottg:((B=g.value)==null?void 0:B.katottg)||((M=v.value)==null?void 0:M.katottg)||null},null,8,["layer-id","boundary","katottg"])):e.createCommentVNode("",!0),e.createElementVNode("div",F1,[D.value?(e.openBlock(),e.createBlock(uo,{key:0,"layer-id":D.value,filters:q.value},null,8,["layer-id","filters"])):e.createCommentVNode("",!0)]),ee[12]||(ee[12]=e.createElementVNode("div",{id:"map-filter-popover-host",class:"map-widget__filter-host"},null,-1)),e.createElementVNode("div",D1,[e.createVNode(Wt)]),e.createElementVNode("div",z1,[e.createVNode(It),p.value.center?(e.openBlock(),e.createBlock(It,{key:0,targetCenter:p.value.center,targetLabel:"Ценр даних"},null,8,["targetCenter"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",I1,[e.createVNode(co,{items:A.value||null},null,8,["items"])]),e.createVNode(Zo),e.createVNode(io,{html:p.value.html},null,8,["html"])]}),_:1},512)])]),e.createVNode(Vo,{open:ne.value,onToggle:ee[1]||(ee[1]=ke=>ne.value=!ne.value),"top-class":"top-4"},null,8,["open"])]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white border-l border-gray-100 flex flex-col overflow-hidden shadow-lg flex-shrink-0 transition-[width] duration-100 ease-in-out",ne.value?"w-[650px]":"w-0"])},[e.createElementVNode("div",P1,[e.createElementVNode("div",j1,[e.createElementVNode("div",R1,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(_,ke=>e.createElementVNode("button",{key:ke.key,type:"button",role:"tab","aria-selected":z.value===ke.key,class:e.normalizeClass(["whitespace-nowrap flex flex-col items-center justify-center gap-0.5 py-1 px-1 text-[9px] font-medium transition-all duration-300 hover:bg-white/70 rounded-lg group",z.value===ke.key?"bg-white shadow-sm text-gray-700":""]),onClick:He=>z.value=ke.key},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(ke.icon),{class:"h-3.5 w-3.5 mb-0.5"})),e.createElementVNode("span",U1,e.toDisplayString(ke.label),1)],10,O1)),64))])]),e.createElementVNode("div",q1,[z.value==="style"?(e.openBlock(),e.createBlock(Gb,{key:0,token:D.value,"style-text":S.value,"style-yaml":w.value,"onUpdate:styleYaml":ee[2]||(ee[2]=ke=>w.value=ke),"onUpdate:styleText":ee[3]||(ee[3]=ke=>S.value=ke),onUpdate:qe},null,8,["token","style-text","style-yaml"])):z.value==="legend"?(e.openBlock(),e.createBlock(a1,{key:1,token:D.value,columns:A.value,"onUpdate:columns":ee[4]||(ee[4]=ke=>A.value=ke),onSave:ee[5]||(ee[5]=ke=>We("legend",ke))},null,8,["token","columns"])):z.value==="popup"?(e.openBlock(),e.createBlock(Qb,{key:2,token:D.value,columns:R.value,fields:p.value.fields,"onUpdate:columns":ee[6]||(ee[6]=ke=>R.value=ke),onSave:ee[7]||(ee[7]=ke=>We("popup",ke))},null,8,["token","columns","fields"])):z.value==="card"?(e.openBlock(),e.createBlock(f1,{key:3,token:D.value,columns:Z.value,fields:p.value.fields,"view-mode":I.value,html:K.value,"onUpdate:columns":ee[8]||(ee[8]=ke=>Z.value=ke),onSave:Ge},null,8,["token","columns","fields","view-mode","html"])):z.value==="filter"?(e.openBlock(),e.createBlock(y1,{key:4,token:D.value,fields:p.value.fields,columns:q.value,"onUpdate:columns":ee[9]||(ee[9]=ke=>q.value=ke),onSave:ee[10]||(ee[10]=ke=>We("filters",ke))},null,8,["token","fields","columns"])):z.value==="metadata"?(e.openBlock(),e.createBlock($o,{key:5,data:g.value,"entity-id":String(e.unref(i)),"entity-type":"service",onSaved:ie},null,8,["data","entity-id"])):e.createCommentVNode("",!0)])])],2)])}}}),[["__scopeId","data-v-008c5939"]])},Symbol.toStringTag,{value:"Module"})),Z1={class:"flex-1 flex flex-col bg-gray-50 h-screen overflow-hidden p-0 m-0"},G1={href:"/api/gis-create-xml",target:"_blank",rel:"noreferrer",class:"flex h-[2rem] items-center gap-1.5 px-3 py-1.5 bg-slate-50 text-slate-700 rounded-md border border-slate-200 hover:bg-slate-100 transition-colors text-sm"},K1={class:"flex-1 px-4 sm:px-6 pb-4 overflow-y-auto overflow-x-visible"},X1={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-visible"},Q1={class:"p-3 border-b border-gray-200"},J1={class:"flex flex-col sm:flex-row gap-2"},ek={class:"entity-table-root"},tk={class:"gap-2 inline-flex"},nk=["onClick"],ok={key:0,class:"flex flex-col gap-3 border-t border-gray-200 px-4 py-3 sm:flex-row sm:items-center sm:justify-between bg-gray-50"},rk={class:"text-sm text-gray-500"},lk={class:"font-medium text-gray-700"},ak={class:"font-medium text-gray-700"},sk={class:"font-medium text-gray-700"},ik={class:"flex items-center justify-end gap-3"},ck=Object.freeze(Object.defineProperty({__proto__:null,default:Ce(e.defineComponent({__name:"RastersTablePage",props:{entityKey:{default:"rasters"},entityBasePath:{default:"/gis.rasters"},columnsConfig:{default:()=>[]}},setup(t){const n=e.defineAsyncComponent(()=>import("@opengis/table")),o=Fe.useRoute(),r=Fe.useRouter(),a=t,i=e.computed(()=>{var v;return String(((v=o.meta)==null?void 0:v.title)||"Растри")}),s=e.computed(()=>{var v;return String(((v=o.meta)==null?void 0:v.description)||"")}),c=e.computed(()=>`Пошук ${String(i.value).trim()}...`),p=e.computed(()=>a.entityKey||"rasters"),g=e.computed(()=>a.entityBasePath||"/gis.rasters"),x=e.ref([]),l=e.ref(!0),y=e.ref([]),d=e.ref([]),u=e.ref({}),b=e.ref([]),f=e.ref(String(o.query.search??"")),m=e.ref(Math.max(1,Number(o.query.page)||1)),h=e.ref(15),k=e.ref(0),N=e.computed(()=>k.value>0),$=e.computed(()=>k.value?(m.value-1)*h.value+1:0),E=e.computed(()=>k.value?Math.min(m.value*h.value,k.value):0);function w(v){const F=new URLSearchParams;return Object.entries(v).forEach(([V,_])=>{if(!(_==null||_==="")){if(Array.isArray(_)){_.forEach(T=>{T!=null&&T!==""&&F.append(V,String(T))});return}F.append(V,String(_))}}),F.toString()}function S(){return`${g.value}/new`}function A(v){return`${g.value}/${v}/edit`}async function R(){try{l.value=!0;const v=`/api/data/gis.${p.value}.table`,F=w({...u.value,page:m.value,limit:h.value}),V=await fetch(F?`${v}?${F}`:v);if(!V.ok)throw new Error(`Rows fetch failed: ${V.status}`);const _=await V.json();x.value=_.rows||[],k.value=Number(_.filtered??_.total??_.count??x.value.length)||0,y.value=a.columnsConfig.length?a.columnsConfig:_.columns||[],d.value=_.filters||[],b.value=_.actions||[],y.value.length&&!y.value[0].link?y.value[0].link=`${g.value}/{id}`:y.value.length&&(y.value[0].link=`${g.value}/{id}`)}catch{x.value=[],k.value=0}finally{l.value=!1}}function Z(v){u.value=v,m.value=1,D(),R()}async function I(v,F,V){const _=await fetch(`/api/form/gis.${p.value}.table/${v.id}`);if(!_.ok)throw new Error(`Form fetch failed: ${_.status}`);const z=(await _.json()).token,Q=await fetch(`/api/table/${z}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({[F]:V})});if(!Q.ok)throw ye.notify({type:"error",title:"Помилка збереження",message:`Поле "${F}" не оновлено`}),new Error(`Save failed: ${Q.status}`);ye.notify({title:"Збережено",message:`Поле "${F}" оновлено`})}function K(v,F){u.value={...u.value,[v]:F},m.value=1,D(),R()}function q(v){K((v==null?void 0:v.name)||"search",(v==null?void 0:v.value)??f.value)}function ne(v){f.value="",K(v||"search",void 0)}function Y(v){!v||v===m.value||(m.value=v,D(),R())}function D(){const v={...o.query,page:String(m.value),...f.value?{search:f.value}:{}};f.value||delete v.search,delete v.view,r.replace({query:v})}return e.onMounted(()=>{R(),document.title=i.value}),e.watch(()=>o.name,()=>{m.value=1,f.value="",R(),document.title=i.value}),e.watch(()=>o.query,v=>{const F=Math.max(1,Number(v.page)||1),V=String(v.search??""),_=F!==m.value,T=V!==f.value;!_&&!T||(m.value=F,f.value=V,u.value={...u.value,search:V||void 0},R())}),(v,F)=>(e.openBlock(),e.createElementBlock("div",Z1,[e.createVNode(Yt,{variant:"table"},e.createSlots({title:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.value),1)]),actions:e.withCtx(()=>[e.createElementVNode("a",G1,[e.createVNode(e.unref(ce.RefreshCw),{size:16}),F[2]||(F[2]=e.createTextVNode(" Оновити растри ",-1))]),e.createElementVNode("a",{onClick:F[0]||(F[0]=V=>e.unref(r).push(S())),class:"hover:cursor-pointer flex items-center gap-1.5 px-3 py-1.5 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors text-sm"},[e.createVNode(e.unref(ce.Plus),{size:16}),F[3]||(F[3]=e.createTextVNode(" Додати ",-1))])]),_:2},[s.value?{name:"description",fn:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(s.value),1)]),key:"0"}:void 0]),1024),e.createElementVNode("div",K1,[e.createElementVNode("div",X1,[e.createElementVNode("div",Q1,[e.createElementVNode("div",J1,[e.createVNode(e.unref(Nn.FilterField),{modelValue:f.value,"onUpdate:modelValue":F[1]||(F[1]=V=>f.value=V),name:"search",type:"text",layout:"inline",class:"flex-1",width:"100%",cleanable:!0,onChange:q,onClear:ne,placeholder:c.value},null,8,["modelValue","placeholder"]),e.createVNode(e.unref(Nn.Filter),{schema:d.value,value:u.value,onChange:Z,layout:"inline",mode:"soft",view:"popover",limit:8,class:"flex-shrink-0"},null,8,["schema","value"])])]),e.createElementVNode("div",ek,[e.createVNode(e.unref(n),{rows:x.value,columns:y.value,loading:l.value,router:e.unref(r),selectable:!1,onCellUpdate:I,classWrapper:"overflow-x-auto overflow-y-visible",TableStyle:"w-full",classTable:"w-full min-w-[640px]",classThead:"bg-gray-50 border-b border-gray-200",classTh:"px-3 sm:px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",classTbody:"bg-white divide-y divide-gray-200",classTr:"hover:bg-gray-50 transition-colors",classTd:"px-3 sm:px-4 py-2.5 whitespace-nowrap",classLink:"text-sm font-medium text-blue-600 hover:text-blue-800 hover:underline text-left"},{action:e.withCtx(({row:V})=>[e.createElementVNode("div",tk,[e.createElementVNode("button",{onClick:_=>e.unref(r).push(A(V.id)),class:"inline-flex items-center justify-center bg-white border rounded-md size-7 gap-x-2 hover:bg-gray-100",title:"Редагувати","aria-label":"Редагувати"},[e.createVNode(Vn)],8,nk)])]),_:1},8,["rows","columns","loading","router"])]),N.value?(e.openBlock(),e.createElementBlock("div",ok,[e.createElementVNode("div",rk,[F[4]||(F[4]=e.createTextVNode(" Показано ",-1)),e.createElementVNode("span",lk,e.toDisplayString($.value),1),F[5]||(F[5]=e.createTextVNode(" - ",-1)),e.createElementVNode("span",ak,e.toDisplayString(E.value),1),F[6]||(F[6]=e.createTextVNode(" з ",-1)),e.createElementVNode("span",sk,e.toDisplayString(k.value),1)]),e.createElementVNode("div",ik,[e.createVNode(e.unref(ye.VsPagination),{total:k.value,page:m.value,"page-size":h.value,showPageSizes:!1,pageRange:5,view:"button",color:"gray","onUpdate:page":Y,onPageChange:Y},null,8,["total","page","page-size"])])])):e.createCommentVNode("",!0)])])]))}}),[["__scopeId","data-v-63309b89"]])},Symbol.toStringTag,{value:"Module"})),dk={class:"flex-1 overflow-y-auto p-4 sm:p-6"},uk={class:"space-y-3"},pk={class:"bg-white p-3 rounded-xl border border-gray-200 shadow-sm"},mk={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2"},fk={class:"text-xs text-gray-500 mb-1"},gk={key:0,class:"text-base text-md font-semibold text-gray-900"},yk={key:1,class:"text-base text-md font-semibold text-gray-900"},hk={class:"bg-white p-3 rounded-xl border border-gray-200 shadow-sm"},xk={class:"space-y-2"},bk={class:"bg-gradient-to-br from-blue-50 to-blue-100/30 p-4 rounded-lg border border-blue-200"},kk={class:"text-sm font-semibold text-gray-900"},wk={class:"text-xs text-gray-600 mt-1"},_k={class:"grid grid-cols-2 gap-3"},Ek={class:"text-xs text-gray-500 mb-1"},Ck={class:"text-sm font-semibold text-gray-900"},Nk={class:"bg-gray-50 p-4 rounded-lg"},Vk={class:"grid grid-cols-2 gap-4"},Bk={class:"text-xs text-gray-500 mb-1"},$k={class:"text-sm font-semibold text-gray-900"},Sk=e.defineComponent({directives:{tooltip:ye.TooltipDirective},__name:"raster-info-tab",props:{details:{}},setup(t){return(n,o)=>{const r=e.resolveDirective("tooltip");return e.openBlock(),e.createElementBlock("div",dk,[e.createElementVNode("div",uk,[e.createElementVNode("div",pk,[o[0]||(o[0]=e.createElementVNode("div",{class:"mb-4"},[e.createElementVNode("h4",{class:"text-sm font-semibold text-gray-900 uppercase tracking-wide"},"Основні параметри")],-1)),e.createElementVNode("div",mk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.details.baseParams,a=>(e.openBlock(),e.createElementBlock("div",{key:a.label,class:"bg-gray-50 p-2 rounded-lg"},[e.createElementVNode("p",fk,e.toDisplayString(a.label),1),a.tooltip?e.withDirectives((e.openBlock(),e.createElementBlock("p",gk,[e.createTextVNode(e.toDisplayString(a.value),1)])),[[r,a.tooltip]]):(e.openBlock(),e.createElementBlock("p",yk,e.toDisplayString(a.value),1))]))),128))])]),e.createElementVNode("div",hk,[o[3]||(o[3]=e.createElementVNode("div",{class:"mb-2"},[e.createElementVNode("h4",{class:"text-sm font-semibold text-gray-900 uppercase tracking-wide"},"Просторова інформація")],-1)),e.createElementVNode("div",xk,[e.createElementVNode("div",null,[o[1]||(o[1]=e.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"},"Система координат",-1)),e.createElementVNode("div",bk,[e.createElementVNode("p",kk,e.toDisplayString(t.details.spatial.crs.code),1),e.createElementVNode("p",wk,e.toDisplayString(t.details.spatial.crs.description),1)])]),e.createElementVNode("div",null,[o[2]||(o[2]=e.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"},"Межі покриття",-1)),e.createElementVNode("div",_k,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.details.spatial.bounds,a=>(e.openBlock(),e.createElementBlock("div",{key:a.label,class:"bg-gray-50 p-2 rounded-lg border border-gray-200"},[e.createElementVNode("p",Ek,e.toDisplayString(a.label),1),e.createElementVNode("p",Ck,e.toDisplayString(a.value),1)]))),128))])]),e.createElementVNode("div",Nk,[e.createElementVNode("div",Vk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.details.spatial.resolution,a=>(e.openBlock(),e.createElementBlock("div",{key:a.label},[e.createElementVNode("p",Bk,e.toDisplayString(a.label),1),e.createElementVNode("p",$k,e.toDisplayString(a.value),1)]))),128))])])])])])])}}}),vk={class:"flex-1 overflow-y-auto space-y-3 pr-1"},Lk={class:"font-medium text-sm text-gray-800"},Ak={class:"text-xs text-gray-500"},Tk=e.defineComponent({__name:"raster-files-tab",props:{files:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",vk,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.files,r=>(e.openBlock(),e.createElementBlock("div",{key:r.name,class:"border border-gray-100 rounded-xl p-4 shadow-sm bg-white flex items-start justify-between"},[e.createElementVNode("div",null,[e.createElementVNode("p",Lk,e.toDisplayString(r.name),1),e.createElementVNode("p",Ak,e.toDisplayString(r.resolution)+" • "+e.toDisplayString(r.size)+"MB",1)]),e.createElementVNode("span",{class:e.normalizeClass(["text-[11px] font-semibold px-2 py-0.5 rounded-full",r.statusClass])},e.toDisplayString(r.status),3)]))),128))]))}}),Mk={},Fk={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function Dk(t,n){return e.openBlock(),e.createElementBlock("svg",Fk,[...n[0]||(n[0]=[e.createElementVNode("circle",{cx:"12",cy:"12",r:"9"},null,-1),e.createElementVNode("line",{x1:"12",y1:"8",x2:"12",y2:"8"},null,-1),e.createElementVNode("path",{d:"M11 12h1v4h1"},null,-1)])])}const zk=Ce(Mk,[["render",Dk]]),Ik={class:"absolute top-[5.5rem] left-4 z-30 flex flex-col items-start gap-2"},Pk={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},jk={class:"flex items-center gap-2"},Rk={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},Ok={class:"inline-flex items-center gap-2 text-[11px] text-slate-600"},Uk=["checked"],qk=e.defineComponent({__name:"RasterLayer",props:{tileUrl:{},extent:{},layerId:{},beforeId:{},showRasterExtent:{type:Boolean}},emits:["toggle-extent"],setup(t){const n=t,o=n.layerId||"raster-preview-layer",r=`${o}-source`,a=n.extent&&n.extent.length===4?[...n.extent]:void 0,i=Ue(o,{sourceId:r,source:{type:"raster",tiles:n.tileUrl?[n.tileUrl+"?nottl=1"]:[],tileSize:256,...a?{bounds:a}:{}},layer:{id:`${o}-raster`,type:"raster",paint:{"raster-opacity":1}},beforeId:n.beforeId??null}),{fitBounds:s}=tt(),c=e.ref(1);e.watch(()=>n.tileUrl,l=>{if(!l){i.setVisible(!1);return}i.setVisible(!0),i.setTiles([l])},{immediate:!0}),e.watch(()=>c.value,l=>{i.setOpacity(l)},{immediate:!0});let p=null,g=!1;e.watch(()=>n.extent,l=>{if(!l||l.length!==4)return;const y=l.join(",");if(y!==p){if(p=y,!g){g=!0;return}s==null||s([[l[0],l[1]],[l[2],l[3]]],{padding:40,maxZoom:17})}},{immediate:!0});const x=e.computed(()=>`${Math.round(c.value*100)}%`);return(l,y)=>(e.openBlock(),e.createElementBlock("div",Ik,[e.createElementVNode("div",Pk,[e.createElementVNode("div",jk,[y[2]||(y[2]=e.createElementVNode("span",null,"Прозорість:",-1)),e.withDirectives(e.createElementVNode("input",{type:"range",min:"0",max:"1",step:"0.01","onUpdate:modelValue":y[0]||(y[0]=d=>c.value=d),class:"h-1 w-28 cursor-pointer appearance-none rounded-full bg-slate-300 focus:outline-none",style:{"accent-color":"#3b82f6"}},null,512),[[e.vModelText,c.value,void 0,{number:!0}]]),e.createElementVNode("span",null,e.toDisplayString(x.value),1)])]),e.createElementVNode("div",Rk,[e.createElementVNode("label",Ok,[e.createElementVNode("input",{type:"checkbox",class:"h-3.5 w-3.5 rounded border-slate-300 text-blue-600 focus:ring-blue-200",checked:t.showRasterExtent,onChange:y[1]||(y[1]=d=>l.$emit("toggle-extent",d.target.checked))},null,40,Uk),y[3]||(y[3]=e.createElementVNode("span",null,"Межі растру",-1))])])]))}}),On=e.defineComponent({__name:"ExtentOutlineLayer",props:{extent:{},layerId:{},beforeId:{},lineColor:{},lineWidth:{}},setup(t){const n=t,o=n.layerId||"extent-outline-layer",r=`${o}-source`,a=e.computed(()=>{const{extent:c}=n;if(!c||c.length!==4)return null;const[p,g,x,l]=c;return[p,g,x,l].some(y=>typeof y!="number"||Number.isNaN(y))?null:{type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[p,g],[x,g],[x,l],[p,l],[p,g]]]}}]}}),i=tt(),s=Ue(o,{sourceId:r,source:{type:"geojson",data:a.value||{type:"FeatureCollection",features:[]}},layer:{id:o,type:"line",paint:{"line-color":n.lineColor??"#ef4444","line-width":n.lineWidth??2}},beforeId:n.beforeId??null});return e.watch(()=>a.value,c=>{var g;if(!c){s.setVisible(!1),s.setData({type:"FeatureCollection",features:[]});return}s.setVisible(!0),s.setData(c);const p=(g=i.map)==null?void 0:g.value;p!=null&&p.moveLayer&&p.getLayer(o)&&p.moveLayer(o)},{immediate:!0}),(c,p)=>e.createCommentVNode("",!0)}}),Hk={class:"flex h-full bg-gradient-to-br from-slate-50 to-white"},Wk={class:"flex-1 relative overflow-hidden"},Yk={class:"absolute top-0 left-0 w-full z-20"},Zk={class:"px-4 sm:px-6 py-4 border-b border-gray-200 bg-white shadow-sm"},Gk={class:"flex items-start justify-between gap-4"},Kk={class:"flex-1 min-w-0"},Xk={class:"flex items-center text-sm text-gray-500 mb-3"},Qk={class:"text-gray-900 font-medium truncate max-w-xs"},Jk={class:"flex items-center justify-between gap-4"},ew={class:"flex-1 min-w-0"},tw={class:"flex items-center gap-3 mb-1"},nw={class:"text-base font-semibold text-gray-900 truncate"},ow=["title"],rw={class:"flex items-center gap-4 min-w-0"},lw={class:"flex-1 min-w-0"},aw=["title"],sw={class:"w-full h-full bg-gradient-to-br from-sky-50 via-white to-blue-50 flex items-center justify-center relative pt-[105px]"},iw={class:"relative w-full h-full"},cw={class:"absolute top-4 left-4 z-20"},dw={key:1,class:"absolute bottom-4 left-1/2 z-30 -translate-x-1/2 rounded-2xl border border-sky-200 bg-white/95 px-4 py-2 text-xs font-medium text-slate-700 shadow-lg backdrop-blur"},uw={class:"absolute top-[6.5rem] right-2 space-y-1 z-20"},pw={class:"flex-1 flex flex-col h-full"},mw={class:"px-3 pt-3 pb-2 border-b border-gray-100"},fw={class:"items-center justify-center text-muted-foreground grid w-full grid-cols-3 h-12 p-1 bg-gray-50 rounded-xl shadow-sm"},gw=["aria-selected","onClick"],yw={class:"leading-none"},hw={class:"flex flex-col flex-1 overflow-y-hidden p-3"},xw={key:0,class:"mb-3 text-xs text-slate-500"},bw={key:1,class:"mb-3 text-xs text-rose-600"},kw="OpenGIS",Vl=2,Un=5,ww=5,_w=Object.freeze(Object.defineProperty({__proto__:null,default:e.defineComponent({__name:"raster",setup(t){const n=[{cardClass:"bg-gradient-to-br from-green-50 to-green-100/30 border-green-200",titleClass:"text-green-900"},{cardClass:"bg-gradient-to-br from-blue-50 to-blue-100/30 border-blue-200",titleClass:"text-blue-900"},{cardClass:"bg-gradient-to-br from-purple-50 to-purple-100/30 border-purple-200",titleClass:"text-purple-900"},{cardClass:"bg-gradient-to-br from-gray-50 to-gray-100/30 border-gray-200",titleClass:"text-gray-900"}],o=Fe.useRouter(),r=Fe.useRoute(),a=e.ref(null),i=e.computed(()=>{var M;const B=(M=r.params)==null?void 0:M.id;return typeof B=="string"?B:void 0}),s=e.ref(null),c=e.ref(!1),p=e.ref(!1),g=e.ref(null),x=e.ref(!0),l=e.ref(!1),y=e.ref(null);let d=null,u=null;const b=e.ref(!1);let f=null,m=!1;function h(B){if(Array.isArray(B))return h(B[0]);if(typeof B!="string"&&typeof B!="number")return null;const M=typeof B=="number"?B:Number(B.trim());return Number.isFinite(M)?M:null}function k(B,M){return B.toFixed(M)}function N(B,M,X){const le=.5*10**-X;return Math.abs(B-M)>le}function $(){var B;return(B=a.value)==null?void 0:B.ctx}function E(){var O,H,ae,ge;const B=(H=(O=$())==null?void 0:O.map)==null?void 0:H.value;if(!B)return;const M=h(r.query.z),X=h(r.query.x),le=h(r.query.y);if(M==null||X==null||le==null)return;const de=(ae=B.getCenter)==null?void 0:ae.call(B),xe=(ge=B.getZoom)==null?void 0:ge.call(B);(!de||N(de.lng,X,Un)||N(de.lat,le,Un)||N(xe??0,M,Vl))&&(b.value=!0,B.jumpTo({center:[X,le],zoom:M}),b.value=!1)}function w(){var de,xe,P,O;if(b.value)return;const B=(xe=(de=$())==null?void 0:de.map)==null?void 0:xe.value;if(!B)return;const M=(P=B.getCenter)==null?void 0:P.call(B),X=(O=B.getZoom)==null?void 0:O.call(B);if(!M||X==null)return;const le={...r.query,z:k(X,Vl),x:k(M.lng,Un),y:k(M.lat,Un)};r.query.z===le.z&&r.query.x===le.x&&r.query.y===le.y||o.replace({query:le})}function S(){var M;if(typeof document>"u")return;const B=(M=te.value)==null?void 0:M.name;document.title=B?`${B} — Растер`:kw}function A(B){return Number(B.toFixed(ww))}function R(B,M){const[X,le]=B,[de,xe]=M;return[A(Math.min(X,de)),A(Math.min(le,xe)),A(Math.max(X,de)),A(Math.max(le,xe))]}function Z(B){const[M,X,le,de]=B;return{type:"Polygon",coordinates:[[[M,X],[le,X],[le,de],[M,de],[M,X]]]}}function I(B){var le,de,xe;const M=(de=(le=$())==null?void 0:le.map)==null?void 0:de.value,X=(xe=M==null?void 0:M.getCanvas)==null?void 0:xe.call(M);X!=null&&X.style&&(X.style.cursor=B)}async function K(B,M){if(!(!i.value||!s.value))try{const X=Z(B),le=await fetch(`/api/gis-metadata/raster/${encodeURIComponent(i.value)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({geom:X})});if(!le.ok)throw new Error(`Failed to save raster metadata geom: ${le.status}`);ye.notify({type:"success",title:"Extent збережено",message:"Нові межі успішно збережено."}),await Ke()}catch(X){console.error("Failed to save raster extent",X),s.value&&(s.value={...s.value,extent:M?[...M]:void 0}),ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти Extent"})}}function q(B){var X,le,de;const M=(le=(X=$())==null?void 0:X.map)==null?void 0:le.value;if((de=M==null?void 0:M.dragPan)!=null&&de.enable&&M.dragPan.enable(),(B==null?void 0:B.length)===4&&s.value){const xe=Array.isArray(s.value.extent)?[...s.value.extent]:null;s.value={...s.value,extent:[...B]},K(B,xe)}f=null,m=!1,y.value=null,l.value=!1,I("")}function ne(){q(null)}function Y(){var xe,P;const B=(P=(xe=$())==null?void 0:xe.map)==null?void 0:P.value;if(!B)return;const M=O=>{var ae,ge,Ne;if(!l.value||((ae=O==null?void 0:O.originalEvent)==null?void 0:ae.button)!=null&&O.originalEvent.button!==0)return;const H=O==null?void 0:O.lngLat;H&&(f=[H.lng,H.lat],m=!0,y.value=[H.lng,H.lat,H.lng,H.lat],(Ne=(ge=B.dragPan)==null?void 0:ge.disable)==null||Ne.call(ge))},X=O=>{if(!l.value||!m||!f)return;const H=O==null?void 0:O.lngLat;H&&(y.value=R(f,[H.lng,H.lat]))},le=O=>{if(!l.value||!m||!f)return;const H=O==null?void 0:O.lngLat;if(!H){ne();return}const ae=R(f,[H.lng,H.lat]),[ge,Ne,Le,Se]=ae;if(!(Math.abs(Le-ge)>0&&Math.abs(Se-Ne)>0)){ye.notify({type:"warning",title:"Bounds не змінено",message:"Потрібно протягнути прямокутник з ненульовою площею."}),ne();return}q(ae)},de=O=>{l.value&&O.key==="Escape"&&(O.preventDefault(),ne())};B.on("mousedown",M),B.on("mousemove",X),B.on("mouseup",le),window.addEventListener("keydown",de),u=()=>{B.off("mousedown",M),B.off("mousemove",X),B.off("mouseup",le),window.removeEventListener("keydown",de)}}async function D(){var X;if(l.value)return;const B=$();!(B!=null&&B.ready)||(await B.ready(),!((X=B.map)==null?void 0:X.value))||(u||Y(),l.value=!0,m=!1,f=null,y.value=null,I("crosshair"),ye.notify({type:"info",title:"Редагування Bounds",message:"Протягніть прямокутник на карті, щоб задати нові межі."}))}const v=e.computed(()=>{var M;const B=(M=s.value)==null?void 0:M.url;return B?/^https?:\/\//i.test(B)||typeof window>"u"||typeof location>"u"?B:`${location.origin}${B}`:""}),F=e.computed(()=>{var B;return((B=s.value)==null?void 0:B.extent)??null}),V=e.computed(()=>i.value?`raster-${i.value}`:void 0),_=e.computed(()=>i.value?`raster-extent-${i.value}`:"raster-extent"),T=e.computed(()=>i.value?`raster-extent-draft-${i.value}`:"raster-extent-draft"),z=e.computed(()=>{const B=V.value??"raster",M=F.value&&F.value.length===4?F.value.join(","):"no-extent";return`${B}-${M}`}),Q=e.computed(()=>!!v.value),se=e.computed(()=>{const B=F.value;if(!B||B.length!==4)return null;const[M,X,le,de]=B;return[M,X,le,de].some(xe=>typeof xe!="number"||Number.isNaN(xe))?null:[(M+le)/2,(X+de)/2]}),te=e.computed(()=>{var xe,P;const B=s.value,M=B==null?void 0:B.extent,le=i.value??"—",de=[B!=null&&B.extension?`Формат ${String(B.extension).toUpperCase()}`:null,(B==null?void 0:B.resolution)||null].filter(Boolean).join(", ");return{id:le,name:(B==null?void 0:B.name)||((P=(xe=B==null?void 0:B.files)==null?void 0:xe[0])==null?void 0:P.name),description:(B==null?void 0:B.description)||de||"Попередній перегляд растрового шару.",coverage:M&&M.length===4?`${W(M[0])}, ${W(M[1])} → ${W(M[2])}, ${W(M[3])}`:"Покриття уточнюється",crs:B!=null&&B.srid?`EPSG:${B.srid}`:"EPSG:4326",source:B!=null&&B.proj4?B.proj4:"Джерело: Mapnik",updatedAt:B!=null&&B.cache?"Дані кешовано":"Нові дані"}}),oe=e.computed(()=>{const B=s.value;return B?[B.source_path,B.srid?`SRID: ${B.srid}`:null,B.is_public?"Публічна":"Не публічна",B.is_active?"Активна":"Неактивна",B.cache?"Кешовано":null].filter(M=>M).join(", "):""}),fe=[{key:"info",label:"Інформація",icon:zk},{key:"files",label:"Файли",icon:Vn},{key:"metadata",label:"Метадані",icon:Bo}],he=fe.map(B=>B.key),ie=e.ref(he.includes(r.query.tab)?r.query.tab:"info"),Be=e.ref(!0);e.watch(()=>r.query.tab,B=>{B&&he.includes(B)&&ie.value!==B&&(ie.value=B)}),e.watch(ie,B=>{r.query.tab!==B&&o.replace({query:{...r.query,tab:B}})});const We=e.computed(()=>G(s.value)),qe=e.computed(()=>be(s.value));e.watch(()=>s.value,()=>{S()},{immediate:!0});async function Re(){var le;const B=$();if(!(B!=null&&B.ready))return;await B.ready(),E();const M=(le=B.map)==null?void 0:le.value;if(!M)return;const X=()=>w();M.on("moveend",X),M.on("zoomend",X),d=()=>{M.off("moveend",X),M.off("zoomend",X)}}e.watch(()=>[r.query.z,r.query.x,r.query.y],()=>{E()}),e.onMounted(()=>{Re()}),e.onBeforeUnmount(()=>{d==null||d(),d=null,u==null||u(),u=null,I("")}),e.watch(i,()=>{Ke()},{immediate:!0});async function Ge(B){var M;Ke(),((M=s.value)==null?void 0:M.srid)!==B.srid&&(ye.notify({title:"XML start",type:"info",message:"зміна системи координат, оновлюємо карту ..."}),await wt(`/api/gis-xml/${encodeURIComponent(i.value)}`),ye.notify({title:"XML created",type:"info",message:"карта створена"}),location.reload())}async function Ke(){const B=i.value;if(!B){s.value=null,g.value=null;return}c.value=!0,g.value=null;try{const M=await fetch(`/api/gis-raster/${encodeURIComponent(B)}`);if(!M.ok)throw new Error(`HTTP ${M.status}`);const X=await M.json();X.xml&&(p.value=!0),s.value=X,X.xml||(ye.notify({title:"XML not found",type:"info",message:"йде створення xml ... зачекайте"}),await wt(`/api/gis-xml/${encodeURIComponent(B)}`),ye.notify({title:"XML created",type:"info",message:"карта створена"}),fetch(`/api/gis-raster/${encodeURIComponent(B)}?nocache=1`),p.value=!0)}catch(M){console.error("Failed to load raster info",M),s.value=null,g.value=M instanceof Error?M.message:String(M)}finally{c.value=!1}}function wt(B){return new Promise((M,X)=>{const le=new EventSource(B),de=[];le.onmessage=xe=>{de.push(xe.data),console.log("Received:",xe.data)},le.addEventListener("end",()=>{le.close(),M(de)}),le.onerror=xe=>{le.close(),M(xe)}})}function G(B){var M;return(M=B==null?void 0:B.files)!=null&&M.length?B.files.map(X=>({name:X.name,resolution:ee(X.name,B),size:X.size||"—",status:"Готово",statusClass:"bg-emerald-50 text-emerald-600 border border-emerald-100"})):[]}function ee(B,M){const X=B.toLowerCase();return X.endsWith(".tfw")?"Georeference":X.endsWith(".xml")?"Опис":X.endsWith(".tif")||X.endsWith(".tiff")?M!=null&&M.resolution?M.resolution:"Растер":(M==null?void 0:M.resolution)??"Файл"}function be(B){return B?{baseParams:Te(B),spatial:{crs:{code:B.srid?`EPSG:${B.srid}`:"EPSG:4326",description:B.proj4||"WGS 84 — World Geodetic System 1984"},bounds:ke(B.extent),resolution:He(B)},statistics:ve(B),technical:lt(B)}:null}function Pe(B){return B!=null&&B.length?B.map(X=>{var de;if(!X)return"";const le=X.trim().split(/\s+/)[0];return((de=le==null?void 0:le[0])==null?void 0:de.toUpperCase())||""}).filter(Boolean).join(""):""}function Te(B){var xe,P;const M=B.bands_count??((xe=B.bands)==null?void 0:xe.length)??"—",X=Pe(B.bands),le=(B.bands??[]).map(O=>O.trim()).filter(O=>O.length>0),de=le.length?le.join(", "):void 0;return[{label:"Розмір растру, px",value:B.width&&B.height?`${B.width}×${B.height}`:"—"},{label:"Формат файлу",value:((P=B.extension)==null?void 0:P.toUpperCase())??"—"},{label:"Розмір файлу, mb",value:B.total_size?`${B.total_size}`:"—"},{label:"Кількість каналів",value:typeof M=="number"?`${M}${X?` (${X})`:""}`:`${M}${X?` (${X})`:""}`,tooltip:de},{label:"Глибина кольору",value:B.color_depth?`${B.color_depth} біт/канал`:"—"},{label:"Стиснення",value:B.compression||"—"}]}function ke(B){return!B||B.length!==4?[]:[{label:"Північ",value:W(B[3],"N")},{label:"Схід",value:W(B[2],"E")},{label:"Південь",value:W(B[1],"S")},{label:"Захід",value:W(B[0],"W")}]}function He(B){const M=[{label:"Роздільна здатність",value:B.resolution||"—"}];return B.width&&B.height&&M.push({label:"Розмір пікселя",value:`${B.width} × ${B.height} px`}),M}function ve(B){var M;return(M=B.bands)!=null&&M.length?B.bands.map((X,le)=>{const de=n[le%n.length];return{label:`Канал ${le+1}${X?` (${X})`:""}`,cardClass:de.cardClass,titleClass:de.titleClass,metrics:[{label:"Назва",value:X||`Канал ${le+1}`},{label:"Глибина",value:B.color_depth?`${B.color_depth} біт`:"—"},{label:"Статус",value:B.cache?"Кешовано":"Готово"}]}}):[]}function lt(B){var M;return[{label:"Тип даних",value:B.color_depth?`Unsigned Integer ${B.color_depth}-bit`:"—"},{label:"Компресія",value:B.compression||"—"},{label:"Кольорова інтерпретація",value:((M=B.bands)==null?void 0:M.join(", "))||"—"},{label:"SRID",value:B.srid?`EPSG:${B.srid}`:"—"},{label:"Проекція (proj4)",value:B.proj4||"—"},{label:"URL тайла",value:B.url||"—"}]}function W(B,M){if(B==null||Number.isNaN(B))return"—";const X=`${B.toFixed(5)}°`;return M?`${X} ${M}`:X}return(B,M)=>(e.openBlock(),e.createElementBlock("div",Hk,[e.createElementVNode("div",Wk,[e.createElementVNode("div",Yk,[e.createElementVNode("div",Zk,[e.createElementVNode("div",Gk,[e.createElementVNode("div",Kk,[e.createElementVNode("div",Xk,[e.createElementVNode("button",{type:"button",class:"hover:text-gray-700 cursor-pointer transition-colors",onClick:M[0]||(M[0]=X=>e.unref(o).push("/gis.rasters"))}," Растри "),M[3]||(M[3]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-chevron-right w-4 h-4 mx-1"},[e.createElementVNode("path",{d:"m9 18 6-6-6-6"})],-1)),e.createElementVNode("span",Qk,e.toDisplayString(te.value.name||"Растер"),1)]),e.createElementVNode("div",Jk,[e.createElementVNode("div",ew,[e.createElementVNode("div",tw,[e.createElementVNode("h1",nw,e.toDisplayString(te.value.name||"Растер"),1)]),oe.value?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-xs text-gray-500 truncate",title:oe.value},e.toDisplayString(oe.value),9,ow)):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",rw,[e.createElementVNode("div",lw,[e.createElementVNode("div",{class:"w-full text-xs text-gray-600 truncate",title:te.value.description},e.toDisplayString(te.value.description),9,aw)]),e.createVNode(So,{"entity-id":i.value||"","entity-info":{name:te.value.name},table:"gis.rasters.table","entity-label":"Растер","save-method":"put","edit-button-text":"Редагувати",onSaved:Ge},null,8,["entity-id","entity-info"])])])])]),e.createElementVNode("div",sw,[e.createElementVNode("div",iw,[e.createVNode(Bn,{ref_key:"mapViewRef",ref:a},{default:e.withCtx(()=>[Q.value&&p.value?(e.openBlock(),e.createBlock(qk,{key:z.value,"tile-url":v.value,extent:F.value,"layer-id":V.value,"show-raster-extent":x.value,onToggleExtent:M[1]||(M[1]=X=>x.value=X)},null,8,["tile-url","extent","layer-id","show-raster-extent"])):e.createCommentVNode("",!0),e.createVNode(On,{extent:x.value?F.value:null,"layer-id":_.value},null,8,["extent","layer-id"]),e.createVNode(On,{extent:y.value,"layer-id":T.value,"line-color":"#0ea5e9","line-width":3},null,8,["extent","layer-id"]),e.createElementVNode("div",cw,[e.createVNode(Wt)]),l.value?(e.openBlock(),e.createElementBlock("div",dw," Потягніть на карті, щоб намалювати нові Bounds. Esc скасовує редагування. ")):e.createCommentVNode("",!0),e.createElementVNode("div",uw,[e.createVNode(It),se.value?(e.openBlock(),e.createBlock(It,{key:0,targetCenter:se.value,targetLabel:"Центр даних",targetAriaLabel:"Перейти до центру даних"},null,8,["targetCenter"])):e.createCommentVNode("",!0)])]),_:1},512)])]),e.createVNode(Vo,{open:Be.value,onToggle:M[2]||(M[2]=X=>Be.value=!Be.value)},null,8,["open"])]),e.createElementVNode("div",{class:e.normalizeClass(["bg-white border-l border-gray-100 flex flex-col overflow-hidden shadow-lg flex-shrink-0 transition-[width] duration-100 ease-in-out",Be.value?"w-[650px]":"w-0"])},[e.createElementVNode("div",pw,[e.createElementVNode("div",mw,[e.createElementVNode("div",fw,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(fe,X=>e.createElementVNode("button",{key:X.key,type:"button",role:"tab","aria-selected":ie.value===X.key,class:e.normalizeClass(["whitespace-nowrap flex flex-col items-center justify-center gap-0.5 py-1 px-1 text-[9px] font-medium transition-all duration-300 hover:bg-white/70 rounded-lg group",ie.value===X.key?"bg-white shadow-sm text-gray-700":""]),onClick:le=>ie.value=X.key},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(X.icon),{class:"h-3.5 w-3.5 mb-0.5"})),e.createElementVNode("span",yw,e.toDisplayString(X.label),1)],10,gw)),64))])]),e.createElementVNode("div",hw,[c.value?(e.openBlock(),e.createElementBlock("div",xw," Завантаження метаданих растру… ")):g.value?(e.openBlock(),e.createElementBlock("div",bw," Не вдалося отримати дані: "+e.toDisplayString(g.value),1)):e.createCommentVNode("",!0),ie.value==="files"?(e.openBlock(),e.createBlock(Tk,{key:2,files:We.value},null,8,["files"])):ie.value==="metadata"?(e.openBlock(),e.createBlock($o,{key:3,data:s.value,"entity-id":i.value,"entity-type":"raster",onSaved:Ke,onEditCssBounds:D},null,8,["data","entity-id"])):qe.value?(e.openBlock(),e.createBlock(Sk,{key:4,details:qe.value},null,8,["details"])):e.createCommentVNode("",!0)])])],2)]))}})},Symbol.toStringTag,{value:"Module"})),Ew={},Cw={xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-table"};function Nw(t,n){return e.openBlock(),e.createElementBlock("svg",Cw,[...n[0]||(n[0]=[e.createElementVNode("path",{d:"M12 3v18"},null,-1),e.createElementVNode("rect",{width:"18",height:"18",x:"3",y:"3",rx:"2"},null,-1),e.createElementVNode("path",{d:"M3 9h18"},null,-1),e.createElementVNode("path",{d:"M3 15h18"},null,-1)])])}const Vw=Ce(Ew,[["render",Nw]]),Bw={class:"flex flex-col h-full"},$w={class:"flex justify-end mb-3 gap-2"},Sw=e.defineComponent({__name:"cartocss-css-tab",props:{modelValue:{}},emits:["update:modelValue","save"],setup(t,{emit:n}){const o=t,r=n,a=e.computed({get:()=>o.modelValue,set:i=>r("update:modelValue",i)});return(i,s)=>(e.openBlock(),e.createElementBlock("div",Bw,[e.createElementVNode("div",$w,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium bg-gradient-to-r from-sky-400 to-blue-400 hover:from-sky-500 hover:to-blue-500 text-white shadow-sm px-4 py-2 h-9 text-xs transition-all duration-300",onClick:s[0]||(s[0]=c=>i.$emit("save"))},[...s[2]||(s[2]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"h-3.5 w-3.5"},[e.createElementVNode("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a 2 2 0 0 1-2-2V5a 2 2 0 0 1 2-2z"}),e.createElementVNode("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a 1 1 0 0 0-1 1v7"}),e.createElementVNode("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})],-1),e.createTextVNode(" Зберегти ",-1)])])]),e.createVNode(kn,{modelValue:a.value,"onUpdate:modelValue":s[1]||(s[1]=c=>a.value=c),language:"cartocss",class:"flex-1 rounded-lg overflow-hidden"},null,8,["modelValue"])]))}}),vw={class:"flex flex-col flex-1 min-h-0"},Lw={class:"flex justify-between mb-3 gap-2"},Aw={class:"text-left"},Tw={class:"font-medium text-gray-900"},Mw={class:"text-xs text-gray-500"},Fw={class:"flex justify-center gap-2"},Dw=["checked","onChange"],zw={class:"text-sm font-medium text-gray-900"},Iw=e.defineComponent({__name:"cartocss-data-tab",props:{modelValue:{default:[]},modelModifiers:{}},emits:e.mergeModels(["save"],["update:modelValue"]),setup(t,{emit:n}){const o=[{key:"table",label:"Таблиця",slot:"datasetCell"},{key:"active",label:"Активний",slot:"activeCell",width:"140px"},{key:"zoom",label:"Min Зум",slot:"zoomCell",width:"140px"}],r=e.defineAsyncComponent(()=>import("@opengis/core").then(u=>u.VsModal)),a=e.defineAsyncComponent(()=>import("@opengis/form")),i=e.useModel(t,"modelValue"),s=n,c=e.ref(!1),p=e.ref({table:"",query:"",srid:"",key:"",columns:"",gcol:"",minzoom:"",maxzoom:"",proj4text:"",active:!0}),g={table:{type:"text",label:"Таблиця",validators:["required"]},key:{type:"text",label:"Ключ",validators:["required"]},query:{type:"text",label:"Query"},columns:{type:"text",label:"Колонки"},gcol:{type:"text",label:"Колонка geometry"},srid:{type:"number",label:"SRID"},proj4text:{type:"text",label:"PROJ4"},active:{type:"switcher",label:"Активна"},minzoom:{type:"number",label:"Min Зум",col:6},maxzoom:{type:"number",label:"Max Зум",col:6}};function x(){p.value={table:"",query:"",srid:"",key:"",columns:"",gcol:"",minzoom:"",maxzoom:"",proj4text:"",active:!0},c.value=!0}function l(){c.value=!1}function y(){var f,m;const u=(f=p.value.table)==null?void 0:f.trim(),b=(m=p.value.key)==null?void 0:m.trim();if(!u||!b){ye.notify({type:"warning",title:"Перевірка",message:"Вкажіть таблицю та підпис"});return}i.value=[...Array.isArray(i.value)?i.value:[],{...p.value,table:u,key:b}],c.value=!1}function d(u,b){var m;const f=((m=b==null?void 0:b.target)==null?void 0:m.checked)??!1;u.active=f,i.value=Array.isArray(i.value)?[...i.value]:[]}return(u,b)=>(e.openBlock(),e.createElementBlock("div",vw,[e.createElementVNode("div",Lw,[e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium bg-gradient-to-r from-gray-500 to-gray-400 text-white h-9 px-4 py-2 hover:from-gray-600 hover:to-gray-500",onClick:x}," Додати таблицю "),e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium bg-gradient-to-r from-sky-400 to-blue-400 hover:from-sky-500 hover:to-blue-500 text-white shadow-sm px-4 py-2 h-9 text-xs transition-all duration-300",onClick:b[0]||(b[0]=f=>s("save"))}," Зберегти ")]),e.createVNode(At,{modelValue:i.value,"onUpdate:modelValue":b[1]||(b[1]=f=>i.value=f),"columns-scheme":o,"form-scheme":g,"add-button":!1,"main-col-width":"260px"},{datasetCell:e.withCtx(({row:f})=>[e.createElementVNode("div",Aw,[e.createElementVNode("div",Tw,e.toDisplayString(f.table),1),e.createElementVNode("div",Mw,e.toDisplayString(f.key),1)])]),activeCell:e.withCtx(({row:f})=>[e.createElementVNode("label",Fw,[e.createElementVNode("input",{type:"checkbox",class:"h-4 w-4 text-sky-500 border-gray-300 rounded focus:ring-sky-300",checked:f.active,onChange:m=>d(f,m)},null,40,Dw)])]),zoomCell:e.withCtx(({row:f})=>[e.createElementVNode("div",zw,e.toDisplayString(f.zoom),1)]),_:1},8,["modelValue"]),e.createVNode(e.unref(r),{teleport:"#modal",visible:c.value,"onUpdate:visible":b[3]||(b[3]=f=>c.value=f),title:"Нова таблиця CartoCSS"},{footer:e.withCtx(()=>[e.createElementVNode("div",{class:"flex justify-end gap-2 p-4 border-т"},[e.createElementVNode("button",{type:"button",class:"px-4 py-2 rounded bg-gray-100 text-gray-700",onClick:l}," Скасувати "),e.createElementVNode("button",{type:"button",class:"px-4 py-2 rounded bg-blue-600 text-white",onClick:y}," Додати ")])]),default:e.withCtx(()=>[e.createVNode(e.unref(a),{values:p.value,"onUpdate:values":b[2]||(b[2]=f=>p.value=f),schema:g},null,8,["values"])]),_:1},8,["visible"])]))}}),Pw={class:"flex flex-col flex-1 min-h-0 gap-4"},jw={class:"h-[calc(100vh-230px)] rounded-md border border-gray-200 bg-white"},Rw=e.defineComponent({__name:"cartocss-card-tab",props:{card:{},table:{}},emits:["save"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(o.table),i=e.ref(o.card),s=e.defineAsyncComponent(()=>import("@opengis/form").then(p=>p.VsInputText));function c(){r("save",{card_html:i.value,card_table:a.value})}return(p,g)=>(e.openBlock(),e.createElementBlock("div",Pw,[e.createElementVNode("div",{class:"flex items-center justify-end gap-3"},[e.createElementVNode("button",{type:"button",class:"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium bg-gradient-to-r from-sky-400 to-blue-400 hover:from-sky-500 hover:to-blue-500 text-white shadow-sm px-4 py-2 h-9 text-xs transition-all duration-300",onClick:c},[...g[2]||(g[2]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"h-3.5 w-3.5"},[e.createElementVNode("path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a 2 2 0 0 1-2-2V5a 2 2 0 0 1 2-2z"}),e.createElementVNode("path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a 1 1 0 0 0-1 1v7"}),e.createElementVNode("path",{d:"M7 3v4a1 1 0 0 0 1 1h7"})],-1),e.createTextVNode(" Зберегти картку ",-1)])])]),e.createElementVNode("div",null,[e.createVNode(e.unref(s),{modelValue:a.value,"onUpdate:modelValue":g[0]||(g[0]=x=>a.value=x)},null,8,["modelValue"])]),e.createElementVNode("div",jw,[e.createVNode(kn,{modelValue:i.value,"onUpdate:modelValue":g[1]||(g[1]=x=>i.value=x),language:"html",theme:"vs-light",class:"h-full w-full rounded-md"},null,8,["modelValue"])])]))}}),Ow=e.defineComponent({__name:"CartocssLayerLoader",props:{layerId:{type:String,required:!0},tileUrl:{type:String,default:""},title:{type:String,default:""},active:{type:Boolean,default:!1},owner:{type:String,default:""},opacity:{type:Number,default:1}},setup(t){const n=t,o=tt(),{activateTemporaryLayer:r,deactivateTemporaryLayer:a,setTemporaryLayerOpacity:i}=lo(o.map),s=e.computed(()=>{var l;const x=`${(l=n==null?void 0:n.tileUrl)==null?void 0:l.trim()}`;return x?typeof window>"u"||typeof location>"u"||/^https?:\/\//i.test(x)?x:x.startsWith("//")?`${window.location.protocol}${x}`:x.startsWith("/")?`${location.origin}${x}`:`${location.origin}/${x}`:""});let c="",p="";function g(){const x=n.active&&!!s.value;c&&(!x||c!==n.layerId)&&(a(c,p||void 0),c="",p=""),x&&(r({id:n.layerId,title:n.title||n.layerId,url:s.value,opacity:n.opacity},{},n.owner),c=n.layerId,p=n.owner||"")}return e.watch(()=>[n.layerId,s.value,n.active,n.owner],g,{immediate:!0}),e.watch(()=>n.opacity,x=>{!c||!n.active||i(c,x,p||void 0)},{immediate:!0}),e.onUnmounted(()=>{c&&(a(c,p||void 0),c="",p="")}),(x,l)=>e.createCommentVNode("",!0)}}),Uw=e.defineComponent({__name:"CartocssMapClickListener",props:{cartocssId:{},infoEnabled:{type:[Boolean,null]}},setup(t){const n=t,o=e.computed(()=>n.cartocssId??null),r=e.computed(()=>!!n.infoEnabled),{map:a,ready:i}=tt(),s=d=>{!d||typeof window>"u"||window.dispatchEvent(new CustomEvent(so,{detail:d}))},c=async d=>{const u=await fetch(`/api/map-format?${d.toString()}`);if(!u.ok)throw new Error(`API returned ${u.status}`);return u.json()};let p=null,g=null;const x=d=>{if(!d)return null;if(typeof d=="string")try{return JSON.parse(d)}catch{return null}return d},l=async(d,u)=>{var m;const b=o.value?`external:${o.value},${String(d)}`:null,f=new URLSearchParams({layer:o.value??"",id:String(d)});try{const h=await c(f),k=typeof h.html=="string"?h.html:null,N=x(((m=h==null?void 0:h.data)==null?void 0:m.geom)??(h==null?void 0:h.geom)??null);(k||N)&&s({html:k,geometry:N??u,infoToken:b})}catch(h){console.warn("CartoCSS map-format (id) error",h)}},y=async d=>{var m,h,k,N;if(!o.value)return;if(!r.value){ye.notify({type:"error",title:"CartoCSS",message:"Картка не налаштована"});return}const u=(m=d==null?void 0:d.lngLat)==null?void 0:m.lng,b=(h=d==null?void 0:d.lngLat)==null?void 0:h.lat;if(typeof u!="number"||typeof b!="number")return;const f=new URLSearchParams({layer:o.value,lat:b.toFixed(6),lng:u.toFixed(6)});try{const $=await c(f),E=x(((k=$==null?void 0:$.data)==null?void 0:k.geom)??($==null?void 0:$.geom)??null),w=((N=$==null?void 0:$.data)==null?void 0:N.id)??($==null?void 0:$.id);if(w!=null){await l(w,E);return}Ko({html:$==null?void 0:$.html})&&s({html:$==null?void 0:$.html,geometry:E,infoToken:null})}catch($){console.warn("CartoCSS map-format error",$)}};return i().then(()=>{g=a.value,g&&(g.on("click",y),p=()=>g==null?void 0:g.off("click",y))}),e.onBeforeUnmount(()=>{p==null||p(),p=null,g=null}),()=>{}}}),qw={class:"flex h-full bg-gradient-to-br from-slate-50 to-white"},Hw={class:"flex-1 relative overflow-hidden"},Ww={class:"absolute top-0 left-0 w-full z-20"},Yw={class:"px-4 sm:px-6 py-4 border-b border-gray-200 bg-white shadow-sm"},Zw={class:"flex items-start justify-between gap-4"},Gw={class:"flex-1 min-w-0"},Kw={class:"flex items-center text-sm text-gray-500 mb-3"},Xw={class:"text-gray-900 font-medium truncate max-w-xs"},Qw={class:"flex items-center justify-between gap-4"},Jw={class:"flex-1 min-w-0"},e2={class:"flex items-center gap-3 mb-1"},t2={class:"text-base font-semibold text-gray-900 truncate"},n2={key:0,class:"px-2 py-0.5 bg-green-50 border border-green-200 rounded flex-shrink-0"},o2={class:"text-xs font-medium text-green-700"},r2=["title"],l2={class:"w-full h-full bg-gradient-to-br from-sky-50 via-white to-blue-50 flex items-center justify-center relative pt-[115px]"},a2={class:"relative w-full h-full"},s2={class:"absolute top-[5.5rem] left-4 z-30 flex flex-col items-start gap-2"},i2={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},c2={class:"flex items-center gap-2"},d2={class:"rounded-2xl bg-white/90 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur"},u2={class:"inline-flex items-center gap-2 text-[11px] text-slate-600"},p2=["checked"],m2={class:"absolute top-4 left-4 z-20"},f2={class:"absolute top-[6.5rem] right-2 space-y-1 z-20"},g2={key:0,class:"absolute bottom-4 left-1/2 z-30 -translate-x-1/2 rounded-2xl border border-sky-200 bg-white/95 px-4 py-2 text-xs font-medium text-slate-700 shadow-lg backdrop-blur"},y2={class:"flex-1 flex flex-col h-full"},h2={key:0,class:"px-3 pt-3 pb-2 border-b border-gray-100"},x2=["aria-selected","onClick"],b2={class:"leading-none"},k2={class:"flex flex-col flex-1 overflow-y-hidden p-3"},w2={key:0,class:"flex-1 flex items-center justify-center text-sm text-gray-500"},_2="cartocss-demo-001",E2="OpenGIS",Bl=2,qn=5,C2=5,N2=Object.freeze(Object.defineProperty({__proto__:null,default:e.defineComponent({__name:"cartocss",setup(t){const n=Fe.useRouter(),o=Fe.useRoute(),r=e.ref(null),a=[{key:"css",label:"CSS",icon:kl},{key:"data",label:"Дані",icon:Vw},{key:"metadata",label:"Метадані",icon:Bo},{key:"card",label:"Картка",icon:wl}],i=a.map(W=>W.key),s=e.ref(i.includes(o.query.tab)?o.query.tab:"css"),c=e.ref(!0),p=e.ref(null),g=e.computed(()=>{var W;return(W=p.value)!=null&&W.source_path?a.filter(B=>B.key==="card"||B.key==="metadata"):a}),x=e.computed(()=>o.params.id||_2),l=e.ref({id:x.value,name:"",description:""});let y=null;const d=e.ref(!1);function u(W){if(Array.isArray(W))return u(W[0]);if(typeof W!="string"&&typeof W!="number")return null;const B=typeof W=="number"?W:Number(W.trim());return Number.isFinite(B)?B:null}function b(W,B){return W.toFixed(B)}function f(W,B,M){const X=.5*10**-M;return Math.abs(W-B)>X}function m(){var W;return(W=r.value)==null?void 0:W.ctx}function h(){var P,O,H,ae;const W=(O=(P=m())==null?void 0:P.map)==null?void 0:O.value;if(!W)return;const B=u(o.query.z),M=u(o.query.x),X=u(o.query.y);if(B==null||M==null||X==null)return;const le=(H=W.getCenter)==null?void 0:H.call(W),de=(ae=W.getZoom)==null?void 0:ae.call(W);(!le||f(le.lng,M,qn)||f(le.lat,X,qn)||f(de??0,B,Bl))&&(d.value=!0,W.jumpTo({center:[M,X],zoom:B}),d.value=!1)}function k(){var le,de,xe,P;if(d.value)return;const W=(de=(le=m())==null?void 0:le.map)==null?void 0:de.value;if(!W)return;const B=(xe=W.getCenter)==null?void 0:xe.call(W),M=(P=W.getZoom)==null?void 0:P.call(W);if(!B||M==null)return;const X={...o.query,z:b(M,Bl),x:b(B.lng,qn),y:b(B.lat,qn)};o.query.z===X.z&&o.query.x===X.x&&o.query.y===X.y||n.replace({query:X})}function N(W){typeof document>"u"||(document.title=W?`${W} — CartoCSS`:E2)}const $=e.ref(""),E=e.ref([]),w=e.ref(!1),S=e.ref(!1),A=e.ref(""),R=e.ref(0),Z=e.ref(!1),I=e.ref(1),K=e.ref(!0),q=e.ref(!1),ne=e.ref(null),Y=e.computed(()=>`cartocss-layer-${x.value}`),D=e.computed(()=>`${Math.round(I.value*100)}%`),v=e.computed(()=>`cartocss-extent-${x.value}`),F=e.computed(()=>`cartocss-extent-draft-${x.value}`),V=e.computed(()=>{var le;const W=(le=A.value)==null?void 0:le.trim();if(!W)return"";const B=W.includes("?")?"&":"?",M=`${W}${B}nottl=1`,X=R.value;return X?`${W}${B}ts=${X}&nocache=1`:M}),_=e.ref(""),T=e.ref(""),z=e.computed(()=>{var de;const W=(de=p.value)==null?void 0:de.bounds;if(!Array.isArray(W)||W.length<4)return null;const[B,M,X,le]=W;return[B,M,X,le].some(xe=>typeof xe!="number"||Number.isNaN(xe))?null:[(B+X)/2,(M+le)/2]}),Q=e.computed(()=>{var de;const W=(de=p.value)==null?void 0:de.bounds;if(!Array.isArray(W)||W.length<4)return null;const[B,M,X,le]=W;return[B,M,X,le].some(xe=>typeof xe!="number"||Number.isNaN(xe))?null:[B,M,X,le]}),se=e.computed(()=>{const W=p.value;return W?[W.description,W.group_id?`Група: ${W.group_id}`:null,W.source_path?`Шлях: ${W.source_path}`:null,W.is_public===!0?"Публічний":"Не публічний",W.enabled===!0?"Активний":"Неактивний"].filter(Boolean).join(", "):""}),te=e.computed(()=>{var B;const W=(B=p.value)==null?void 0:B.group_id;return W?String(W).toUpperCase():""});let oe=null,fe=!1,he=null;function ie(W){return Number(W.toFixed(C2))}function Be(W,B){const[M,X]=W,[le,de]=B;return[ie(Math.min(M,le)),ie(Math.min(X,de)),ie(Math.max(M,le)),ie(Math.max(X,de))]}function We(W){const[B,M,X,le]=W;return{type:"Polygon",coordinates:[[[B,M],[X,M],[X,le],[B,le],[B,M]]]}}function qe(W){var X,le,de;const B=(le=(X=m())==null?void 0:X.map)==null?void 0:le.value,M=(de=B==null?void 0:B.getCanvas)==null?void 0:de.call(B);M!=null&&M.style&&(M.style.cursor=W)}async function Re(W,B){if(!(!x.value||!p.value)){S.value=!0;try{const M=We(W),X=await fetch(`/api/gis-css/${x.value}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({geom:M})});if(!X.ok)throw new Error(`Failed to save cartocss bounds: ${X.status}`);ye.notify({type:"success",title:"Bounds збережено",message:"Нові межі успішно збережено."}),await He(x.value,{bustCache:!0})}catch(M){console.error("Failed to save CartoCSS bounds",M),p.value&&(p.value={...p.value,bounds:B?[...B]:null}),ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти Bounds"})}finally{S.value=!1}}}function Ge(W){var M,X,le;const B=(X=(M=m())==null?void 0:M.map)==null?void 0:X.value;if((le=B==null?void 0:B.dragPan)!=null&&le.enable&&B.dragPan.enable(),(W==null?void 0:W.length)===4&&p.value){const de=Array.isArray(p.value.bounds)?[...p.value.bounds]:null;p.value={...p.value,bounds:[...W]},Re(W,de)}oe=null,fe=!1,ne.value=null,q.value=!1,qe("")}function Ke(){Ge(null)}function wt(){var de,xe;const W=(xe=(de=m())==null?void 0:de.map)==null?void 0:xe.value;if(!W)return;const B=P=>{var H,ae,ge;if(!q.value||((H=P==null?void 0:P.originalEvent)==null?void 0:H.button)!=null&&P.originalEvent.button!==0)return;const O=P==null?void 0:P.lngLat;O&&(oe=[O.lng,O.lat],fe=!0,ne.value=[O.lng,O.lat,O.lng,O.lat],(ge=(ae=W.dragPan)==null?void 0:ae.disable)==null||ge.call(ae))},M=P=>{if(!q.value||!fe||!oe)return;const O=P==null?void 0:P.lngLat;O&&(ne.value=Be(oe,[O.lng,O.lat]))},X=P=>{if(!q.value||!fe||!oe)return;const O=P==null?void 0:P.lngLat;if(!O){Ke();return}const H=Be(oe,[O.lng,O.lat]),[ae,ge,Ne,Le]=H;if(!(Math.abs(Ne-ae)>0&&Math.abs(Le-ge)>0)){ye.notify({type:"warning",title:"Bounds не змінено",message:"Потрібно протягнути прямокутник з ненульовою площею."}),Ke();return}Ge(H)},le=P=>{q.value&&P.key==="Escape"&&(P.preventDefault(),Ke())};W.on("mousedown",B),W.on("mousemove",M),W.on("mouseup",X),window.addEventListener("keydown",le),he=()=>{W.off("mousedown",B),W.off("mousemove",M),W.off("mouseup",X),window.removeEventListener("keydown",le)}}async function G(){var M;const W=m();!(W!=null&&W.ready)||(await W.ready(),!((M=W.map)==null?void 0:M.value))||(he||wt(),q.value=!0,fe=!1,oe=null,ne.value=null,qe("crosshair"),ye.notify({type:"info",title:"Редагування Bounds",message:"Протягніть прямокутник на карті, щоб задати нові межі."}))}e.watch(x,W=>{W&&He(W)},{immediate:!0}),e.watch(()=>{var W;return(W=l.value)==null?void 0:W.name},W=>N(W),{immediate:!0});async function ee(){var X;const W=m();if(!(W!=null&&W.ready))return;await W.ready(),h();const B=(X=W.map)==null?void 0:X.value;if(!B)return;const M=()=>k();B.on("moveend",M),B.on("zoomend",M),y=()=>{B.off("moveend",M),B.off("zoomend",M)}}e.watch(()=>[o.query.z,o.query.x,o.query.y],()=>{h()}),e.onMounted(()=>{ee()}),e.onBeforeUnmount(()=>{y==null||y(),y=null,he==null||he(),he=null,qe("")}),e.watch(()=>o.query.tab,W=>{W&&g.value.some(B=>B.key===W)&&s.value!==W&&(s.value=W)}),e.watch(g,W=>{W.length&&!W.some(B=>B.key===s.value)&&(s.value=W[0].key)},{immediate:!0}),e.watch(s,W=>{o.query.tab!==W&&g.value.some(B=>B.key===W)&&n.replace({query:{...o.query,tab:W}})}),e.watch(()=>p.value,W=>{const B=W==null?void 0:W.card_html;_.value=B,T.value=W==null?void 0:W.card_table},{immediate:!0});function be(){x.value&&He(x.value,{bustCache:!0})}async function Pe(W,B){if(x.value){S.value=!0;try{const M=await fetch(`/api/gis-css/${x.value}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)});if(!M.ok)throw new Error(`Failed to save cartocss: ${M.status}`);ye.notify({type:"success",title:"Збережено",message:B}),await He(x.value,{bustCache:!0})}catch(M){console.error("Failed to save CartoCSS",M),ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти CartoCSS"})}finally{S.value=!1}}}function Te(W){if(!W)return null;if(typeof W=="string")try{return JSON.parse(W)}catch(B){return console.warn("Failed to parse CartoCSS config",B),null}return typeof W=="object"?W:null}function ke(W){const B=Array.isArray(W)?W:W==null?void 0:W.datasets;return Array.isArray(B)?B.map((M,X)=>({table:(M==null?void 0:M.table)||(M==null?void 0:M.id)||`dataset_${X+1}`,query:(M==null?void 0:M.query)||"",srid:(M==null?void 0:M.srid)||"",gcol:(M==null?void 0:M.gcol)||"",key:(M==null?void 0:M.key)||(M==null?void 0:M.label)||"Без підпису",active:typeof(M==null?void 0:M.active)=="boolean"?M.active:!0,minzoom:typeof(M==null?void 0:M.zoom)>"u"?"":String(M.zoom),maxzoom:typeof(M==null?void 0:M.maxzoom)>"u"?"":String(M.maxzoom),columns:(M==null?void 0:M.columns)||"",proj4text:(M==null?void 0:M.proj4text)||""})):[]}async function He(W,B){w.value=!0;try{const M=await fetch(`/api/gis-css/${W}`);if(!M.ok)throw new Error(`Failed to load cartocss: ${M.status}`);const X=await M.json(),le=(X==null?void 0:X.message)||X||{};p.value=le,l.value={id:le.cartocss_key||W,name:le.name||l.value.name,description:le.description||l.value.description},$.value=typeof le.style=="string"?le.style:"";const de=Te(le.config??[]);E.value=ke(de);const xe=typeof le.url=="string"?le.url:"";A.value=xe,Z.value=!!(xe&&le.enabled!==!1),R.value=B!=null&&B.bustCache?Date.now():0}catch(M){console.error("Failed to fetch CartoCSS",M),Z.value=!1,A.value="",R.value=0,p.value=null}finally{w.value=!1}}async function ve(){await Pe({style:$.value||"",config:E.value},"CartoCSS оновлено")}async function lt(W){const B=await fetch(`/api/gis-css/${x.value}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)});if(!B.ok)throw new Error(`Failed to save cartocss: ${B.status}`);ye.notify({type:"success",title:"Збережено",message:"Картка CartoCSS оновлена"})}return(W,B)=>(e.openBlock(),e.createElementBlock("div",qw,[e.createElementVNode("div",Hw,[e.createElementVNode("div",Ww,[e.createElementVNode("div",Yw,[e.createElementVNode("div",Zw,[e.createElementVNode("div",Gw,[e.createElementVNode("div",Kw,[e.createElementVNode("button",{type:"button",class:"hover:text-gray-700 cursor-pointer transition-colors",onClick:B[0]||(B[0]=M=>e.unref(n).push("/gis.cartocss"))}," CartoCSS "),B[6]||(B[6]=e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"lucide lucide-chevron-right w-4 h-4 mx-1"},[e.createElementVNode("path",{d:"m9 18 6-6-6-6"})],-1)),e.createElementVNode("span",Xw,e.toDisplayString(l.value.name||"CartoCSS"),1)]),e.createElementVNode("div",Qw,[e.createElementVNode("div",Jw,[e.createElementVNode("div",e2,[e.createElementVNode("h1",t2,e.toDisplayString(l.value.name||"CartoCSS"),1),te.value?(e.openBlock(),e.createElementBlock("div",n2,[e.createElementVNode("span",o2,e.toDisplayString(te.value),1)])):e.createCommentVNode("",!0)]),se.value?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-xs text-gray-500 truncate",title:se.value},e.toDisplayString(se.value),9,r2)):e.createCommentVNode("",!0)])])]),e.createVNode(So,{class:"flex-shrink-0","entity-id":x.value,"entity-info":l.value,"form-endpoint":M=>`/api/form/gis.cartocss.table/${M}`,"save-endpoint":M=>`/api/gis-css/${M}`,"entity-label":"CartoCSS","save-method":"post",onSaved:be},null,8,["entity-id","entity-info","form-endpoint","save-endpoint"])])])]),e.createElementVNode("div",l2,[e.createElementVNode("div",a2,[e.createVNode(Bn,{ref_key:"mapViewRef",ref:r},{default:e.withCtx(()=>{var M,X;return[e.createElementVNode("div",s2,[e.createElementVNode("div",i2,[e.createElementVNode("div",c2,[B[7]||(B[7]=e.createElementVNode("span",null,"Прозорість:",-1)),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":B[1]||(B[1]=le=>I.value=le),type:"range",min:"0",max:"1",step:"0.01",class:"h-1 w-28 cursor-pointer appearance-none rounded-full bg-slate-300 focus:outline-none",style:{"accent-color":"#3b82f6"}},null,512),[[e.vModelText,I.value,void 0,{number:!0}]]),e.createElementVNode("span",null,e.toDisplayString(D.value),1)])]),e.createElementVNode("div",d2,[e.createElementVNode("label",u2,[e.createElementVNode("input",{type:"checkbox",class:"h-3.5 w-3.5 rounded border-slate-300 text-blue-600 focus:ring-blue-200",checked:K.value,onChange:B[2]||(B[2]=le=>K.value=le.target.checked)},null,40,p2),B[8]||(B[8]=e.createElementVNode("span",null,"Межі css",-1))])])]),e.createElementVNode("div",m2,[e.createVNode(Wt)]),e.createElementVNode("div",f2,[e.createVNode(It),z.value?(e.openBlock(),e.createBlock(It,{key:0,targetCenter:z.value,targetLabel:"Центр даних",targetAriaLabel:"Перейти до центру даних"},null,8,["targetCenter"])):e.createCommentVNode("",!0)]),q.value?(e.openBlock(),e.createElementBlock("div",g2," Потягніть на карті, щоб намалювати нові Bounds. Esc скасовує редагування. ")):e.createCommentVNode("",!0),V.value?(e.openBlock(),e.createBlock(Ow,{key:1,"layer-id":Y.value,"tile-url":V.value,active:Z.value,opacity:I.value,title:l.value.name,owner:x.value},null,8,["layer-id","tile-url","active","opacity","title","owner"])):e.createCommentVNode("",!0),e.createVNode(On,{extent:K.value?Q.value:null,"layer-id":v.value},null,8,["extent","layer-id"]),e.createVNode(On,{extent:ne.value,"layer-id":F.value,"line-color":"#0ea5e9","line-width":3},null,8,["extent","layer-id"]),e.createVNode(Uw,{"cartocss-id":x.value,bounds:((M=p.value)==null?void 0:M.bounds)??null,active:Z.value&&!q.value,"info-enabled":(X=p.value)==null?void 0:X.info},null,8,["cartocss-id","bounds","active","info-enabled"]),e.createVNode(io,{"map-id":x.value},null,8,["map-id"])]}),_:1},512)])]),p.value?(e.openBlock(),e.createBlock(Vo,{key:0,open:c.value,onToggle:B[3]||(B[3]=M=>c.value=!c.value)},null,8,["open"])):e.createCommentVNode("",!0)]),p.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["bg-white border-l border-gray-100 flex flex-col overflow-hidden shadow-lg flex-shrink-0 transition-[width] duration-100 ease-in-out",c.value?"w-[650px]":"w-0"])},[e.createElementVNode("div",y2,[g.value.length>1?(e.openBlock(),e.createElementBlock("div",h2,[e.createElementVNode("div",{class:"items-center justify-center text-muted-foreground grid w-full h-12 p-1 bg-gray-50 rounded-xl shadow-sm",style:e.normalizeStyle({gridTemplateColumns:`repeat(${g.value.length}, minmax(0, 1fr))`})},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,M=>(e.openBlock(),e.createElementBlock("button",{key:M.key,type:"button",role:"tab","aria-selected":s.value===M.key,class:e.normalizeClass(["whitespace-nowrap flex flex-col items-center justify-center gap-0.5 py-1 px-1 text-[9px] font-medium transition-all duration-300 hover:bg-white/70 rounded-lg group",s.value===M.key?"bg-white shadow-sm text-gray-700":""]),onClick:X=>s.value=M.key},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(M.icon),{class:"h-3.5 w-3.5 mb-0.5"})),e.createElementVNode("span",b2,e.toDisplayString(M.label),1)],10,x2))),128))],4)])):e.createCommentVNode("",!0),e.createElementVNode("div",k2,[w.value?(e.openBlock(),e.createElementBlock("div",w2," Завантаження стилю… ")):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[s.value==="css"?(e.openBlock(),e.createBlock(Sw,{key:0,modelValue:$.value,"onUpdate:modelValue":B[4]||(B[4]=M=>$.value=M),class:"flex-1 min-h-0",onSave:ve},null,8,["modelValue"])):s.value==="data"?(e.openBlock(),e.createBlock(Iw,{key:1,modelValue:E.value,"onUpdate:modelValue":B[5]||(B[5]=M=>E.value=M),class:"flex-1 min-h-0 flex flex-col",onSave:ve},null,8,["modelValue"])):s.value==="card"?(e.openBlock(),e.createBlock(Rw,{key:2,card:_.value,table:T.value,class:"flex-1 min-h-0",onSave:lt},null,8,["card","table"])):s.value==="metadata"?(e.openBlock(),e.createBlock($o,{key:3,data:p.value,"entity-id":x.value,"entity-type":"css",onSaved:be,onEditCssBounds:G},null,8,["data","entity-id"])):e.createCommentVNode("",!0)],64))])])],2)):e.createCommentVNode("",!0)]))}})},Symbol.toStringTag,{value:"Module"})),V2={class:"rounded-lg border border-gray-200 bg-[rgba(252,252,252,0.8)] p-6"},B2=e.defineComponent({__name:"GeneralSettings",props:{schema:{},modelValue:{},loading:{type:Boolean},form:{}},emits:["update:modelValue","update:form"],setup(t,{emit:n}){const o=e.defineAsyncComponent(()=>import("@opengis/form")),r=t,a=n,i=e.computed({get:()=>r.modelValue,set:c=>a("update:modelValue",c)}),s=e.computed({get:()=>r.form,set:c=>a("update:form",c)});return(c,p)=>(e.openBlock(),e.createElementBlock("section",V2,[p[2]||(p[2]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-800 mb-4"}," Основна інформація ",-1)),t.loading?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(o),{key:0,schema:t.schema,values:i.value,"onUpdate:values":p[0]||(p[0]=g=>i.value=g),form:s.value,"onUpdate:form":p[1]||(p[1]=g=>s.value=g)},null,8,["schema","values","form"]))]))}}),$2={class:"rounded-lg border border-gray-200 bg-[rgba(252,252,252,0.8)] p-6"},S2=e.defineComponent({__name:"LayerSettings",props:{layerIDs:{},options:{}},emits:["update:layerIDs"],setup(t,{emit:n}){const o=t,r=n,a=e.computed({get:()=>o.layerIDs,set:i=>r("update:layerIDs",i)});return(i,s)=>(e.openBlock(),e.createElementBlock("section",$2,[s[1]||(s[1]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-800 mb-4"},"Шари",-1)),s[2]||(s[2]=e.createElementVNode("label",{class:"block text-sm font-medium text-gray-700 mb-2"},"Доступні шари",-1)),e.createVNode(e.unref(Do.VsInputArraySelect),{data:"layer_list",api:"/api/suggest/layer_list",modelValue:a.value,"onUpdate:modelValue":s[0]||(s[0]=c=>a.value=c),placeholder:"Шари"},null,8,["modelValue"])]))}}),v2={class:"w-full"},L2=e.defineComponent({__name:"MapPreview",props:{id:{}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",v2,[e.createVNode(Tn,{class:"w-full h-[calc(100vh-200px)]",height:"h-[calc(100vh-200px)]",id:t.id},null,8,["id"])]))}}),A2={class:"bg-white rounded-lg shadow-xl w-full max-w-4xl flex flex-col h-[80vh] m-4"},T2={class:"flex items-center justify-between px-6 py-4 border-b border-gray-200"},M2={key:0,class:"absolute top-0 left-0 right-0 bg-red-100 text-red-700 text-sm px-4 py-2 z-10 border-b border-red-200"},F2={class:"flex-1 overflow-hidden relative bg-[#fffffe]"},D2={class:"px-6 py-4 border-t border-gray-200 flex justify-end gap-3"},z2=["disabled"],I2=e.defineComponent({__name:"ConfigEditor",props:{modelValue:{}},emits:["update:modelValue","save"],setup(t,{emit:n}){const o=t,r=n,a=e.ref(""),i=e.ref(null);e.watch(()=>o.modelValue,p=>{if(p){try{a.value=JSON.stringify(p,null,2)}catch{a.value="{}"}i.value=null}},{immediate:!0}),e.watch(a,p=>{if(!p.trim()){i.value=null;return}try{JSON.parse(p),i.value=null}catch(g){i.value=g.message}}),e.watch(()=>o.modelValue,()=>{setTimeout(()=>{const{monaco:p}=window;if(p&&p.editor){const g=p.editor.getEditors();g.length>0&&g[g.length-1].updateOptions({wordWrap:"on"})}},300)},{immediate:!0});function s(){r("update:modelValue",null),a.value="",i.value=null}function c(){if(!i.value)try{const p=JSON.parse(a.value);r("save",p),s()}catch(p){console.error("Failed to parse JSON",p)}}return(p,g)=>t.modelValue!==null?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 flex items-center justify-center bg-black/50 backdrop-blur-sm",onClick:e.withModifiers(s,["self"])},[e.createElementVNode("div",A2,[e.createElementVNode("div",T2,[g[1]||(g[1]=e.createElementVNode("h3",{class:"text-lg font-semibold text-gray-800"}," Редагування конфігурації (JSON) ",-1)),e.createElementVNode("button",{onClick:s,class:"text-gray-500 hover:text-gray-700 transition-colors"},[e.createVNode(e.unref(ce.X),{size:20})])]),i.value?(e.openBlock(),e.createElementBlock("div",M2," Помилка JSON: "+e.toDisplayString(i.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",F2,[e.createVNode(kn,{modelValue:a.value,"onUpdate:modelValue":g[0]||(g[0]=x=>a.value=x),language:"json",theme:"vs-light",class:"w-full h-full"},null,8,["modelValue"])]),e.createElementVNode("div",D2,[e.createElementVNode("button",{onClick:s,class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 transition-colors"}," Скасувати "),e.createElementVNode("button",{onClick:c,disabled:!!i.value,class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 transition-colors disabled:opacity-50 disabled:cursor-not-allowed"}," Зберегти ",8,z2)])])])):e.createCommentVNode("",!0)}}),P2={key:0,class:"text-center py-8 text-gray-500 border rounded-lg bg-[rgba(252,252,252,0.8)]"},j2={key:1,class:"rounded-lg border border-gray-200 overflow-hidden"},R2={class:"w-full text-sm"},O2={class:"divide-y divide-gray-200"},U2={class:"px-4 py-3"},q2=["onUpdate:modelValue","onChange"],H2=["value"],W2={class:"px-4 py-3"},Y2=["onUpdate:modelValue","onChange"],Z2=["value"],G2={class:"px-4 py-3 text-center"},K2=["checked","onChange"],X2={class:"px-4 py-3"},Q2={key:0,class:"flex items-center gap-2"},J2=["onClick"],e_=["onClick"],t_={key:1},n_=["onClick"],o_={class:"px-4 py-3 text-right"},r_=["onClick"],l_=e.defineComponent({__name:"WidgetSettings",props:{modelValue:{}},emits:["update:modelValue"],setup(t,{emit:n}){const o=t,r=n,a=["catalog","legend","basemaps","info","layers","dataset","filters","search"],i=["top-left","top-right","bottom-left","bottom-right"],s=e.ref(null),c=e.ref(-1),p=e.computed(()=>o.modelValue||[]);function g(){const m=[...p.value,{type:"info",position:"top-left",visible:!0,config:{}}];r("update:modelValue",m)}function x(m){ye.confirm({title:"Видалити віджет?",message:"Ви впевнені, що хочете видалити цей віджет?",type:"warning",onConfirm:()=>{const h=p.value.filter((k,N)=>N!==m);r("update:modelValue",h)}})}function l(m,h,k){const N=[...p.value];N[m]={...N[m],[h]:k},r("update:modelValue",N)}function y(m){return!!m&&Object.keys(m).length>0}function d(m,h){c.value=m,s.value=h||{}}function u(m){d(m,{})}function b(m){ye.confirm({title:"Видалити конфігурацію?",message:"Ви впевнені, що хочете видалити конфігурацію цього віджета?",type:"warning",onConfirm:()=>{l(m,"config",void 0)}})}function f(m){c.value>-1&&l(c.value,"config",m),s.value=null,c.value=-1}return(m,h)=>{var k;return e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",{class:"flex items-center justify-between mb-4"},[h[1]||(h[1]=e.createElementVNode("h2",{class:"text-lg font-semibold text-gray-800"},"Віджети",-1)),e.createElementVNode("button",{onClick:g,class:"px-3 py-1.5 text-sm bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors"}," + Додати віджет ")]),(k=p.value)!=null&&k.length?(e.openBlock(),e.createElementBlock("div",j2,[e.createElementVNode("table",R2,[h[2]||(h[2]=e.createElementVNode("thead",{class:"bg-[rgba(252,252,252,0.8)] border-b border-gray-200"},[e.createElementVNode("tr",null,[e.createElementVNode("th",{class:"px-4 py-3 text-left font-medium text-gray-700 w-1/4"},"Тип"),e.createElementVNode("th",{class:"px-4 py-3 text-left font-medium text-gray-700 w-1/4"},"Розташування"),e.createElementVNode("th",{class:"px-4 py-3 text-center font-medium text-gray-700 w-24"},"Видимість"),e.createElementVNode("th",{class:"px-4 py-3 text-left font-medium text-gray-700"},"Конфігурація"),e.createElementVNode("th",{class:"px-4 py-3 text-right font-medium text-gray-700 w-24"},"Дії")])],-1)),e.createElementVNode("tbody",O2,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(N,$)=>(e.openBlock(),e.createElementBlock("tr",{key:$,class:"hover:bg-gray-50"},[e.createElementVNode("td",U2,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E=>N.type=E,onChange:E=>l($,"type",N.type),class:"w-full px-2 py-1.5 bg-white border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 text-gray-700"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,E=>e.createElementVNode("option",{key:E,value:E},e.toDisplayString(E),9,H2)),64))],40,q2),[[e.vModelSelect,N.type]])]),e.createElementVNode("td",W2,[e.withDirectives(e.createElementVNode("select",{"onUpdate:modelValue":E=>N.position=E,onChange:E=>l($,"position",N.position),class:"w-full px-2 py-1.5 bg-white border border-gray-300 rounded focus:outline-none focus:ring-1 focus:ring-blue-500 text-gray-700"},[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(i,E=>e.createElementVNode("option",{key:E,value:E},e.toDisplayString(E),9,Z2)),64))],40,Y2),[[e.vModelSelect,N.position]])]),e.createElementVNode("td",G2,[e.createElementVNode("input",{type:"checkbox",checked:N.visible!==!1,onChange:E=>l($,"visible",E.target.checked),class:"w-4 h-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500"},null,40,K2)]),e.createElementVNode("td",X2,[y(N.config)?(e.openBlock(),e.createElementBlock("div",Q2,[e.createElementVNode("button",{onClick:E=>d($,N.config),class:"p-1 text-blue-600 hover:text-blue-800 hover:bg-blue-50 rounded transition-colors",title:"Редагувати конфігурацію"},[e.createVNode(e.unref(ce.Pen),{size:16})],8,J2),e.createElementVNode("button",{onClick:E=>b($),class:"p-1 text-red-500 hover:text-red-700 hover:bg-red-50 rounded transition-colors",title:"Видалити конфігурацію"},[e.createVNode(e.unref(ce.X),{size:16})],8,e_)])):(e.openBlock(),e.createElementBlock("div",t_,[e.createElementVNode("button",{onClick:E=>u($),class:"p-1 text-green-600 hover:text-green-800 hover:bg-green-50 rounded transition-colors",title:"Додати конфігурацію"},[e.createVNode(e.unref(ce.Plus),{size:16})],8,n_)]))]),e.createElementVNode("td",o_,[e.createElementVNode("button",{onClick:E=>x($),class:"p-1 text-gray-400 hover:text-red-500 transition-colors",title:"Видалити віджет"},[e.createVNode(e.unref(ce.Trash2),{size:16})],8,r_)])]))),128))])])])):(e.openBlock(),e.createElementBlock("div",P2," Немає віджетів. Додайте перший віджет. ")),e.createVNode(I2,{teleport:"#modal",modelValue:s.value,"onUpdate:modelValue":h[0]||(h[0]=N=>s.value=N),onSave:f},null,8,["modelValue"])])}}}),a_={class:"relative h-full flex flex-col flex-1 min-h-0 overflow-hidden mx-auto w-full"},s_={class:"mx-1"},i_={class:"text-gray-900 font-semibold"},c_=["disabled"],d_={key:0,class:"text-center py-12 mt-6 px-[24px]"},u_={key:1,class:"px-[24px] overflow-y-auto"},p_={class:"space-y-6"},m_={class:"space-y-6"},f_={class:"space-y-6"},g_=Object.freeze(Object.defineProperty({__proto__:null,default:Ce(e.defineComponent({__name:"MapSettings",setup(t){const n=Fe.useRouter(),o=Fe.useRoute(),r=e.computed(()=>{var E;return((E=n.resolve("/gis.maps").meta)==null?void 0:E.title)??"Карти"}),a=e.ref(!0),i=e.ref(!1),s=e.ref({}),c=e.ref({}),p=[{name:"Загальна",id:"general"},{name:"Шари",id:"layers"},{name:"Віджети",id:"widgets"},{name:"Карта",id:"map"}],g=p.map(E=>E.id),x=E=>E?Array.isArray(E)?E[0]:E:null,l=(()=>{const E=x(o.query.tab);return E&&g.includes(E)?E:"general"})(),y=e.ref(l);e.watch(()=>o.query.tab,E=>{const w=x(E);w&&g.includes(w)&&y.value!==w&&(y.value=w)}),e.watch(y,E=>{o.query.tab!==E&&n.replace({query:{...o.query,tab:E}})});const d=e.ref({name:"",map_key:"",description:"",holder:"",image:"",keywords:[],center:null,zoom:11,widgets:[],layers:[]}),u=e.computed({get:()=>(d.value.layers||[]).map(E=>E.id||E),set:E=>{d.value.layers=E}});async function b(E){if(!E.length){c.value={};return}try{const w=new URLSearchParams({json:"1",val:Array.from(new Set(E)).join(",")}),S=await fetch(`/api/suggest/layer_list?${w.toString()}`);if(!S.ok)return;const A=await S.json(),R=(A==null?void 0:A.data)??A??[],Z=Array.isArray(R)?R:[],I={...c.value};Z.forEach(K=>{const q=K.id!=null?String(K.id):"";q&&(I[q]=K.text??K.name??q)}),c.value=I}catch(w){console.error("Failed to fetch layer labels:",w)}}const f=e.computed({get:()=>u.value.map(E=>c.value[E]??E),set:E=>{const w=Object.entries(c.value).reduce((A,[R,Z])=>(A[Z]=R,A),{}),S=E.map(A=>w[A]??null).filter(A=>A!=null);u.value=S}}),m=e.computed(()=>{const E=d.value.center;if(!Array.isArray(E)||E.length<2)return"Не задано";const[w,S]=E;return w===void 0||S===void 0||w===null||S===null||Number.isNaN(Number(w))||Number.isNaN(Number(S))?"Не задано":`Lng ${Number(w).toFixed(6)}, Lat ${Number(S).toFixed(6)}`}),h=e.computed(()=>{const E=d.value.zoom;if(E==null||E==="")return"Не задано";const w=Number(E);return Number.isNaN(w)?"Не задано":w.toFixed(2)}),k=[{name:"name",type:"text",label:"Назва",col:6,validators:["required"]},{name:"map_key",type:"text",label:"Унікальний ключ",col:6,validators:["required"]},{name:"description",type:"textarea",label:"Опис",col:12},{name:"holder",type:"text",label:"Власник/Утримувач/Відповідальний",col:6},{name:"keywords",type:"Tags",label:"Ключові слова",placeholder:"Введіть тег та натисніть Enter",col:6},{name:"center",type:"array",label:"Центр",inputType:"number",limit:2,count:2,col:6},{name:"zoom",type:"number",label:"Зум",col:6,validators:["required"]},{name:"is_public",type:"switcher",label:"Чи публічна карта?",col:6,data:"yes_no"},{name:"is_active",type:"switcher",label:"Чи активна?",col:6,data:"yes_no"},{name:"image",type:"File",label:"Фото",col:12}];async function N(){try{const w=await(await fetch(`/api/gis-map/${o.params.id}?original=1`)).json();d.value={...w,keywords:w.keywords||[],center:w.center??null,widgets:Array.isArray(w.widgets)?w.widgets:[],layers:(w.layers||[]).map(S=>S.id||S)},await b(d.value.layers??[])}catch(E){console.error("Failed to load map:",E),ye.notify({type:"error",title:"Помилка",message:"Не вдалося завантажити карту"})}finally{a.value=!1}}async function $(){var w,S;const E=(S=(w=s.value)==null?void 0:w.validate)==null?void 0:S.call(w);if(E){ye.notify({type:"warning",title:"Валідація",message:Object.entries(E).map(([A,R])=>`${A}: ${R}`).join(`
44
44
  `)});return}i.value=!0;try{const A=JSON.parse(JSON.stringify(d.value));if(A.zoom=Number(A.zoom),Array.isArray(A.center)&&(A.center.every(I=>I==null||I===""||I===0)||A.center.length===0)&&(A.center=null),delete A.created_at,delete A.updated_at,delete A.created_by,delete A.updated_by,delete A.history,delete A.maps,!(await fetch(`/api/gis-map/${o.params.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(A)})).ok)throw new Error("Save failed");ye.notify({type:"success",title:"Успіх",message:"Збережено!"})}catch(A){console.error("Save error:",A),ye.notify({type:"error",title:"Помилка",message:"Не вдалося зберегти"})}finally{i.value=!1}}return e.watch(()=>{var E;return((E=d.value)==null?void 0:E.layers)??[]},E=>b(Array.isArray(E)?E.map(w=>(w==null?void 0:w.id)??w):[]),{immediate:!1}),e.onMounted(async()=>{await N()}),(E,w)=>{const S=e.resolveComponent("router-link");return e.openBlock(),e.createElementBlock("div",a_,[e.createVNode(Yt,{variant:"form",title:d.value.name||"Налаштування карти"},{breadcrumbs:e.withCtx(()=>[e.createVNode(S,{to:"/gis.maps",class:"text-gray-500 hover:text-gray-700"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(r.value),1)]),_:1}),e.createElementVNode("span",s_,[e.createVNode(e.unref(ce.LucideChevronRight),{size:16,class:"shrink-0"})]),e.createElementVNode("span",i_,e.toDisplayString(d.value.name||"Налаштування карти"),1)]),description:e.withCtx(()=>[...w[6]||(w[6]=[e.createTextVNode("Редагування параметрів карти",-1)])]),actions:e.withCtx(()=>[e.createElementVNode("button",{onClick:w[0]||(w[0]=A=>e.unref(n).back()),class:"inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50"}," Повернутися "),e.createElementVNode("button",{onClick:$,disabled:i.value,class:"inline-flex items-center justify-center px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-md hover:bg-blue-700 disabled:opacity-50"},e.toDisplayString(i.value?"Збереження...":"Зберегти"),9,c_)]),_:1},8,["title"]),a.value?(e.openBlock(),e.createElementBlock("div",d_,[...w[7]||(w[7]=[e.createElementVNode("p",{class:"text-gray-500"},"Завантаження...",-1)])])):(e.openBlock(),e.createElementBlock("div",u_,[e.createVNode(mr,{tabs:p,activeTab:y.value,"onUpdate:activeTab":w[1]||(w[1]=A=>y.value=A)},null,8,["activeTab"]),e.withDirectives(e.createElementVNode("div",p_,[e.createVNode(B2,{schema:k,loading:a.value,modelValue:d.value,"onUpdate:modelValue":w[2]||(w[2]=A=>d.value=A),form:s.value,"onUpdate:form":w[3]||(w[3]=A=>s.value=A)},null,8,["loading","modelValue","form"])],512),[[e.vShow,y.value==="general"]]),e.withDirectives(e.createElementVNode("div",m_,[e.createVNode(S2,{layerIDs:u.value,"onUpdate:layerIDs":w[4]||(w[4]=A=>u.value=A)},null,8,["layerIDs"])],512),[[e.vShow,y.value==="layers"]]),e.withDirectives(e.createVNode(l_,{modelValue:d.value.widgets,"onUpdate:modelValue":w[5]||(w[5]=A=>d.value.widgets=A)},null,8,["modelValue"]),[[e.vShow,y.value==="widgets"]]),e.withDirectives(e.createElementVNode("div",f_,[e.createVNode(L2,{"center-display":m.value,"zoom-display":h.value,"layer-names":f.value,id:e.unref(o).params.id},null,8,["center-display","zoom-display","layer-names","id"])],512),[[e.vShow,y.value==="map"]])]))])}}}),[["__scopeId","data-v-df90fbac"]])},Symbol.toStringTag,{value:"Module"}));Ye.CartoCSS=Hl,Ye.Classifiers=ss,Ye.MapSettings=Ql,Ye.MapWidget=Tn,Ye.Permissions=As,Ye.Raster=Ol,Ye.Register=Dl,Ye.Service=Pl,Ye.default=Tn,Ye.install=wf,Ye.template1=rr,Ye.template2=lr,Ye.template3=ar,Ye.template4=sr,Ye.template5=ir,Object.defineProperties(Ye,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));