@opengis/form 0.0.157 → 0.0.159

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.
@@ -1,7 +1,7 @@
1
1
  (function(be,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@opengis/core"),require("lucide-vue-next")):typeof define=="function"&&define.amd?define(["exports","vue","@opengis/core","lucide-vue-next"],e):(be=typeof globalThis<"u"?globalThis:be||self,e(be.FormBuilder={},be.Vue,be.OpenGISCore,be.lucide))})(this,function(be,e,he,P){"use strict";const _o=e.defineComponent({__name:"vs-info-tooltip",props:{text:{}},setup(o){const t=o,n=e.ref(!1),r=e.ref({top:"0px",left:"0px"});function l(s){if(!t.text)return;const i=s.currentTarget.getBoundingClientRect();r.value={top:`${i.bottom+4}px`,left:`${Math.min(i.left,window.innerWidth-230)}px`},n.value=!0}function a(){n.value=!1}return(s,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("span",{class:"inline-flex items-center",onMouseenter:l,onMouseleave:a},[e.renderSlot(s.$slots,"default",{},()=>[e.createVNode(e.unref(P.Info),{class:"h-4 w-4 text-gray-400 cursor-help"})])],32),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.value&&s.text?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle(r.value),class:"fixed z-[9999] max-w-xs p-2 bg-gray-900 text-white text-xs rounded-lg shadow-lg pointer-events-none"},e.toDisplayString(s.text),5)):e.createCommentVNode("",!0)]))],64))}}),Yr={class:"w-full relative"},Xr={key:0,class:"text-[14px] font-medium text-gray-900 mb-2 flex items-center gap-1"},Zr={class:"opacity-100"},Jr={key:0,class:"text-red-500 text-[14px]"},Qr={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},el=e.defineComponent({__name:"vs-layout-default",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.computed(()=>typeof t.item?.label=="string"&&t.item.label?t.item.label:t.item?.ua||t.label||t.ua),r=e.computed(()=>!!n.value),l=e.computed(()=>!!t.item?.rules?.includes("required")),a=e.computed(()=>t.item?.info||"");return(s,i)=>(e.openBlock(),e.createElementBlock("div",Yr,[r.value?(e.openBlock(),e.createElementBlock("div",Xr,[e.createElementVNode("span",Zr,e.toDisplayString(n.value),1),l.value?(e.openBlock(),e.createElementBlock("span",Jr,"*")):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(_o,{key:1,text:a.value},null,8,["text"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"default",e.mergeProps(s.$attrs,{class:{"opacity-60":s.item.disabled}})),s.error?(e.openBlock(),e.createElementBlock("span",Qr,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0)]))}}),tl={class:"w-full relative flex flex-row items-center gap-2"},nl={key:0,class:"text-red-500 text-[14px]"},ol={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},rl=e.defineComponent({__name:"vs-layout-horizontal",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{default:()=>({container:12,label:3})}},setup(o){const t=o,n=e.computed(()=>t.item?.label||t.label||t.ua),r=e.computed(()=>t.item?.info||""),l=e.computed(()=>t.columns??{container:12,label:3}),a=e.computed(()=>{const{container:d,label:u}=l.value;return!d||d<=0?0:Math.min(Math.max(u??0,0),d)/d}),s=e.computed(()=>t.item?.type==="html"||a.value<=0?!1:!!n.value),i=e.computed(()=>{if(!s.value)return{};const d=`${a.value*100}%`;return{flexBasis:d,maxWidth:d}}),c=e.computed(()=>{const{container:d,label:u}=l.value;if(!d||d<=0)return{};if(t.item?.type==="html")return{flexBasis:"100%",maxWidth:"100%"};if(!s.value)return{flexBasis:"100%",maxWidth:"100%"};const p=Math.max(d-Math.max(u??0,0),0)/d;if(!p)return{};const h=`${p*100}%`;return{flexBasis:h,maxWidth:h}});return(d,u)=>(e.openBlock(),e.createElementBlock("div",tl,[s.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"text-sm text-gray-900 font-medium flex shrink-0 items-center gap-1",style:e.normalizeStyle(i.value)},[e.createTextVNode(e.toDisplayString(n.value)+" ",1),d.item?.rules?.includes("required")&&n.value?(e.openBlock(),e.createElementBlock("span",nl,"*")):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createBlock(_o,{key:1,text:r.value},null,8,["text"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"flex-1 min-w-0",style:e.normalizeStyle(c.value)},[e.renderSlot(d.$slots,"default",e.normalizeProps(e.guardReactiveProps(d.$attrs)))],4),d.error?(e.openBlock(),e.createElementBlock("span",ol,e.toDisplayString(d.error),1)):e.createCommentVNode("",!0)]))}}),ll={class:"w-full relative"},al={key:0,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},sl=e.defineComponent({__name:"vs-layout-inline",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",ll,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(t.$attrs))),t.error?(e.openBlock(),e.createElementBlock("span",al,e.toDisplayString(t.error),1)):e.createCommentVNode("",!0)]))}}),il={class:"flex-1 min-w-0"},cl={key:0,class:"text-sm font-medium text-slate-700 dark:text-slate-200 flex items-center gap-1"},dl={class:"truncate"},ul={key:0,class:"text-red-500 text-[14px]"},pl=["innerHTML"],fl={key:0,class:"mt-1 text-xs text-red-500"},ml={default:el,horizontal:rl,inline:sl,settings:e.defineComponent({__name:"vs-layout-settings",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.ref("uk");e.computed(()=>(t.item??{})?.[n.value]??t.ua??t.label??"");const r=e.computed(()=>t.item?.description??""),l=e.computed(()=>Array.isArray(t.item?.rules)&&t.item.rules.includes("required")),a=e.computed(()=>(typeof t.error=="string"?t.error:"")??""),s=()=>{const i=typeof localStorage<"u"?localStorage.getItem("locale"):null;n.value=i||"uk"};return e.onMounted(()=>{try{typeof localStorage<"u"&&localStorage.locale&&(n.value=localStorage.locale)}catch{}window.addEventListener("storage",s)}),e.onUnmounted(()=>{window.removeEventListener("storage",s)}),(i,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-full relative",{"opacity-60":i.item?.disabled}])},[e.createElementVNode("div",{class:e.normalizeClass(["gap-2 md:flex-row md:items-center md:justify-between",[["switcher","native-select"].includes(i.item.type)?"flex flex-col":""]])},[e.createElementVNode("div",il,[i.ua||i.label?(e.openBlock(),e.createElementBlock("p",cl,[e.createElementVNode("span",dl,e.toDisplayString(i.item[n.value]||i.ua||i.label),1),l.value?(e.openBlock(),e.createElementBlock("span",ul,"*")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createElementBlock("p",{key:1,class:"text-xs text-slate-500 dark:text-slate-400",innerHTML:r.value},null,8,pl)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["w-full",["select","native-select"].includes(i.item.type)?"md:w-[30%]":"md:w-auto"])},[e.renderSlot(i.$slots,"default",e.normalizeProps(e.guardReactiveProps(i.$attrs)))],2)],2),a.value?(e.openBlock(),e.createElementBlock("p",fl,e.toDisplayString(a.value),1)):e.createCommentVNode("",!0)],2))}})};function ze(o){return{inputClass:e.computed(()=>{const n=`disabled:opacity-50 disabled:cursor-not-allowed outline-none focus:ring-2 focus:ring-ring focus:ring-${o?.primaryColor||"blue"}-500 border border-solid border-stone-200 rounded-md text-sm text-stone-800 placeholder:text-stone-400 `;return o?.size==="sm"?`${n}h-[32px]`:`${n}h-[38px]`})}}const hl=["placeholder","disabled"],gl=e.defineComponent({__name:"vs-input-password",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=ze(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");return(s,i)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"password","onUpdate:modelValue":i[0]||(i[0]=c=>r.value=c),placeholder:a.value,disabled:l.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":s.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,hl)),[[e.vModelText,r.value]])}}),yl=["placeholder","disabled","maxlength","minlength"],Ot=e.defineComponent({__name:"vs-input-text",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=ze(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??""),s=e.computed(()=>t.maxlength??void 0),i=e.computed(()=>t.minlength??void 0);function c(){typeof r.value=="string"&&(r.value=r.value.trim())}return(d,u)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"text","onUpdate:modelValue":u[0]||(u[0]=p=>r.value=p),placeholder:a.value,disabled:l.value,maxlength:s.value,minlength:i.value,onBlur:c,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[d.customClass,e.unref(n),{"!border-red-600":d.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,yl)),[[e.vModelText,r.value]])}}),bl=["step","placeholder","disabled","min","max"],Co=e.defineComponent({__name:"vs-input-number",props:e.mergeModels({style:{type:Object,default:()=>({})},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},min:{type:Number,default:void 0},max:{type:Number,default:void 0},step:{type:[Number,String],default:void 0}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=ze(t.style),r=e.useAttrs(),l=e.useModel(o,"modelValue"),a=e.computed(()=>!!t.disabled),s=u=>{if(u==null||u==="")return;const p=typeof u=="string"?u.trim().replace(",","."):u,h=Number(p);return Number.isFinite(h)?h:void 0},i=e.computed(()=>s(t.min??r.min)),c=e.computed(()=>s(t.max??r.max)),d=e.computed(()=>{if(t.step!==void 0&&t.step!==null&&t.step!=="")return t.step;const u=r.step;return typeof u=="number"||typeof u=="string"?u:"any"});return(u,p)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"number",step:d.value,"onUpdate:modelValue":p[0]||(p[0]=h=>l.value=h),placeholder:o.placeholder,disabled:a.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"},min:i.value,max:c.value},null,10,bl)),[[e.vModelText,l.value]])}}),sn=o=>!!String(o??"").trim(),Et=o=>o?.color?String(o.color):"",Ut=o=>{const t=o?.icon;if(typeof t=="string")return t;const n=o?.imgUrl;return typeof n=="string"?n:""},Ht=o=>{const t=o?.icon;return t&&typeof t!="string"?t:null},kl={class:"flex items-center gap-[4px]"},xl=["value","id","disabled"],wl=["for"],_l=["innerHTML"],Cl={key:1,class:"text-[14px] text-gray-700 flex items-center gap-2 dark:text-neutral-400"},vl=["src"],El=e.defineComponent({__name:"vs-checkbox-default",props:{value:{default:""},label:{default:""},html:{default:""},disabled:{type:Boolean,default:!1},id:{},modelValue:{default:""},info:{},error:{},option:{default:null}},emits:["update:modelValue"],setup(o,{emit:t}){const n=t,r=o,l=e.computed({get:()=>r.modelValue,set:x=>n("update:modelValue",x)}),a=e.computed(()=>!!r.disabled),s=e.computed(()=>Ut(r.option)),i=e.computed(()=>Ht(r.option)),c=e.computed(()=>Et(r.option)),d=e.computed(()=>!!(c.value&&!s.value&&!i.value)),u=e.computed(()=>!!(s.value&&c.value)),p=e.computed(()=>c.value?{color:c.value}:void 0),h=e.computed(()=>{if(!(!s.value||!c.value))return{backgroundColor:c.value,WebkitMaskImage:`url(${s.value})`,maskImage:`url(${s.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(x,m)=>(e.openBlock(),e.createElementBlock("div",kl,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",value:x.value,"onUpdate:modelValue":m[0]||(m[0]=b=>l.value=b),class:e.normalizeClass(["shrink-0 border border-solid hidden border-gray-700 w-3.5 h-3.5 rounded text-blue-600 focus:ring-offset-0 dark:bg-neutral-800 dark:border-neutral-700 cursor-pointer",{"!cursor-not-allowed":a.value}]),id:x.id,disabled:a.value},null,10,xl),[[e.vModelCheckbox,l.value]]),e.createElementVNode("label",{for:x.id,class:e.normalizeClass(["flex flex-1 checkbox-label items-center gap-x-2 cursor-pointer text-sm text-gray-800 dark:text-neutral-300",{"!cursor-not-allowed":a.value}])},[e.createElementVNode("div",{class:e.normalizeClass(["h-[16px] text-white w-[16px] flex items-center justify-center shrink-0 border rounded",[l.value?"bg-blue-600 border-blue-600":"bg-white border-gray-600",x.error?"border-red-600":""]])},[e.createVNode(e.unref(P.Check),{class:"h-4 w-4"})],2),x.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:x.html},null,8,_l)):(e.openBlock(),e.createElementBlock("span",Cl,[d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:c.value})},null,4)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(h.value)},null,4)):s.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:s.value,alt:"icon"},null,8,vl)):i.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(p.value)},null,8,["style"])):e.createCommentVNode("",!0),e.renderSlot(x.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(x.label),1)])]))],10,wl)]))}}),Bl=["name","value","disabled"],Vl=["innerHTML"],Sl={key:1,class:"flex items-center gap-[6px] text-[14px]"},$l={key:2,class:"text-[16px] inline-flex items-center justify-center"},Nl=["src"],Al=e.defineComponent({__name:"vs-checkbox-buttons",props:{value:{type:[String,Number,Boolean],default:""},label:{default:""},html:{default:""},modelValue:{default:""},disabled:{type:Boolean},id:{},icon:{},imgUrl:{},style:{},option:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=e.computed({get:()=>n.modelValue,set:b=>{r("update:modelValue",b)}}),a=e.computed(()=>Array.isArray(l.value)?l.value.includes(n.value):l.value===!0||l.value===n.value),s=e.computed(()=>n.style?.size==="xs"?"p-1.5 text-xs":n.style?.size==="lg"?"p-3.5 text-[20px]":"p-2.5 text-xs"),i=e.computed(()=>({...n.option??{},icon:n.option?.icon??n.icon,imgUrl:n.option?.imgUrl??n.imgUrl,color:n.option?.color})),c=e.computed(()=>Ut(i.value)),d=e.computed(()=>Ht(i.value)),u=e.computed(()=>Et(i.value)),p=e.computed(()=>!!(u.value&&!c.value&&!d.value)),h=e.computed(()=>!!(c.value&&u.value)),x=e.computed(()=>u.value?{color:u.value}:void 0),m=e.computed(()=>{if(!(!c.value||!u.value))return{backgroundColor:u.value,WebkitMaskImage:`url(${c.value})`,maskImage:`url(${c.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(b,g)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["group relative flex justify-center items-center gap-x-3 text-center bg-white text-gray-800 ring-ring ring-2 cursor-pointer rounded-lg",[s.value,a.value?"ring-blue-500":"border border-gray-200 ring-transparent"]])},[e.withDirectives(e.createElementVNode("input",{type:"checkbox",class:"hidden",name:b.id,value:b.value,"onUpdate:modelValue":g[0]||(g[0]=C=>l.value=C),disabled:b.disabled},null,8,Bl),[[e.vModelCheckbox,l.value]]),b.html?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-full",innerHTML:b.html},null,8,Vl)):(e.openBlock(),e.createElementBlock("span",Sl,[p.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:u.value})},null,4)):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(m.value)},null,4)):c.value||d.value?(e.openBlock(),e.createElementBlock("span",$l,[c.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:c.value,width:"16",height:"16",alt:"icon"},null,8,Nl)):d.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),{key:1,class:"h-4 w-4",style:e.normalizeStyle(x.value)},null,8,["style"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(b.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(b.label),1)])]))],2))}}),Fl={class:"flex items-center"},On=e.defineComponent({__name:"vs-input-checkbox-item",props:{value:{default:""},label:{default:""},labelHtml:{default:""},disabled:{type:Boolean,default:!1},view:{default:"default"},modelValue:{type:[Boolean,Array],default:!1},icon:{},imgUrl:{},slots:{},option:{},style:{},error:{default:""}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=`radio-${Math.floor(Math.random()*1e4)}`,a=e.computed({get:()=>Array.isArray(n.modelValue)?Array.isArray(n.modelValue)&&n.modelValue.includes(n.value):n.modelValue,set:i=>{if(Array.isArray(n.modelValue)){let c=[...n.modelValue];i?c.includes(n.value)||c.push(n.value):c=c.filter(d=>d!==n.value),r("update:modelValue",c)}else r("update:modelValue",i)}}),s=e.ref(`vs-checkbox-${n.view||"default"}`);return(i,c)=>(e.openBlock(),e.createElementBlock("div",Fl,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value==="vs-checkbox-buttons"?e.unref(Al):e.unref(El)),{value:i.value,label:i.label,html:i.labelHtml,info:i.option?.info,disabled:i.disabled,modelValue:a.value,"onUpdate:modelValue":c[0]||(c[0]=d=>a.value=d),id:l,icon:i.icon,imgUrl:i.imgUrl,option:i.option,style:e.normalizeStyle(i.style),error:i.error},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.label),1)]),_:1},8,["value","label","html","info","disabled","modelValue","icon","imgUrl","option","style","error"]))]))}}),Ml={key:0,class:"flex items-start gap-x-1"},Dl={key:0,class:"text-red-500 text-[14px]"},Tl=["title"],Ll=["disabled"],zn=e.defineComponent({__name:"vs-input-switcher",props:e.mergeModels({rules:{default:()=>[]},view:{default:"checkbox"},label:{default:""},i:{default:""},text:{default:""},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue");return(r,l)=>t.view==="checkbox"?(e.openBlock(),e.createElementBlock("div",Ml,[e.createVNode(On,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),error:r.error||""},null,8,["modelValue","error"]),r.rules?.includes("required")?(e.openBlock(),e.createElementBlock("span",Dl,"*")):e.createCommentVNode("",!0),r.i?(e.openBlock(),e.createElementBlock("button",{key:1,class:"cursor-pointer",title:r.i,onClick:l[1]||(l[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(e.unref(P.Info),{class:"h-4 w-4 text-gray-500"})],8,Tl)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["inline-flex h-5 w-9 shrink-0 px-[2px] cursor-pointer items-center rounded-full shadow-sm disabled:cursor-not-allowed disabled:opacity-50",[n.value?`bg-${r.style?.primaryColor||"blue"}-500`:"bg-stone-200",r.customClass]]),disabled:r.disabled,onClick:l[2]||(l[2]=a=>n.value=!n.value)},[e.createElementVNode("span",{"data-state":"checked",class:e.normalizeClass(["pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform",[n.value?"translate-x-4":"translate-x-0"]])},null,2)],10,Ll))}}),Il=["id","innerHTML"],Pn=e.defineComponent({__name:"vs-input-static",props:{text:{default:""},html:{default:""},style:{},customClass:{default:""},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{id:t.name,class:e.normalizeClass(["text-gray-900",t.customClass]),innerHTML:t.html?t.html:t.text},null,10,Il))}}),Rl=["placeholder","disabled","name"],cn=e.defineComponent({__name:"vs-input-mask",props:e.mergeModels({name:{},mask:{default:""},unmask:{type:Boolean,default:!1},placeholder:{default:"_"},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=ze(t.style),r=e.useModel(o,"modelValue"),l=e.ref(null);let a=null;function s(i){const c={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},d=new Set;let u=!1;for(let h=0;h<i.length;h+=1){const x=i[h];x==="{"?u=!0:x==="}"?u=!1:u&&d.add(x)}const p={};return Object.keys(c).forEach(h=>{d.has(h)||(p[h]=c[h])}),{mask:i,definitions:p,lazy:!1}}return e.onMounted(async()=>{if(l.value){const{default:i}=await Promise.resolve().then(()=>so),c=s(t.mask||"");a=i(l.value,c),a.on("accept",()=>{r.value=t.unmask?a.unmaskedValue:a.value}),a.on("complete",()=>{r.value=t.unmask?a.unmaskedValue:a.value}),a.value=r.value!=null?String(r.value):""}}),e.onBeforeUnmount(()=>{a?.destroy()}),e.watch(()=>t.mask,i=>{if(a){const c=s(i||"");a.updateOptions(c)}}),e.watch(r,i=>{a&&a.unmaskedValue!==i&&(a.value=i!=null?String(i):"")}),(i,c)=>(e.openBlock(),e.createElementBlock("input",{type:"text",ref_key:"inputEl",ref:l,placeholder:i.placeholder,disabled:i.disabled,name:i.name,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,10,Rl))}}),Ol={class:"relative w-full bg-white rounded-lg"},zl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},Pl=["placeholder","disabled"],jn=e.defineComponent({__name:"vs-input-email",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=ze(t.style),r=e.useModel(o,"modelValue");return(l,a)=>(e.openBlock(),e.createElementBlock("div",Ol,[e.createElementVNode("div",zl,[e.createVNode(e.unref(P.Mail),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),e.withDirectives(e.createElementVNode("input",{type:"email","onUpdate:modelValue":a[0]||(a[0]=s=>r.value=s),placeholder:l.placeholder,disabled:l.disabled,class:e.normalizeClass(["!pl-8 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":l.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Pl),[[e.vModelText,r.value]])]))}}),jl={class:"relative w-full bg-white rounded-lg"},Ul={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},Hl=["value","placeholder","disabled"],Un=e.defineComponent({__name:"vs-input-tel",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=ze(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>r.value?r.value.startsWith("+")?r.value.slice(1):r.value:""),a=i=>{let{value:c}=i.target;c=c.replace(/^\+/,""),r.value=c?`+${c}`:""},s=i=>{const c=i,{data:d,inputType:u}=c;u&&u.startsWith("delete")||d&&/\D/.test(d)&&c.preventDefault()};return e.watch(()=>r.value,i=>{i&&!i.startsWith("+")?r.value=`+${i.replace(/^\+/,"")}`:i||(r.value="")},{immediate:!0}),(i,c)=>(e.openBlock(),e.createElementBlock("div",jl,[e.createElementVNode("div",Ul,[e.createVNode(e.unref(P.Phone),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),c[0]||(c[0]=e.createElementVNode("div",{class:"absolute bottom-2/4 translate-y-2/4 left-[30px] text-gray-500 select-none pointer-events-none"}," + ",-1)),e.createElementVNode("input",{type:"tel",value:l.value,onInput:a,onBeforeinput:s,pattern:"^\\+[1-9]\\d{1,14}$",maxlength:"15",placeholder:i.placeholder,disabled:i.disabled,class:e.normalizeClass(["!pl-10 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":i.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,Hl)]))}}),ql=["value","disabled"],Kl=["innerHTML"],Wl={key:1,class:"flex items-center gap-2"},Gl=["src"],Yl={class:"text-[13px] text-gray-700"},Xl=e.defineComponent({__name:"vs-input-radio-default",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Ut(t.option)),a=e.computed(()=>Ht(t.option)),s=e.computed(()=>Et(t.option)),i=e.computed(()=>!!(s.value&&!l.value&&!a.value)),c=e.computed(()=>!!(l.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),u=e.computed(()=>{if(!(!l.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${l.value})`,maskImage:`url(${l.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(p,h)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex items-center gap-0",[t.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[0]||(h[0]=x=>n.value=x),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,ql),[[e.vModelRadio,n.value]]),e.createElementVNode("span",{class:e.normalizeClass(["w-[16px] shrink-0 h-[16px] border rounded-full flex items-center justify-center mr-[10px]",[`border-${t.style?.primaryColor||"blue"}-500`,r.value?"opacity-50 cursor-not-allowed":""]])},[n.value==t.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["w-[12px] h-[12px] shrink-0 rounded-full",[`bg-${t.style?.primaryColor||"blue"}-500`]])},null,2)):e.createCommentVNode("",!0)],2),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,Kl)):(e.openBlock(),e.createElementBlock("div",Wl,[i.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(u.value)},null,4)):l.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:l.value,alt:"icon"},null,8,Gl)):a.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(d.value)},null,8,["style"])):e.createCommentVNode("",!0),e.createElementVNode("span",Yl,e.toDisplayString(t.text),1)]))],2))}}),Zl=["value","disabled"],Jl=["innerHTML"],Ql={key:1,class:"flex items-center gap-2"},ea=["src"],ta={class:"text-[13px] text-gray-700"},na={"vs-input-radio-default":Xl,"vs-input-radio-buttons":e.defineComponent({__name:"vs-input-radio-buttons",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Ut(t.option)),a=e.computed(()=>Ht(t.option)),s=e.computed(()=>Et(t.option)),i=e.computed(()=>!!(s.value&&!l.value&&!a.value)),c=e.computed(()=>!!(l.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),u=e.computed(()=>{if(!(!l.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${l.value})`,maskImage:`url(${l.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(p,h)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex h-full w-full items-center border rounded-lg px-2 py-1",[n.value==t.value?`ring-2 ring-ring ring-${t.style?.primaryColor||"blue"}-500`:"",t.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":h[0]||(h[0]=x=>n.value=x),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,Zl),[[e.vModelRadio,n.value]]),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,Jl)):(e.openBlock(),e.createElementBlock("div",Ql,[i.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(u.value)},null,4)):l.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:l.value,alt:"icon"},null,8,ea)):a.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(d.value)},null,8,["style"])):e.createCommentVNode("",!0),e.createElementVNode("span",ta,e.toDisplayString(t.text),1)]))],2))}})},vo=o=>Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[],Eo=o=>{const t=o.host??"",n=o.prefix??"api",r=o.api??`/${n}/suggest/${o.data}`;return`${t}${r}`},oa=o=>({fetchOptions:async(r="")=>{const l=o();if(!l.data)return l.options?[...l.options]:[];try{const a=new URLSearchParams;a.set("json","1"),r&&a.set("key",r),l.parentValue!==void 0&&l.parentValue!==null&&l.parentValue!==""&&a.set("parent",String(l.parentValue)),l.start===1&&a.set("start","1");const i=await(await fetch(`${Eo(l)}?${a.toString()}`)).json();return vo(i)}catch{return[]}},fetchOptionByValue:async r=>{if(r==null||r==="")return null;const l=o();if(!l.data)return(l.options??[]).find(s=>s?.id?.toString()===String(r))??null;try{const a=new URLSearchParams;a.set("json","1"),a.set("val",String(r)),l.parentValue!==void 0&&l.parentValue!==null&&l.parentValue!==""&&a.set("parent",String(l.parentValue)),l.start===1&&a.set("start","1");const i=await(await fetch(`${Eo(l)}?${a.toString()}`)).json();return vo(i)[0]??null}catch{return null}}}),dn=({props:o,formValues:t=null,watchParent:n=!0})=>{const r=e.ref([]),l=e.computed(()=>o.parent?t?.value?.[o.parent]?.toString?.()??null:null),{fetchOptions:a,fetchOptionByValue:s}=oa(()=>({data:o.data,options:o.options,api:o.api,prefix:o.prefix,host:o.host,start:o.start,parentValue:l.value})),i=async(c="")=>{const d=o.data?await a(c):o.options?[...o.options]:[];return r.value=d,r.value};return e.watch(()=>o.options,()=>{o.data||(r.value=o.options?[...o.options]:[])},{immediate:!0,deep:!0}),n&&e.watch(l,async()=>{o.data&&(r.value=await a())},{immediate:!1}),{optionsList:r,parentValue:l,fetchOptions:a,fetchOptionByValue:s,loadOptions:i}},ra=/\{\{\s*([^}]+?)\s*\}\}/g,la=o=>(o?String(o):"").replace(/<[^>]*>/g,"").trim(),aa=(o,t)=>t.split(".").reduce((n,r)=>n==null?n:n[r.trim()],o),un=(o,t)=>{if(!o)return"";const n=(t??"").trim();return n?n.replace(ra,(r,l)=>{const a=String(l).trim(),s=o,c=(a.includes(".")?aa(s,a):void 0)??s[a];return c!=null?String(c):""}):o.text??""},pn=(o,t)=>{if(!o)return"";const n=un(o,t);return la(n)||o.text||""},Hn=e.defineComponent({__name:"vs-input-radio",props:e.mergeModels({options:{},slot:{},data:{},api:{},prefix:{},host:{},start:{},parent:{},position:{default:"vertical"},view:{default:"default"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>na[`vs-input-radio-${t.view}`]),l=e.computed(()=>t.slot??t?.optionTemplate??""),a=e.computed(()=>sn(l.value)),s=x=>un(x,l.value),i=x=>pn(x,l.value),c=e.computed(()=>t.position==="horizontal"?"flex w-full flex-row flex-wrap gap-[10px]":"flex w-full flex-col gap-2"),d=e.computed(()=>{if(t.position==="horizontal"&&t.customClass?.includes("50%"))return{flex:"0 0 calc(50% - 5px)"}}),u=e.inject("values",null),{optionsList:p,loadOptions:h}=dn({props:t,formValues:u});return e.onMounted(async()=>{await h()}),(x,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p),b=>(e.openBlock(),e.createElementBlock("div",{key:b?.id,class:e.normalizeClass(["flex items-stretch",x.position==="horizontal"?t.customClass:""]),style:e.normalizeStyle(d.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),e.mergeProps({text:i(b),html:a.value?s(b):"",option:b,value:b.id.toString(),checked:n.value?.toString?.()===b.id?.toString?.(),"custom-class":x.position==="horizontal"?"":t.customClass,modelValue:n.value,"onUpdate:modelValue":m[0]||(m[0]=g=>n.value=g)},{ref_for:!0},x.$attrs),null,16,["text","html","option","value","checked","custom-class","modelValue"]))],6))),128))],2))}}),sa={key:1,class:"w-full flex flex-col gap-4"},ia={key:0,class:"text-sm font-medium text-muted-foreground my-2"},ca="Без категорії",da=e.defineComponent({__name:"vs-input-checkbox",props:{options:{default:()=>[]},position:{default:"vertical"},slots:{default:null},slot:{},colSpan:{default:0},data:{},api:{},prefix:{},host:{},start:{},parent:{},view:{},group:{default:void 0},values:{default:()=>[]},style:{},customClass:{},disabled:{type:Boolean},modelValue:{default:!1},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=e.reactive({}),a=e.inject("values",null),{optionsList:s,loadOptions:i}=dn({props:{...n,options:n.options},formValues:a}),c=e.computed(()=>s.value),d=k=>k?.value||k?.id||k?.text||k,u=e.computed(()=>n.slot??n?.optionTemplate??""),p=e.computed(()=>sn(u.value)),h=k=>un(k,u.value),x=k=>pn(k,u.value),m=k=>`lg:col-span-${k||12}`,b=e.computed(()=>[n.position==="vertical"?"flex flex-col":"",n.colSpan?"grid":"flex justify-start"]),g=k=>k==null||k===""?null:typeof k=="string"||typeof k=="number"?k:String(k),C=e.computed(()=>{if(!n.group)return[];const k=new Map;c.value.forEach(L=>{const B=L[n.group],S=g(B);k.has(S)||k.set(S,[]),k.get(S)?.push(L)});const w=[];n.values?.length&&n.values.forEach(L=>{const B=g(L);w.push(B)});const V=new Set,R=L=>{const B=k.get(L)||[];if(!B.length)return null;const S=L===null?"group-null":`group-${String(L)}`,$=L===null?ca:String(L);return V.add(L),{key:S,label:$,options:B}},Y=[];return w.forEach(L=>{const B=R(L);B&&Y.push(B)}),k.forEach((L,B)=>{if(V.has(B))return;const S=R(B);S&&Y.push(S)}),Y});return e.watch(()=>n.modelValue,k=>{if(typeof k=="boolean"&&c.value.length===1){const w=d(c.value[0]);l[w]=k}else if(Array.isArray(k)){const w=new Set(k);c.value.forEach(V=>{if(!V.disabled){const R=d(V);l[R]=w.has(R)}})}},{immediate:!0}),e.watch(l,()=>{if(!c.value.length){r("update:modelValue",null);return}const k=Object.entries(l).filter(([,w])=>w).map(([w])=>w);r("update:modelValue",k.length===0?[]:k)},{deep:!0}),e.onMounted(async()=>{if(await i(),typeof n.modelValue=="boolean"&&c.value.length===1){const k=d(c.value[0]);l[k]=n.modelValue}else if(Array.isArray(n.modelValue)){const k=new Set(n.modelValue);c.value.forEach(w=>{if(!w.disabled){const V=d(w);l[V]=k.has(V)}})}}),(k,w)=>n.group?(e.openBlock(),e.createElementBlock("div",sa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(C.value,V=>(e.openBlock(),e.createElementBlock("div",{key:V.key,class:"flex flex-col gap-2"},[V.label?(e.openBlock(),e.createElementBlock("span",ia,e.toDisplayString(V.label),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-0 w-full gap-[12px]",b.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.options,R=>(e.openBlock(),e.createBlock(On,{modelValue:l[d(R)],"onUpdate:modelValue":Y=>l[d(R)]=Y,value:d(R),class:e.normalizeClass(m(k.colSpan)),disabled:n.disabled||R.disabled,label:x(R),labelHtml:p.value?h(R):"",key:`${V.key}-${d(R)}`,icon:R?.icon,imgUrl:R?.imgUrl,option:R,view:k.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2)]))),128))])):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["p-0 w-full gap-[10px]",b.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,V=>(e.openBlock(),e.createBlock(On,{modelValue:l[d(V)],"onUpdate:modelValue":R=>l[d(V)]=R,value:d(V),class:e.normalizeClass(m(k.colSpan)),disabled:n.disabled||V.disabled,label:x(V),labelHtml:p.value?h(V):"",key:d(V),icon:V?.icon,imgUrl:V?.imgUrl,option:V,view:k.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2))}}),xe=(o,t)=>{const n=o.__vccOpts||o;for(const[r,l]of t)n[r]=l;return n},Bo=xe(da,[["__scopeId","data-v-9056e0ec"]]),ua=["type","placeholder","disabled"],pa=e.defineComponent({__name:"vs-input-date1",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},mode:{default:"date"}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o;function r(u){return u?n.mode==="datetime"?(u.includes("T")?u:null)||u+(u.includes(" ")?"":"T00:00"):u?.split(" ")[0]:null}const{inputClass:l}=ze(n.style),a=t,s=e.computed({get:()=>r(n.modelValue),set:u=>a("update:modelValue",u)}),i=e.computed(()=>n.mode==="datetime"?"datetime-local":n.mode),c=e.computed(()=>!!n.disabled),d=e.computed(()=>n.placeholder??"");return(u,p)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:i.value,"onUpdate:modelValue":p[0]||(p[0]=h=>s.value=h),placeholder:d.value,disabled:c.value,ref:"date",class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[u.modelValue?"":"text-opacity-50",e.unref(l)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,ua)),[[e.vModelDynamic,s.value]])}}),fa=(o,t)=>{if(!t||!Object.keys(t).length)return o;const[n,r=""]=o.split("?"),l=new URLSearchParams(r);Object.entries(t).forEach(([s,i])=>{i==null||i===""||l.set(s,String(i))});const a=l.toString();return a?`${n}?${a}`:n},Vo=async(o,t={})=>{try{const n=new FormData;n.append("unique","true"),n.append("file",o);const{api:r,id:l="1",form:a="form",table:s="table",customParams:i}=t,c=r||`/file/upload/uploads?id=${l||""}&form=${a||""}&table=${s||""}`,d=fa(c,i);return(await fetch(d,{method:"POST",body:n}).then(p=>p.json()))?.result}catch(n){return he.notify({type:"error",title:"Помилка!",message:"Сталась помилка під час завантаження файлу",position:"right-bottom"}),console.error("Сталась помилка завантаження файлу",n),null}},ma=async o=>{try{return await fetch(`file/delete${o}`),!0}catch(t){return console.error(t),!1}},So=async o=>{try{const t=await fetch(`/file/download${o}`);if(!t.ok)throw new Error(`Download failed with status ${t.status}`);const n=await t.blob(),l=(t.headers.get("content-disposition")||"").match(/filename\*?=(?:UTF-8''|")?([^\";]+)/i),a=l?.[1]?decodeURIComponent(l[1].replace(/"/g,"").trim()):"",s=o.split("/").filter(Boolean).pop()||"download",i=a||s,c=document.createElement("a");c.setAttribute("download",i),c.href=window.URL.createObjectURL(n),c.click(),window.URL.revokeObjectURL(c.href)}catch(t){console.error(t.message)}},ha=o=>{if(!o)return"";const t=o?.split(".");return t[t.length-1]},ga=o=>{const t=ha(o),n={imageFormat:["tiff","jpg","jpeg","png","svg","ico","webp"],sheetsFormat:["xls","csv","xlsx"],archivesFormat:["zip","rar"],textsFormat:["json","geojson","txt","yml","yaml","shp"],documentsFormat:["pdf"]};return n.imageFormat.includes(t)?"img":n.sheetsFormat.includes(t)?P.Table:n.textsFormat.includes(t)?P.FileCode:n.documentsFormat.includes(t)?P.FileText:n.archivesFormat.includes(t)?P.FileArchive:P.FileText},ya=["title"],ba={class:"absolute hidden top-0 right-0 flex items-center gap-x-2 w-full h-full justify-center"},qn=xe(e.defineComponent({__name:"vs-input-file-list-item",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{value:{},valueModifiers:{},item:{},itemModifiers:{}}),emits:["update:value","update:item"],setup(o){const t=e.useModel(o,"value"),n=e.useModel(o,"item"),r=o,l=e.computed(()=>n.value?typeof n.value=="string"?n.value:n.value.file_path:""),a=c=>typeof c=="string"?c:c?.file_path||"",s=()=>{const c=l.value;ma(c),r.multiple&&Array.isArray(t.value)?t.value=t.value.filter(d=>a(d)!==c):t.value=""},i=()=>{l.value&&window.open(l.value,"_blank")};return(c,d)=>(e.openBlock(),e.createElementBlock("div",{title:l.value,class:"h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg overflow-hidden relative item-file"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(ga)(l.value)),{src:l.value,alt:"file",class:"w-full h-full object-cover cursor-pointer",onClick:d[0]||(d[0]=u=>e.unref(So)(l.value))},null,8,["src"])),e.createElementVNode("div",ba,[e.createElementVNode("button",{type:"button",onClick:s,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-red-500"},[e.createVNode(e.unref(P.Trash2),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:i,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-emerald-600"},[e.createVNode(e.unref(P.Eye),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:d[1]||(d[1]=u=>e.unref(So)(l.value)),class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-blue-500"},[e.createVNode(e.unref(P.Download),{class:"w-4 h-4"})])])],8,ya))}}),[["__scopeId","data-v-89357cbb"]]),ka={class:"flex items-center gap-x-2"},xa=["accept","multiple","disabled"],wa={key:1,class:"flex items-center flex-wrap gap-2"},_a={key:1,class:"loader"},Ca={key:1,class:"loader"},$o=xe(e.defineComponent({__name:"vs-input-file",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["change"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),l=t,a=e.computed(()=>{const k=r.value;return!n.multiple||!Array.isArray(k)?[]:k}),s=e.ref(null),i=e.ref(!1),c=e.inject("values"),d=e.computed(()=>n.format?n.format.split(",").map(k=>k.trim().toLowerCase()).filter(Boolean):[]),u=k=>{if(n.max_size&&k.size>n.max_size*1024*1024){const w=(k.size/1048576).toFixed(2);return he.notify({type:"error",title:"Помилка!",message:`Файл "${k.name}" занадто великий. Максимальний розмір: ${n.max_size} МБ, розмір файлу: ${w} МБ`,position:"right-bottom"}),!1}return!0},p=k=>{if(!d.value.length)return!0;const w=`.${k.name.split(".").pop()?.toLowerCase()||""}`,V=d.value.includes(w);return V||he.notify({type:"error",title:"Помилка!",message:`Неприпустимий формат файлу "${k.name}". Дозволені формати: ${d.value.join(", ")}`,position:"right-bottom"}),V},h=e.computed(()=>{const k={},w=[];if(!n.customParams?.length)return{params:k,missingSources:w};const V=c?.value??{};return n.customParams.forEach(R=>{if(!R)return;const[Y,L]=R.split("="),B=Y?.trim(),S=L?.trim();if(!B||!S)return;const $=V[S];if($==null||$===""){w.push(S);return}k[B]=$}),{params:k,missingSources:w}}),x=()=>{const{params:k}=h.value;return{api:n.api,customParams:Object.keys(k).length?k:void 0}},m=()=>{const k=h.value.missingSources;if(!k.length)return!0;const w=k.join(", ");return he.notify({type:"warning",title:"Заповніть поля",message:`Поля (${w}) необхідні для завантаження файлу`,position:"right-bottom"}),!1},b=k=>{he.notify({type:"error",title:"Помилка завантаження",message:k||"Не вдалося завантажити файл. Спробуйте ще раз.",position:"right-bottom"})},g=()=>{n.disabled||i.value||m()&&s.value?.click()},C=async k=>{const{files:w}=k.target;if(!w||w.length===0)return;if(!m()){s.value&&(s.value.value="");return}const V=Array.from(w);if(n.max_size&&V.filter(L=>!u(L)).length>0){s.value&&(s.value.value="");return}if(V.filter(Y=>!p(Y)).length>0){s.value&&(s.value.value="");return}i.value=!0;try{if(n.multiple){const Y=Array.from(w).map(async E=>await Vo(E,x())),L=await Promise.all(Y),B=L.filter(E=>E?.file_path);if(B.length===0){b();return}B.length<L.length&&b("Деякі файли не вдалося завантажити. Перевірте їх та спробуйте знову.");const S=B.map(E=>E.file_path),$=Array.isArray(r.value)?r.value:[];r.value=[...$,...S],l("change",r.value)}else{const Y=w[0],L=await Vo(Y,x());if(!L?.file_path){b();return}const B=L.file_path;r.value=B,l("change",B)}}catch(Y){const L=Y?.message||void 0;b(L)}finally{i.value=!1,s.value&&(s.value.value="")}};return(k,w)=>(e.openBlock(),e.createElementBlock("div",ka,[e.createElementVNode("input",{class:"hidden",ref_key:"fileInput",ref:s,type:"file",accept:n.format,multiple:k.multiple,onChange:C,disabled:i.value||k.disabled},null,40,xa),!k.multiple&&r.value&&!Array.isArray(r.value)?(e.openBlock(),e.createBlock(qn,{key:0,item:r.value,value:r.value,"onUpdate:value":w[0]||(w[0]=V=>r.value=V)},null,8,["item","value"])):k.multiple?(e.openBlock(),e.createElementBlock("div",wa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(V,R)=>(e.openBlock(),e.createBlock(qn,{multiple:k.multiple,key:R,value:r.value,"onUpdate:value":w[1]||(w[1]=Y=>r.value=Y),item:V},null,8,["multiple","value","item"]))),128)),e.createElementVNode("div",{onClick:g,class:e.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 hover:text-blue-500 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",k.disabled||i.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500 hover:bg-blue-50"])},[i.value?(e.openBlock(),e.createElementBlock("div",_a)):(e.openBlock(),e.createBlock(e.unref(P.Plus),{key:0,class:"h-4 w-4"}))],2)])):e.createCommentVNode("",!0),k.multiple?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:2,onClick:g,class:e.normalizeClass([k.disabled||i.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500","relative h-[120px] w-[120px] border text-gray-300 hover:text-blue-500 border-dashed border-gray-300 rounded-lg flex items-center justify-center cursor-pointer hover:border-blue-500 transition-all duration-300 hover:bg-blue-50"])},[i.value?(e.openBlock(),e.createElementBlock("div",Ca)):(e.openBlock(),e.createBlock(e.unref(P.Plus),{key:0,class:"h-4 w-4"}))],2))]))}}),[["__scopeId","data-v-dda91e05"]]),va={class:"vs-input-file2 flex flex-col gap-4"},Ea={class:"flex items-center gap-x-2"},Ba=["accept","disabled"],Va={key:0,class:"absolute inset-0 flex flex-col items-center justify-center gap-1 rounded-lg bg-white/90 text-xs font-medium text-slate-600"},Sa={key:0,class:"rounded-lg border border-[#CFD9E0] bg-white p-4 shadow-sm"},$a={class:"flex items-center justify-between text-sm"},Na={class:"truncate pr-4"},Aa={class:"font-medium text-slate-800 truncate"},Fa={class:"text-slate-500"},Ma={class:"text-slate-500 whitespace-nowrap"},Da={class:"mt-3 h-2 rounded-full bg-slate-100 overflow-hidden"},Ta={class:"mt-3 flex flex-wrap gap-2 text-sm"},La={key:0,class:"mt-2 text-sm text-rose-600"},Ia=e.defineComponent({__name:"vs-input-file2",props:e.mergeModels({format:{},max_size:{},api:{},chunkSize:{default:5*1024*1024},subdir:{default:""},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(null),l=e.ref(null),a=e.ref(""),s=e.ref(0),i=e.ref(!1),c=e.ref(""),d=e.ref(null),u=e.inject("values"),p=e.computed(()=>t.format?t.format.split(",").map(N=>N.trim().toLowerCase()).filter(Boolean):[]),h=e.computed(()=>!l.value||!l.value.size?0:Math.min(100,Math.round(s.value/l.value.size*100))),x=e.computed(()=>l.value?`${g(s.value)} / ${g(l.value.size)}`:""),m=e.computed(()=>t.disabled?"opacity-50 cursor-not-allowed":i.value?"cursor-default text-blue-500":"cursor-pointer hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500"),b=()=>{t.disabled||i.value||V()&&r.value?.click()},g=N=>{if(!Number.isFinite(N))return"0 B";const I=["B","KB","MB","GB"];let v=0,M=N;for(;M>=1024&&v<I.length-1;)M/=1024,v+=1;return`${M.toFixed(v===0?0:1)} ${I[v]}`},C=N=>{if(!t.max_size)return!0;const I=t.max_size*1024*1024;return N.size>I?(he.notify({type:"error",title:"Файл занадто великий",message:`Максимальний розмір ${t.max_size} МБ`,position:"right-bottom"}),!1):!0},k=N=>{if(!p.value.length)return!0;const I=`.${N.name.split(".").pop()?.toLowerCase()||""}`;return p.value.includes(I)?!0:(he.notify({type:"error",title:"Непідтримуваний формат",message:`Дозволені формати: ${p.value.join(", ")}`,position:"right-bottom"}),!1)},w=e.computed(()=>{const N={},I=[];if(!t.customParams?.length)return{params:N,missing:I};const v=u?.value??{};return t.customParams.forEach(M=>{if(!M)return;const[D,K]=M.split("="),W=D?.trim(),X=K?.trim();if(!W||!X)return;const re=v[X];re==null||re===""?I.push(X):N[W]=re}),{params:N,missing:I}}),V=()=>w.value.missing.length?(he.notify({type:"warning",title:"Заповніть поля",message:`Потрібні значення: ${w.value.missing.join(", ")}`,position:"right-bottom"}),!1):!0,R=N=>{const I=N.target,v=I.files?.[0];if(v){if(!V()){I.value="";return}if(!C(v)||!k(v)){I.value="";return}l.value=v,s.value=0,a.value="",c.value=""}},Y=async()=>{if(!l.value){b();return}try{c.value="";const N={id:a.value||"",fileName:l.value.name,subdir:t.subdir,size:l.value.size,...w.value.params},I=await fetch("/api/file/upload2/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(!I.ok)throw new Error("Не вдалося ініціалізувати завантаження");const v=await I.json();a.value=v.id||a.value,s.value=v.uploaded||0,await L()}catch(N){c.value=N?.message||"Помилка при старті завантаження"}},L=async()=>{if(!(!l.value||!a.value)){i.value=!0;try{for(;s.value<l.value.size;){const N=s.value,I=Math.min(N+t.chunkSize,l.value.size),v=l.value.slice(N,I);d.value=new AbortController;const M=await fetch(`/api/file/upload2/${a.value}`,{method:"PATCH",headers:{"Content-Range":`bytes ${N}-${I-1}/${l.value.size}`},body:v,signal:d.value.signal});if(!M.ok)throw new Error("Помилка завантаження частини");const D=await M.json().catch(()=>({}));if(D.uploaded!=null?s.value=Number(D.uploaded):s.value=I,D.finished||s.value>=l.value.size){i.value=!1;const K=D.file_path||D.url||a.value;n.value={file_id:D.file_id??a.value??K,file_path:K},he.notify({type:"success",title:"Файл завантажено",message:l.value.name,position:"right-bottom"}),E();return}}}catch(N){if(N?.name==="AbortError")return;c.value=N?.message||"Помилка при завантаженні",i.value=!1}finally{d.value=null,i.value=!1}}},B=()=>{i.value&&(d.value?.abort(),d.value=null,i.value=!1)},S=async()=>{if(l.value){if(!a.value){await Y();return}await L()}},$=()=>{d.value?.abort(),d.value=null,E()},E=()=>{const N=r.value;N&&(N.value=""),l.value=null,a.value="",s.value=0,c.value=""};return(N,I)=>(e.openBlock(),e.createElementBlock("div",va,[e.createElementVNode("div",Ea,[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",class:"hidden",accept:t.format,disabled:i.value||t.disabled,onChange:R},null,40,Ba),n.value?(e.openBlock(),e.createBlock(qn,{key:0,item:n.value,"onUpdate:item":I[0]||(I[0]=v=>n.value=v),value:n.value,"onUpdate:value":I[1]||(I[1]=v=>n.value=v)},null,8,["item","value"])):(e.openBlock(),e.createElementBlock("div",{key:1,onClick:b,class:e.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",m.value])},[i.value?(e.openBlock(),e.createElementBlock("div",Va,[I[2]||(I[2]=e.createElementVNode("div",{class:"loader"},null,-1)),e.createElementVNode("span",null,e.toDisplayString(h.value)+"%",1)])):(e.openBlock(),e.createBlock(e.unref(P.Plus),{key:1,class:"h-4 w-4"}))],2))]),l.value&&!n.value?(e.openBlock(),e.createElementBlock("div",Sa,[e.createElementVNode("div",$a,[e.createElementVNode("div",Na,[e.createElementVNode("div",Aa,e.toDisplayString(l.value.name),1),e.createElementVNode("div",Fa,e.toDisplayString(g(l.value.size)),1)]),e.createElementVNode("div",Ma,e.toDisplayString(x.value),1)]),e.createElementVNode("div",Da,[e.createElementVNode("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-300",style:e.normalizeStyle({width:`${h.value}%`})},null,4)]),e.createElementVNode("div",Ta,[!i.value&&s.value>0&&s.value<(l.value?.size||0)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:S}," Resume ")):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:B}," Pause ")):e.createCommentVNode("",!0),!i.value&&s.value===0?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:Y}," Upload ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"rounded border border-rose-200 px-3 py-1 text-rose-600",onClick:$}," Cancel ")]),c.value?(e.openBlock(),e.createElementBlock("p",La,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]))}}),Kn=xe(Ia,[["__scopeId","data-v-19ea2129"]]),Ra={class:"flex items-center justify-center h-[30px] w-[30px]"},Oa={class:"max-w-[55vw]"},za={class:"text-sm font-semibold text-gray-800 truncate dark:text-neutral-200"},Pa={class:"flex items-center text-xs text-gray-500 truncate dark:text-neutral-500"},ja={class:"px-[5px]"},Ua={class:""},fn=e.defineComponent({__name:"vs-widget-file-info",props:{item:{default:null}},setup(o){const t=o,n=e.computed(()=>{try{return new Date(t.item.cdate).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}});function r(l){if(l<1024)return`${l} B`;const a=l/1024;return a<1024?`${a.toFixed(2)} KB`:`${(a/1024).toFixed(2)} MB`}return(l,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",Ra,[e.createVNode(e.unref(P.FileText),{class:"icon icon-tabler icons-tabler-outline icon-tabler-file h-4 w-4"})]),e.createElementVNode("div",Oa,[e.createElementVNode("p",za,e.toDisplayString(l.item?.uploaded_name),1),e.createElementVNode("p",Pa,[e.createElementVNode("span",null,e.toDisplayString(l.item?.username),1),e.withDirectives(e.createElementVNode("span",ja,"|",512),[[e.vShow,l.item?.username]]),e.createElementVNode("span",null,e.toDisplayString(n.value),1),a[0]||(a[0]=e.createElementVNode("span",{class:"px-[5px]"},"|",-1)),e.createElementVNode("span",Ua,e.toDisplayString(r(l.item?.size)),1)])])],64))}}),Ha={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-md w-full"},qa={key:0,class:"flex w-full gap-x-3 items-center"},Ka={key:1,class:"flex gap-x-3 w-full items-center"},Wa={key:2,class:"flex gap-x-3 w-full items-center"},Ga=["href"],Ya={key:3,class:"flex gap-x-3 w-full items-center"},Xa={class:"lg:absolute lg:top-3 lg:end-1 opacity-100"},Za={class:"p-0.5 sm:p-1 inline-flex items-center gap-0.5 bg-white rounded-lg dark:bg-neutral-800 dark:border-neutral-700"},Ja={class:"inline-block"},Qa={class:"inline-block"},es={class:"inline-block"},ts=e.defineComponent({__name:"vs-widget-file-item",props:{item:{default:null},index:{default:0},prefix:{default:"/api"}},emits:["update","openModal","openLightbox"],setup(o,{emit:t}){const n=o,r=t;function l(p){return["pdf","json"].includes(p.ext)}function a(p){return["ppt","pptx","doc","docx","xls","xlsx"].includes(p.ext)}function s(p){const h=document.createElement("a");h.setAttribute("download",p?.uploaded_name),h.href=p?.file_path,h.click()}function i(p){p?.file_path&&window.open(p.file_path,"_blank")}async function c(){try{await fetch(`${n.prefix}/widget/file/${n.item.entity_id}/${n.item.file_id}`),r("update")}catch(p){console.error(p)}}function d(){r("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:c,updateListOnConfirm:!0})}function u(p){(n.item.ext==="jpg"||n.item.ext==="png")&&r("openLightbox",{item:n.item,index:p})}return(p,h)=>(e.openBlock(),e.createElementBlock("div",Ha,[p.item.ext==="jpg"||p.item.ext==="png"?(e.openBlock(),e.createElementBlock("div",qa,[e.createElementVNode("div",{class:"max-w-[55vw] cursor-pointer flex gap-x-3 w-full items-center",onClick:h[0]||(h[0]=x=>u(p.index))},[e.createVNode(fn,{item:p.item},null,8,["item"])])])):l(p.item)?(e.openBlock(),e.createElementBlock("div",Ka,[e.createVNode(fn,{item:p.item},null,8,["item"])])):a(p.item)?(e.openBlock(),e.createElementBlock("div",Wa,[e.createElementVNode("a",{href:`/api/file-preview?id=${p.item.file_id}`,target:"_blank",class:"flex gap-x-3 w-full items-center"},[e.createVNode(fn,{item:p.item},null,8,["item"])],8,Ga)])):(e.openBlock(),e.createElementBlock("div",Ya,[e.createVNode(fn,{item:p.item},null,8,["item"])])),e.createElementVNode("div",Xa,[e.createElementVNode("div",Za,[e.createElementVNode("div",Ja,[e.createElementVNode("button",{class:"inline-flex p-[6px] justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:h[1]||(h[1]=x=>i(p.item))},[e.createVNode(e.unref(P.Eye),{class:"h-4 w-4"})])]),e.createElementVNode("div",Qa,[e.createElementVNode("button",{class:"inline-flex p-[6px] justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:h[2]||(h[2]=x=>s(p.item))},[e.createVNode(e.unref(P.Download),{class:"h-4 w-4"})])]),h[4]||(h[4]=e.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),e.createElementVNode("div",es,[e.createElementVNode("button",{type:"button",class:"size-[30px] inline-flex justify-center items-center gap-x-2 rounded-lg border border-transparent text-red-600 hover:bg-red-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-red-100 dark:text-red-500 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20",onClick:h[3]||(h[3]=x=>d())},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})])])])])]))}}),ns={class:"flex flex-col widget-file xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700 w-full"},os={class:"flex w-full mb-[12px] items-center gap-x-2"},rs={class:"font-semibold text-gray-800 dark:text-neutral-200 text-[14px]"},ls={class1:"ml-auto"},as={class:"py-1.5 px-4 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg bg-gray-100 cursor-pointer hover:bg-gray-200 text-gray-800 shadow-2xs hover:bg-gray-50 focus:outline-hidden focus:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-white dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},ss={key:0,class:"py-4 mb-4 space-y-4 border-gray-200 border-y dark:border-neutral-700"},is={class:"relative"},cs={class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-[1] ps-3.5"},ds={key:1,class:"space-y-3 max-h-[300px] overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},us={key:0},No=e.defineComponent({__name:"vs-input-file-list",props:{id:{default:""},prefix:{default:"/api"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update"],setup(o,{emit:t}){const n=o,r=e.inject("form"),l=e.computed(()=>r.value.formId),a=e.ref(!1),s=e.ref(0),i=t,c=e.ref(!1),d=e.ref({}),u=e.ref([]),p=e.ref(""),h=e.computed(()=>Array.isArray(u.value)?u.value.filter(w=>w.ext==="jpg"||w.ext==="png").map(w=>w?.file_path):[]),x=e.computed(()=>p.value===""?u.value:u.value.filter(w=>w?.uploaded_name?.includes(p.value))),m=w=>{const V=h.value.findIndex(R=>R===w.item.file_path);V!==-1&&(a.value=!0,s.value=V)},b=async()=>{try{const w=await fetch(`${n.prefix}/widget/file/${l.value}`).then(V=>V.json());u.value=w?.rows}catch(w){console.error(w)}},g=async w=>{await Promise.all(Array.from(w.target.files).map(async V=>{const R=new FormData;R.append("file",V);try{const Y=`${n.prefix}/widget/file/${l.value}`,L=await fetch(Y,{method:"POST",body:R});return L.ok?(i("update","file-list"),V):(he.notify({type:L.status>=400&&L.status<500?"warning":"error",title:"Error",message:`Error code: ${L.status}`}),null)}catch(Y){return he.notify({type:"error",title:"Error",message:Y.message||"Unknown error"}),console.error(Y),null}})),await b()},C=w=>{const V={...w};return w.cancel||(V.cancel=()=>{c.value=!1}),w.updateListOnConfirm&&(V.confirm=async()=>{await w.confirm(),c.value=!1,b()}),V},k=w=>{d.value=C(w),c.value=!0};return e.watch(l,w=>{w&&b()}),e.onMounted(()=>{l.value&&b()}),(w,V)=>{const R=e.resolveComponent("Lightbox"),Y=e.resolveComponent("MessageBox");return e.openBlock(),e.createElementBlock("div",ns,[e.createElementVNode("div",os,[e.createElementVNode("h2",rs," Файлів: "+e.toDisplayString(u.value?.length),1),e.createElementVNode("div",ls,[e.createElementVNode("label",null,[e.createElementVNode("input",{type:"file",class:"hidden",onChange:V[0]||(V[0]=L=>g(L))},null,32),e.createElementVNode("div",as,[e.createVNode(e.unref(P.Upload),{class:"h-4 w-4"})])])])]),u.value?.length>4?(e.openBlock(),e.createElementBlock("div",ss,[e.createElementVNode("div",null,[e.createElementVNode("div",is,[e.createElementVNode("div",cs,[e.createVNode(e.unref(P.Search),{class:"flex-shrink-0 text-gray-500 size-4 dark:text-neutral-400"})]),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":V[1]||(V[1]=L=>p.value=L),class:"py-2 px-3 ps-10 pe-16 block w-full bg-gray-200 xl:bg-gray-100 rounded-lg text-sm focus:border-blue-500 h-[40px] focus:border-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:border-transparent dark:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-600",placeholder:"Введіть назву файлу"},null,512),[[e.vModelText,p.value,void 0,{trim:!0}]])])])])):e.createCommentVNode("",!0),u.value?.length?(e.openBlock(),e.createElementBlock("div",ds,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,(L,B)=>(e.openBlock(),e.createBlock(ts,{key:B,prefix:w.prefix,item:L,index:B,onUpdate:V[2]||(V[2]=S=>w.$emit("update","file-list")),onOpenModal:V[3]||(V[3]=S=>k(S)),onOpenLightbox:V[4]||(V[4]=S=>m(S))},null,8,["prefix","item","index"]))),128)),x.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",us,V[8]||(V[8]=[e.createElementVNode("p",{class:"text-sm text-gray-600 font-sm"}," Файлів з такою назвою не існує, введіть інше пошукове слово ",-1)])))])):e.createCommentVNode("",!0),e.createVNode(R,{modelValue:a.value,"onUpdate:modelValue":V[5]||(V[5]=L=>a.value=L),startIndex:s.value,"onUpdate:index":V[6]||(V[6]=L=>s.value=L),images:h.value},null,8,["modelValue","startIndex","images"]),e.createVNode(Y,e.mergeProps({modelValue:c.value,"onUpdate:modelValue":V[7]||(V[7]=L=>c.value=L),onConfirm:d.value.confirm},d.value),null,16,["modelValue","onConfirm"])])}}}),ps={class:"flex items-center justify-between"},fs={class:"text-[16px] text-gray-900 font-medium"},ms={class:"grid gap-3"},hs=xe(e.defineComponent({__name:"vs-container-switcher",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",ps,[e.createElementVNode("p",fs,e.toDisplayString(o.title),1),e.createVNode(zn,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),style:e.normalizeStyle(o.style)},null,8,["modelValue","style"])]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",ms,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-90320b87"]]),gs={class:"text-[16px] text-gray-900 font-medium"},ys={class:"grid gap-3"},bs=xe(e.defineComponent({__name:"vs-container-accordion",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("button",{type:"button",onClick:l[0]||(l[0]=a=>n.value=!n.value),class:"flex items-center gap-2"},[e.createVNode(e.unref(P.ChevronDown),{class:e.normalizeClass(["h-4 w-4 duration-300",[n.value?"-rotate-180":""]])},null,8,["class"]),e.createElementVNode("span",gs,e.toDisplayString(o.title),1)]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",ys,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-0c825d65"]]),ks={class:"flex items-center justify-between"},xs={switcher:hs,accordion:bs,default:e.defineComponent({__name:"vs-container-default",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",ks,[e.createElementVNode("p",null,e.toDisplayString(o.title),1)]),e.renderSlot(t.$slots,"default")]))}})},ot={Equal:"==",Inequal:"!=",Higer:">",HigerOrEqual:">=",Lower:"<",LowerOrEqual:"<=",Between:"between",StartWith:"^",EndWith:"$",Contain:"*",In:"in",NotIn:"not_in"},ws=(o,t)=>String(o)===String(t),_s=(o,t)=>String(o)!==String(t),Cs=(o,t)=>o>t,vs=(o,t)=>o>=t,Es=(o,t)=>o<t,Bs=(o,t)=>o<=t,Vs=(o,t)=>Array.isArray(t)&&t.length===2?o>=t[0]&&o<=t[1]:!1,Ss=(o,t)=>String(o).startsWith(String(t)),$s=(o,t)=>String(o).endsWith(String(t)),Ns=(o,t)=>String(o).includes(String(t)),As=(o,t)=>Array.isArray(t)?t.includes(o):!1,Fs=(o,t)=>Array.isArray(t)?!t.includes(o):!0,Ao=(o,t)=>{if(!t)return!0;switch(t?.[1]){case ot.Equal:return ws(o,t?.[2]);case ot.Inequal:return _s(o,t?.[2]);case ot.Higer:return Cs(o,t?.[2]);case ot.HigerOrEqual:return vs(o,t?.[2]);case ot.Lower:return Es(o,t?.[2]);case ot.LowerOrEqual:return Bs(o,t?.[2]);case ot.Between:return Vs(o,t?.[2]);case ot.StartWith:return Ss(o,t?.[2]);case ot.EndWith:return $s(o,t?.[2]);case ot.Contain:return Ns(o,t?.[2]);case ot.In:return As(o,t?.[2]);case ot.NotIn:return Fs(o,t?.[2]);default:return!0}},Fo=e.defineComponent({__name:"vs-input-container",props:{style:{type:Object,default:()=>({})},title:{type:String,default:""},view:{type:String,default:"default"},name:{type:String,default:""},schema:{type:Array,default:()=>[]}},setup(o){const t=o,n=e.inject("values",e.ref({})),r=e.inject("form"),l=e.computed(()=>t.schema?.filter(i=>{const c=i?.conditions;if(!c)return!0;const d=Array.isArray(c)?c[0]:c,u=t.name?n.value?.[t.name]?.[d]??n.value?.[d]:n.value?.[d];return Ao(u,c)})),a=e.computed(()=>xs[t.view]),s=e.computed(()=>{if(n.value||(n.value={}),!t.name)return n.value;const i=n.value[t.name];if(i)return i;const c={};return n.value={...n.value,[t.name]:c},c});return(i,c)=>o.schema?.length?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:0,title:o.title,style:e.normalizeStyle(o.style)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,d=>(e.openBlock(),e.createBlock(tr,e.mergeProps({key:d.name},{ref_for:!0},d,{item:d,modelValue:s.value[d.name],"onUpdate:modelValue":u=>s.value[d.name]=u,style:o.style,error:e.unref(r)?.errors?.[d.name]}),null,16,["item","modelValue","onUpdate:modelValue","style","error"]))),128))]),_:1},8,["title","style"])):e.createCommentVNode("",!0)}}),Mo=({props:o,fetchOptionByValue:t,optionsList:n,selectedOption:r,modelValue:l,onCreated:a})=>{const s=e.ref(!1),i=e.ref({}),c=e.ref([]),d=e.ref(null),u=e.computed(()=>o.add?.title||"Додати"),p=e.computed(()=>o.add?.token||o.add?.model||""),h=e.computed(()=>o.add?.pk||"id");return{isOpenAdd:s,addData:i,addSchema:c,addForm:d,addTitle:u,addOption:async()=>{if(!(!p.value||d?.value.validate()))try{const g=o.add?.api??`/api/table/${p.value}`,C=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i.value)}),k=await C.json().catch(()=>({})),w=k?.error||k?.message,V=Number(k?.code)>=400;if(!C.ok||V){he.notify({title:"Помилка",type:"error",message:w||`Код помилки: ${k?.code||C.status}`});return}const R=k?.[h.value]??k?.id;if(!R){he.notify({title:"Помилка",type:"error",message:"Обʼєкт створено, але в відповіді відсутній ID."});return}const Y=await t(R);Y&&(n.value.some(B=>String(B?.id)===String(Y.id))||n.value.push(Y)),a?await a(Y,R):Y&&(r.value=Y,l.value=R),s.value=!1,he.notify({title:"Успіх",message:"Обʼєкт успішно створено."})}catch(g){he.notify({title:"Помилка",type:"error",message:g?.message||"Не вдалося створити обʼєкт."})}},onAddValue:async()=>{if(!o.add)return null;const b=await fetch(`/api/template/form/${o.add.form}`).then(g=>g.json());return c.value=b.schema,i.value={},s.value=!0,null}}},Ms=["aria-expanded","data-focus"],Ds={class:"relative flex flex-1 items-center gap-1 py-0.5 pl-1 pr-0 overflow-hidden h-full min-w-0"},Ts={key:0,class:"flex flex-nowrap items-center gap-1 overflow-x-auto overflow-y-hidden min-w-0 flex-1 py-0.5"},Ls={class:"flex items-center gap-1 min-w-0"},Is=["title"],Rs=["innerHTML"],Os=["onClick"],zs={class:"flex-1 min-w-[2px]"},Ps=["placeholder"],js=["title"],Us=["innerHTML"],Hs={key:3,class:"truncate flex-1 min-w-0"},qs={key:2,class:"flex-1 min-w-[2px]"},Ks=["placeholder"],Ws={class:"flex items-center shrink-0"},Gs=["disabled"],Ys={key:1,class:"self-stretch w-px bg-[#ccc] my-[1px]"},Xs=["disabled","title"],Zs=e.defineComponent({__name:"vs-select-control",props:{disabled:{type:Boolean},isOpen:{type:Boolean},inputFocus:{type:Boolean},isMulti:{type:Boolean},selectedOptions:{},selectedIds:{},placeholder:{},search:{type:Boolean},optionTemplate:{default:""},iconWrapperClass:{},selectedOptionLabel:{},selectedOption:{},showClear:{type:Boolean},keyWord:{default:""},setTriggerRef:{},setInputRef:{},shouldShowColorDot:{},optionHasIcon:{},getIconColorStyle:{},resolveOptionIcon:{},renderTemplate:{},getLabel:{},onControlKeydown:{},onControlClick:{},onInputFocus:{},onInputBlur:{},onInputKeydown:{},onRemoveSelected:{},onClearSelected:{},onToggleSelect:{}},emits:["update:keyWord"],setup(o,{emit:t}){const n=o,r=t,l=e.computed({get:()=>n.keyWord,set:a=>r("update:keyWord",a)});return(a,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-input-select__control flex min-h-[38px] items-center justify-between rounded transition-colors bg-white",a.disabled?"bg-gray-100 text-gray-400 cursor-not-allowed":""]),role:"combobox","aria-expanded":a.isOpen,"aria-haspopup":"listbox",onKeydown:s[10]||(s[10]=(...i)=>a.onControlKeydown&&a.onControlKeydown(...i)),onClick:s[11]||(s[11]=(...i)=>a.onControlClick&&a.onControlClick(...i)),"data-focus":a.isOpen||a.inputFocus?"true":"false",ref:a.setTriggerRef},[e.createElementVNode("div",Ds,[a.isMulti?(e.openBlock(),e.createElementBlock("div",Ts,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.selectedOptions,i=>(e.openBlock(),e.createElementBlock("div",{key:i.id,class:"flex min-w-0 bg-[rgb(230,230,230)] rounded-[2px] m-[2px] box-border max-w-full"},[e.createElementVNode("div",Ls,[a.shouldShowColorDot(i)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[16px] h-[16px] rounded-md block ml-1.5 flex-shrink-0",style:e.normalizeStyle({backgroundColor:i?.color})},null,4)):e.createCommentVNode("",!0),!a.optionTemplate&&a.optionHasIcon(i)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(a.iconWrapperClass),style:e.normalizeStyle(a.getIconColorStyle(i)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.resolveOptionIcon(i)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"truncate text-[#172b4d] overflow-hidden max-w-[200px] px-0.5 pl-1.5",title:a.getLabel(i)},[a.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:a.renderTemplate(i)},null,8,Rs)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(i.text),1)],64))],8,Is)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border text-[#172b4d] hover:bg-[rgb(255,189,173)] hover:text-[rgb(222,53,11)] flex-shrink-0",onClick:e.withModifiers(c=>a.onRemoveSelected(i.id),["stop"])},[e.createVNode(e.unref(P.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Os)]))),128)),e.createElementVNode("div",zs,[!a.disabled&&a.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref:a.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:a.selectedIds.length?" ":a.placeholder,"onUpdate:modelValue":s[0]||(s[0]=i=>l.value=i),onFocus:s[1]||(s[1]=(...i)=>a.onInputFocus&&a.onInputFocus(...i)),onBlur:s[2]||(s[2]=(...i)=>a.onInputBlur&&a.onInputBlur(...i)),onKeydown:s[3]||(s[3]=(...i)=>a.onInputKeydown&&a.onInputKeydown(...i))},null,40,Ps)),[[e.vModelText,l.value]]):e.createCommentVNode("",!0)])])):!a.isMulti&&a.selectedOptionLabel&&l.value===""?(e.openBlock(),e.createElementBlock("div",{key:1,class:"truncate text-gray-900 absolute inset-x-0 pl-2 flex items-center gap-1 min-w-0",title:a.selectedOptionLabel},[a.shouldShowColorDot(a.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[14px] h-[14px] rounded-md block flex-shrink-0",style:e.normalizeStyle({backgroundColor:a.selectedOption?.color})},null,4)):e.createCommentVNode("",!0),!a.optionTemplate&&a.optionHasIcon(a.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(a.iconWrapperClass),style:e.normalizeStyle(a.getIconColorStyle(a.selectedOption)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.resolveOptionIcon(a.selectedOption)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),a.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:2,class:"truncate flex-1 min-w-0",innerHTML:a.renderTemplate(a.selectedOption)},null,8,Us)):(e.openBlock(),e.createElementBlock("span",Hs,e.toDisplayString(a.selectedOption?.text),1))],8,js)):e.createCommentVNode("",!0),a.isMulti?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",qs,[!a.disabled&&a.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref:a.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:a.selectedOptionLabel?" ":a.placeholder,"onUpdate:modelValue":s[4]||(s[4]=i=>l.value=i),onFocus:s[5]||(s[5]=(...i)=>a.onInputFocus&&a.onInputFocus(...i)),onBlur:s[6]||(s[6]=(...i)=>a.onInputBlur&&a.onInputBlur(...i)),onKeydown:s[7]||(s[7]=(...i)=>a.onInputKeydown&&a.onInputKeydown(...i))},null,40,Ks)),[[e.vModelText,l.value]]):e.createCommentVNode("",!0)]))]),e.createElementVNode("div",Ws,[a.showClear?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.disabled,onClick:s[8]||(s[8]=e.withModifiers((...i)=>a.onClearSelected&&a.onClearSelected(...i),["stop"]))},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,Gs)):e.createCommentVNode("",!0),a.showClear?(e.openBlock(),e.createElementBlock("div",Ys)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.disabled,onClick:s[9]||(s[9]=e.withModifiers((...i)=>a.onToggleSelect&&a.onToggleSelect(...i),["stop"])),title:a.isOpen?"Закрити список":"Відкрити список"},[e.createVNode(e.unref(P.ChevronDown),{class:"h-4 w-4"})],8,Xs)])],42,Ms))}}),Js=["aria-disabled","onClick"],Qs={class:"leading-[19px]"},ei=["innerHTML"],ti={key:1,class:"px-3 py-2 text-center text-gray-500"},ni=e.defineComponent({__name:"vs-select-dropdown",props:{isOpen:{type:Boolean},dropdownStyle:{},filteredOptionsList:{},selectedNavIndex:{},optionTemplate:{},iconWrapperClass:{},setDropdownRef:{type:Function},setListRef:{type:Function},setItemRef:{type:Function},isSelected:{type:Function},onOptionClick:{type:Function},shouldShowColorDot:{type:Function},optionHasIcon:{type:Function},getIconColorStyle:{type:Function},resolveOptionIcon:{type:Function},renderTemplate:{type:Function}},setup(o){return(t,n)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.isOpen?(e.openBlock(),e.createElementBlock("div",{key:0,ref:t.setDropdownRef,class:"fixed z-[3000] rounded bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.1),0_4px_11px_rgba(0,0,0,0.1)]",style:e.normalizeStyle(t.dropdownStyle),role:"listbox"},[e.createElementVNode("div",{class:"overflow-y-auto py-1",style:e.normalizeStyle({maxHeight:t.dropdownStyle.maxHeight||"300px"}),ref:t.setListRef},[t.filteredOptionsList.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.filteredOptionsList,(r,l)=>(e.openBlock(),e.createElementBlock("div",{key:r.id,ref_for:!0,ref:a=>t.setItemRef(a,l),class:e.normalizeClass(["flex px-3 py-2 gap-2 cursor-pointer select-none text-gray-900",t.isSelected(r.id)?"bg-[#2684ff] text-white":"bg-white hover:bg-[#deebff] hover:text-[#172b4d]",t.selectedNavIndex===l&&!t.isSelected(r.id)?"bg-[#deebff] text-[#172b4d]":""]),"aria-disabled":t.isSelected(r.id)?"true":"false",role:"option",tabindex:"-1",onClick:a=>t.onOptionClick(r)},[t.shouldShowColorDot(r)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[11px] h-[11px] rounded-full block flex-shrink-0",style:e.normalizeStyle({backgroundColor:r?.color})},null,4)):e.createCommentVNode("",!0),!t.optionTemplate&&t.optionHasIcon(r)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(t.iconWrapperClass),style:e.normalizeStyle(t.getIconColorStyle(r)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.resolveOptionIcon(r)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",Qs,[t.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:t.renderTemplate(r)},null,8,ei)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r.text),1)],64))])],10,Js))),128)):(e.openBlock(),e.createElementBlock("div",ti," No options "))],4)],4)):e.createCommentVNode("",!0)]))}}),oi=["disabled"],Do="w-[16px] h-[16px] flex items-center justify-center flex-shrink-0 text-current",Wn=xe(e.defineComponent({__name:"vs-input-select",props:{multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean,default:!0},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{default:400},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{default:0},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t,l=e.computed(()=>n.multiple),a=e.computed(()=>n.disabled),s=e.computed(()=>n.search);ze(n.style);const i=e.computed({get:()=>n.modelValue,set:O=>r("update:modelValue",O)});!i.value&&n.defaultValue&&(i.value=n.defaultValue);const c=e.ref(null),d=e.ref(null),u=e.ref(null),p=e.ref(null),h=e.ref(!1),x=e.ref(!1),m=e.ref(null),b=e.ref(-1),g=e.ref([]),C=e.ref(""),k=e.ref(null),w=O=>{d.value=O},V=O=>{k.value=O},R=O=>{p.value=O},Y=O=>{u.value=O},L=(O,oe)=>{g.value[oe]=O},B=e.ref({}),S=e.ref([]),$=e.computed(()=>{if(!S.value.length)return[];const O=ye.value,oe=new Map(O.map(ue=>[ue.id?.toString(),ue]));return S.value.map(ue=>oe.get(ue?.toString())).filter(ue=>!!ue)}),E=e.computed(()=>n.placeholder||"Select..."),N=e.computed(()=>re(m.value)),I=e.computed(()=>a.value?!1:l.value?S.value.length>0:!!i.value),v=O=>l.value?S.value.some(oe=>oe?.toString()===O?.toString()):i.value?.toString()===O?.toString(),M=e.computed(()=>{let O=ye.value??[];if(!n.data&&C.value.trim()!==""){const oe=C.value.toLowerCase();O=O.filter(ue=>{const Ve=re(ue).toLowerCase(),Te=ue.text?.toLowerCase?.()||"";return Ve.includes(oe)||Te.includes(oe)})}if(l.value&&S.value.length){const oe=new Set(S.value.map(ue=>ue?.toString()));O=O.filter(ue=>!oe.has(ue.id?.toString()))}return O}),D=e.inject("values"),K=e.inject("field-props"),W=e.computed(()=>n.slot??n?.optionTemplate??""),X=O=>un(O,W.value),re=O=>pn(O,W.value),Ce=e.computed(()=>sn(W.value)),ge=O=>Ht(O),te=O=>!!(!Ce.value&&Et(O)&&!ge(O)),se=O=>{const oe=Et(O);return oe?{color:oe}:void 0},we=O=>!!(!Ce.value&&(Ut(O)||ge(O))),J=(O,oe,ue)=>{if(!K)return!1;const Ve=K.value?.[O]??{},Te=(De,at,kt)=>{if(!at.length)return De;const[st,...dt]=at,it={...De};if(!dt.length)return it[st]=kt,it;const rn=typeof De[st]=="object"&&De[st]!==null?De[st]:{};return it[st]=Te(rn,dt,kt),it},Oe=Te(Ve,oe,ue);return K.value={...K.value||{},[O]:Oe},!0},ce=O=>{if(!n.set)return;const oe=D?.value;!oe&&!K||Object.entries(n.set).forEach(([ue,Ve])=>{if(!ue)return;const Te=O?O[Ve]:null,Oe=ue.split(".").map(kt=>kt.trim()).filter(Boolean);if(!Oe.length)return;const[De,...at]=Oe;at.length&&J(De,at,Te??null)||oe&&(oe[De]=Te??null)})},{optionsList:ye,parentValue:Ee,fetchOptions:Ae,fetchOptionByValue:Re,loadOptions:Fe}=dn({props:n,formValues:D,watchParent:!1}),Be=O=>O==null?"":String(O),j=O=>{if(l.value){if(!S.value.length){ye.value=O;return}}else if(!m.value){ye.value=O;return}const oe=new Set(O.map(Ve=>Be(Ve.id)).filter(Boolean));if(l.value){const Ve=new Set(S.value.map(Oe=>Be(Oe)).filter(Boolean)),Te=(ye.value??[]).filter(Oe=>{const De=Be(Oe.id);return!De||!Ve.has(De)?!1:!oe.has(De)});ye.value=[...Te,...O];return}const ue=Be(m.value?.id);if(ue&&!oe.has(ue)){ye.value=[m.value,...O];return}ye.value=O},Z=async()=>{if(n.data){const O=await Ae(C.value);return j(O),ye.value}return Fe()},ne=async O=>{if(O==null||O==="")return null;const oe=ye.value?.find(ue=>ue?.id?.toString()===String(O));return oe||Re(O)},de=async O=>{const oe=new Set(ye.value.map(Ve=>Ve.id?.toString())),ue=O.filter(Ve=>!oe.has(Ve?.toString()));ue.length&&await ue.reduce(async(Ve,Te)=>{await Ve;const Oe=await ne(Te);Oe&&ye.value.push(Oe)},Promise.resolve())},me=()=>{if(!M.value.length){b.value=-1;return}let O=0;if(!l.value&&m.value){const oe=m.value.id?.toString(),ue=M.value.findIndex(Ve=>Ve.id?.toString()===oe);ue>=0&&(O=ue)}b.value=O,e.nextTick(()=>{U(g.value[O],u.value)})},$e=async()=>{a.value||(h.value=!0,await Z(),await e.nextTick(()=>{H(),k.value?.focus()}),me())},Se=()=>{h.value=!1,b.value=-1,e.nextTick(()=>{k.value?.blur()})},Ne=async O=>{if(a.value)return;(O!==void 0?O:!h.value)?await $e():Se()},Qe=async()=>{if(!a.value){if(h.value){Se();return}await $e()}},Q=()=>{l.value?(S.value=[],i.value=[],r("change",[]),Me(null,[])):(m.value=null,i.value=null,r("change",null),Me(null,null)),ce(null),C.value="",e.nextTick(()=>{k.value?.focus(),h.value||$e()})},ae=O=>{l.value&&(S.value=S.value.filter(oe=>oe?.toString()!==O?.toString()),i.value=[...S.value],r("change",i.value),Me(null),e.nextTick(()=>k.value?.focus()))},Me=(O,oe)=>{const ue=oe??(l.value?[...S.value]:O?.id??null);r("value-selected",{name:n.name,value:ue,option:O})},z=O=>{l.value?(v(O.id)||(S.value=[...S.value,O.id],i.value=[...S.value],r("change",i.value),Me(O)),C.value="",e.nextTick(()=>{k.value?.focus(),b.value=Math.min(b.value,M.value.length-1)}),ce(null)):(m.value=O,i.value=O.id,r("change",i.value),Me(O),C.value="",Se(),ce(O))},q=O=>{if(v(O.id)){l.value||Se();return}z(O)},U=(O,oe)=>{if(!O||!oe)return;const ue=O.offsetTop,Ve=ue+O.offsetHeight,Te=oe.scrollTop,Oe=Te+oe.clientHeight;let De=oe.scrollTop;ue<Te?De=ue-80:Ve>Oe&&(De=Ve-oe.clientHeight+4);const at=oe;at.scrollTop=De},F=O=>{let oe=O.parentElement;for(;oe;){if(oe.classList.contains("ui-dialog__content"))return oe;const ue=window.getComputedStyle(oe),Ve=ue.overflow+ue.overflowY+ue.overflowX;if(Ve.includes("auto")||Ve.includes("scroll")||oe===document.body||oe===document.documentElement)return oe;oe=oe.parentElement}return document.body},H=()=>{if(!d.value)return;const O=d.value.getBoundingClientRect(),oe=window.innerHeight||document.documentElement.clientHeight,ue=window.innerWidth||document.documentElement.clientWidth,Ve=8,Te=8,Oe=n.maxHeight||300,De=oe-O.bottom-Te-Ve,at=O.top-Te-Ve,kt=De>=at,st=Math.max(ue-Ve*2,0);let{width:dt}=O;st>0&&dt>st&&(dt=st);let{left:it}=O;it+dt+Ve>ue&&(it=ue-dt-Ve),it=Math.max(it,Ve);const rn=Math.min(Oe,Math.max(kt?De:at,50));B.value={position:"fixed",left:`${it}px`,width:`${dt}px`,maxHeight:`${rn}px`,transform:kt?"none":"translateY(-100%)",top:kt?`${O.bottom+Te}px`:`${O.top-Te}px`}},ee=async O=>{a.value||!h.value&&(O.key==="ArrowDown"||O.key==="ArrowUp")&&(O.preventDefault(),await $e())},ie=O=>{if(!h.value)return;const{key:oe}=O;if(oe==="ArrowDown")O.preventDefault(),b.value+1<M.value.length&&(b.value+=1,U(g.value[b.value],u.value));else if(oe==="ArrowUp")O.preventDefault(),b.value>0&&(b.value-=1,U(g.value[b.value],u.value));else if(oe==="Enter"){O.preventDefault();const ue=M.value[b.value];ue&&z(ue),k.value?.blur()}else oe==="Escape"?(O.preventDefault(),Se()):oe==="Backspace"?l.value&&C.value===""&&S.value.length&&(S.value=S.value.slice(0,-1),i.value=[...S.value],r("change",i.value)):oe==="Home"?(b.value=0,U(g.value[0],u.value)):oe==="End"?(b.value=M.value.length-1,U(g.value[b.value],u.value)):oe==="Tab"&&Se()},ve=()=>{a.value||(x.value=!0)},et=()=>{x.value=!1,C.value=""},qe=O=>{O.key==="Escape"&&h.value&&Se()},gt=O=>{const oe=O.target;c.value?.contains(oe)||p.value?.contains(oe)||Se()},He=O=>{h.value&&u.value&&!u.value.contains(O.target)&&H()},Ke=()=>{h.value&&H()},yt=()=>{h.value&&H()};async function lt(){if(l.value)Array.isArray(i.value)?S.value=[...i.value]:(S.value=i.value==null?[]:[i.value],i.value=[...S.value]),n.data&&S.value.length&&(await de(S.value),await e.nextTick());else{if(Array.isArray(i.value)){const O=i.value[0]??null;i.value=O??null}i.value!=null&&(m.value=await ne(i.value)),ce(m.value??null)}}e.watch(i,()=>{lt()}),e.onMounted(async()=>{addEventListener("keydown",qe),addEventListener("scroll",He,!0),addEventListener("resize",Ke),document.addEventListener("click",gt,!0),d.value&&F(d.value).addEventListener("scroll",yt,!0),n.options?.length&&!n.data?ye.value=[...n.options]:n.data&&j(await Ae("")),await lt(),tt.value=!1}),e.onUnmounted(()=>{removeEventListener("keydown",qe),removeEventListener("scroll",He,!0),removeEventListener("resize",Ke),document.removeEventListener("click",gt,!0),d.value&&F(d.value).removeEventListener("scroll",yt,!0)});const{isOpenAdd:It,addData:Nt,addSchema:ho,addForm:At,addTitle:Rt,addOption:go,onAddValue:bt}=Mo({props:n,fetchOptionByValue:Re,optionsList:ye,selectedOption:m,modelValue:i});function yo(O,oe=200){let ue;return(...Ve)=>{ue&&clearTimeout(ue),ue=window.setTimeout(()=>O(...Ve),oe)}}const on=yo(async O=>{j(await Ae(O))},200);e.watch(C,O=>{n.data&&on(O.trim())}),e.watch(()=>n.options,O=>{!n.data&&O?.length&&(ye.value=[...O],lt())},{immediate:!0});const tt=e.ref(!0);return e.watch(Ee,async()=>{if(n.data&&(tt.value||(l.value?(S.value=[],i.value=[],r("change",[])):(m.value=null,i.value=null,r("change",null))),await Z(),n.auto===1&&Ee.value&&ye.value.length>0)){const O=ye.value[0];O&&z(O)}}),(O,oe)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(he.VsModal),{visible:e.unref(It),"onUpdate:visible":oe[1]||(oe[1]=ue=>e.isRef(It)?It.value=ue:null),class:"z-[1000]",title:e.unref(Rt),buttonText:"Додати",onDone:e.unref(go),teleport:O.teleport},{default:e.withCtx(()=>[e.createVNode(rt,{schema:e.unref(ho),modelValue:e.unref(Nt),"onUpdate:modelValue":oe[0]||(oe[0]=ue=>e.isRef(Nt)?Nt.value=ue:null),ref_key:"addForm",ref:At},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone","teleport"]),e.createElementVNode("div",{class:"flex gap-1 w-full",ref_key:"selectRoot",ref:c,onClick:oe[4]||(oe[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass])},[oe[5]||(oe[5]=e.createElementVNode("span",{id:"react-select-live-region",class:"sr-only"},null,-1)),oe[6]||(oe[6]=e.createElementVNode("span",{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text",role:"log",class:"sr-only"},null,-1)),e.createVNode(Zs,{keyWord:C.value,"onUpdate:keyWord":oe[2]||(oe[2]=ue=>C.value=ue),disabled:a.value,"is-open":h.value,"input-focus":x.value,"is-multi":l.value,"selected-options":$.value,"selected-ids":S.value,placeholder:E.value,search:s.value,"option-template":W.value,"icon-wrapper-class":Do,"selected-option-label":N.value,"selected-option":m.value,"show-clear":I.value,"set-trigger-ref":w,"set-input-ref":V,"should-show-color-dot":te,"option-has-icon":we,"get-icon-color-style":se,"resolve-option-icon":ge,"render-template":X,"get-label":re,"on-control-keydown":ee,"on-control-click":Qe,"on-input-focus":ve,"on-input-blur":et,"on-input-keydown":ie,"on-remove-selected":ae,"on-clear-selected":Q,"on-toggle-select":Ne},null,8,["keyWord","disabled","is-open","input-focus","is-multi","selected-options","selected-ids","placeholder","search","option-template","selected-option-label","selected-option","show-clear"]),e.createVNode(ni,{"is-open":h.value,"dropdown-style":B.value,"filtered-options-list":M.value,"selected-nav-index":b.value,"option-template":W.value,"icon-wrapper-class":Do,"set-dropdown-ref":R,"set-list-ref":Y,"set-item-ref":L,"is-selected":v,"on-option-click":q,"should-show-color-dot":te,"option-has-icon":we,"get-icon-color-style":se,"resolve-option-icon":ge,"render-template":X},null,8,["is-open","dropdown-style","filtered-options-list","selected-nav-index","option-template"])],2),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:oe[3]||(oe[3]=(...ue)=>e.unref(bt)&&e.unref(bt)(...ue)),class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:a.value,type:"button"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),oe[7]||(oe[7]=e.createElementVNode("span",null,"Додати",-1))],8,oi)):e.createCommentVNode("",!0)],512)],64))}}),[["__scopeId","data-v-3fdc60cb"]]),Gn=(o="")=>`${o}${Math.floor(Math.random()*1e4)}`,ri=["disabled","aria-expanded"],li={class:"truncate"},ai={class:"py-2 px-4"},si={class:"block font-medium text-[13px] text-foreground"},ii={class:"truncate"},ci={class:"p-1 border-t border-gray-200"},di={class:"space-y-0.5 max-h-48 overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-none [&::-webkit-scrollbar-track]:bg-scrollbar-track [&::-webkit-scrollbar-thumb]:bg-scrollbar-thumb"},ui=["onClick"],pi=["checked"],fi={class:"shrink-0 size-3.5 flex justify-center items-center"},mi={key:1,class:"shrink-0 size-2 block mx-auto rounded-full bg-secondary/60"},hi={class:"truncate"},gi={key:0,class:"px-3 py-2 text-xs text-stone-500"},mn=e.defineComponent({__name:"vs-input-inline-select",props:{multiple:{type:Boolean},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t;ze(n.style);const l=e.computed({get:()=>Array.isArray(n.modelValue)?n.modelValue[0]??null:n.modelValue??null,set:J=>r("update:modelValue",J)});l.value==null&&n.defaultValue!=null&&(l.value=n.defaultValue);const a=e.inject("values"),s=e.inject("field-props"),i=e.computed(()=>!!n.disabled),c=e.ref(null),d=e.ref(!1),u=e.ref(null),p=e.ref(null),h=e.ref(null),x=e.ref({}),m=`vs-input-inline-select-${Gn()}`,b=e.computed(()=>n.placeholder||"Оберіть значення"),g=e.computed(()=>R(c.value)||n.placeholder||"Оберіть значення"),C=e.computed(()=>n.slot??""),k=e.computed(()=>sn(C.value)),w=e.computed(()=>n.teleport||"body"),V=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6}|[\da-fA-F]{8})$/,R=J=>pn(J,C.value),Y=J=>!!(!k.value&&Et(J)),L=e.computed(()=>{const J=Et(c.value).trim();return J?V.test(J)?`bg-[${J}] border-[${J}]`:`bg-${J.toLowerCase()}-500 border-${J.toLowerCase()}-500`:""}),{optionsList:B,parentValue:S,fetchOptions:$,fetchOptionByValue:E,loadOptions:N}=dn({props:n,formValues:a,watchParent:!1}),I=(J,ce,ye)=>{if(!s)return!1;const Ee=s.value?.[J]??{},Ae=(Fe,Be,j)=>{if(!Be.length)return Fe;const[Z,...ne]=Be,de={...Fe};if(!ne.length)return de[Z]=j,de;const me=typeof Fe[Z]=="object"&&Fe[Z]!==null?Fe[Z]:{};return de[Z]=Ae(me,ne,j),de},Re=Ae(Ee,ce,ye);return s.value={...s.value||{},[J]:Re},!0},v=J=>{if(!n.set)return;const ce=a?.value;!ce&&!s||Object.entries(n.set).forEach(([ye,Ee])=>{if(!ye)return;const Ae=J?J[Ee]:null,Re=ye.split(".").map(j=>j.trim()).filter(Boolean);if(!Re.length)return;const[Fe,...Be]=Re;Be.length&&I(Fe,Be,Ae??null)||ce&&(ce[Fe]=Ae??null)})},M=J=>l.value?.toString?.()===J?.toString?.(),D=()=>{if(!p.value||typeof window>"u")return;const J=p.value.getBoundingClientRect(),ce=8,ye=8,Ee=window.innerHeight||document.documentElement.clientHeight,Ae=window.innerWidth||document.documentElement.clientWidth,Re=h.value?.offsetHeight||260,Fe=Math.max(J.width,176),Be=Math.max(Ae-ce*2,120),j=Math.min(Fe,Be);let Z=J.left;Z+j+ce>Ae&&(Z=Ae-j-ce),Z=Math.max(Z,ce);const ne=Ee-J.bottom-ye-ce,de=J.top-ye-ce,me=ne<Math.min(Re,260)&&de>ne,$e=Math.max(120,Math.min(320,me?de:ne));x.value={position:"fixed",left:`${Z}px`,top:me?`${J.top-ye}px`:`${J.bottom+ye}px`,transform:me?"translateY(-100%)":"none",width:`${j}px`,maxHeight:`${$e}px`}},K=async()=>{if(n.data){B.value=await $("");return}await N()},W=async()=>{if(l.value==null||l.value===""){c.value=null,v(null);return}const J=B.value.find(ce=>ce.id?.toString()===String(l.value));if(J){c.value=J,v(J);return}c.value=await E(l.value),v(c.value??null)},X=async()=>{i.value||(d.value=!0,await K(),await e.nextTick(),D())},re=()=>{d.value=!1},Ce=async()=>{if(d.value){re();return}await X()},ge=J=>{r("value-selected",{name:n.name,value:J?.id??null,option:J})},te=J=>{c.value=J,l.value=J.id,r("change",J.id),ge(J),v(J),re()},se=J=>{const ce=J.target;u.value?.contains(ce)||h.value?.contains(ce)||re()},we=()=>{d.value&&D()};return e.watch(()=>n.options,J=>{n.data||(B.value=J?[...J]:[],W())},{immediate:!0,deep:!0}),e.watch(l,()=>{W()}),e.watch(S,async()=>{n.data&&(await K(),c.value&&!B.value.some(J=>J.id?.toString()===c.value?.id?.toString())&&(c.value=null,l.value=null,r("change",null),ge(null),v(null)))}),e.onMounted(async()=>{document.addEventListener("click",se,!0),window.addEventListener("resize",we),window.addEventListener("scroll",we,!0),await K(),await W()}),e.onUnmounted(()=>{document.removeEventListener("click",se,!0),window.removeEventListener("resize",we),window.removeEventListener("scroll",we,!0)}),(J,ce)=>(e.openBlock(),e.createElementBlock("div",{class:"relative inline-flex w-full max-w-full",ref_key:"rootRef",ref:u,onClick:ce[0]||(ce[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("button",{ref_key:"triggerRef",ref:p,type:"button",disabled:i.value,"aria-expanded":d.value?"true":"false","aria-haspopup":"menu",class:e.normalizeClass(["py-1.5 px-2.5 inline-flex items-center gap-2 text-nowrap text-xs sm:text-[13px] rounded-lg focus:outline-hidden disabled:opacity-50 disabled:pointer-events-none max-w-full border",L.value?`${L.value} text-white`:"bg-secondary text-secondary-foreground hover:bg-secondary-hover focus:bg-secondary-focus border-gray-300 hover:border-gray-400"]),onClick:Ce},[e.createElementVNode("span",li,e.toDisplayString(g.value),1)],10,ri),(e.openBlock(),e.createBlock(e.Teleport,{to:w.value},[d.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:h,class:"z-[3000] w-44 transition-[opacity,margin] duration-150 bg-white text-gray-900 border border-gray-200 rounded-xl shadow-lg",style:e.normalizeStyle(x.value),role:"menu","aria-orientation":"vertical"},[e.createElementVNode("div",ai,[e.createElementVNode("span",si,[e.createElementVNode("span",ii,e.toDisplayString(b.value),1)])]),e.createElementVNode("div",ci,[e.createElementVNode("div",di,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(B),ye=>(e.openBlock(),e.createElementBlock("label",{key:ye.id,class:"py-1.5 px-3 group flex items-center gap-x-3 rounded-lg cursor-pointer text-[13px] text-gray-800 hover:bg-gray-100",onClick:e.withModifiers(Ee=>te(ye),["prevent"])},[e.createElementVNode("input",{type:"radio",class:"hidden",name:m,checked:M(ye.id),tabindex:"-1"},null,8,pi),e.createElementVNode("span",fi,[Y(ye)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"shrink-0 size-2 block mx-auto rounded-full",style:e.normalizeStyle({backgroundColor:ye.color})},null,4)):(e.openBlock(),e.createElementBlock("span",mi))]),e.createElementVNode("span",hi,e.toDisplayString(R(ye)),1),e.createVNode(e.unref(P.Check),{class:e.normalizeClass(["shrink-0 size-3.5 ms-auto transition-opacity",M(ye.id)?"opacity-100":"opacity-0"])},null,8,["class"])],8,ui))),128))]),e.unref(B).length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",gi,"Немає варіантів"))])],4)):e.createCommentVNode("",!0)],8,["to"]))],512))}}),yi=["placeholder","disabled"],To=e.defineComponent({__name:"vs-input-textarea",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=ze(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");function s(){typeof r.value=="string"&&(r.value=r.value.trim())}return(i,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{"onUpdate:modelValue":c[0]||(c[0]=d=>r.value=d),placeholder:a.value,disabled:l.value,row:"2",onBlur:s,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] h-auto bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,42,yi)),[[e.vModelText,r.value]])}}),Lo=e.defineComponent({__name:"vs-input-richtext",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},format:{default:"html"},richtextProps:{default:()=>({})}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.defineAsyncComponent(()=>Promise.resolve().then(()=>u0)),n=o,{inputClass:r}=ze(n.style),l=e.useModel(o,"modelValue"),a=e.computed(()=>!!n.disabled),s=e.computed(()=>n.placeholder??""),i=e.computed(()=>({height:n.richtextProps.height||"300px",format:n.format,...n.richtextProps}));return(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["!h-full",[c.customClass,e.unref(r)]]),style:e.normalizeStyle(a.value?{pointerEvents:"none",opacity:.6}:{})},[e.createVNode(e.unref(t),e.mergeProps({modelValue:l.value,"onUpdate:modelValue":d[0]||(d[0]=u=>l.value=u),placeholder:s.value},i.value),null,16,["modelValue","placeholder"])],6))}}),bi={},ki={viewBox:"0 0 178 90",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function xi(o,t){return e.openBlock(),e.createElementBlock("svg",ki,t[0]||(t[0]=[e.createStaticVNode('<rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs>',12)]))}const wi=xe(bi,[["render",xi]]),_i={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden flex flex-col"},Ci={key:0,class:"flex flex-col gap-2 !p-4 border-b border-gray-200 md:flex-row md:items-center md:justify-between bg-gray-50"},vi={key:0,class:"relative flex-1 min-w-0"},Ei={class:"flex flex-nowrap items-center justify-end gap-2 shrink-0"},Bi={class:"w-full overflow-x-auto"},Vi={class:"w-full min-w-[640px] table-auto divide-y divide-gray-200"},Si={class:"bg-gray-50"},$i={class:"border-b border-gray-200"},Ni={class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 w-12 text-center"},Ai=["onClick"],Fi={key:0,class:"text-gray-400"},Mi={key:0,colspan:"100%",class:"text-center"},Di={class:"w-full"},Ti={class:"p-5 min-h-[200px] flex flex-col justify-center items-center text-center"},Li=["onDragstart","onDragover","onDrop"],Ii={class:"px-4 py-3 text-center align-middle"},Ri={class:"flex items-center justify-center"},Oi=["innerHTML"],zi={key:0,class:"flex items-center gap-3 text-sm text-gray-700"},Pi={key:0},ji=["src"],Ui={key:1,class:"rounded-md max-w-[45px] w-[45px] max-h-[45px] h-[45px] bg-gray-200 flex items-center justify-center"},Hi={key:1,class:"flex items-center justify-center"},qi={key:2,class:"text-sm font-medium text-gray-900"},Ki={class:"px-4 py-3 text-right whitespace-nowrap"},Wi={class:"flex items-center justify-end gap-2"},Gi=["onClick"],Yi=["onClick"],Xi={class:"vs-form__head mr-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},Io=e.defineComponent({__name:"vs-input-datatable",props:e.mergeModels({actions:{},colModel:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useSlots(),r=j=>t.actions===void 0?!0:t.actions.includes(j),l=["search","import","export","add"],a=e.computed(()=>l.some(j=>r(j))),s=e.useModel(o,"modelValue"),i=e.ref({}),c=e.ref(""),d=e.ref(null),u=e.ref("asc"),p=e.computed(()=>{const j=s.value??[],Z=c.value?j.filter(me=>h.value?.some($e=>{const Se=$e.key||$e.name;if(!Se)return!1;const Ne=me[Se];return Ne?Array.isArray(Ne)?Ne.join(", ").toLowerCase().includes(c.value.toLowerCase()):String(Ne).toLowerCase().includes(c.value.toLowerCase()):!1})):j;if(!d.value)return Z;const ne=d.value,de=[...Z].sort((me,$e)=>{const Se=se(me?.[ne]),Ne=se($e?.[ne]);return typeof Se=="number"&&typeof Ne=="number"?Se-Ne:String(Se).localeCompare(String(Ne))});return u.value==="asc"?de:de.reverse()}),h=e.computed(()=>(t.colModel??[]).filter(j=>!j.tableHidden)),x=e.ref(null),m=e.ref(null),b=e.ref(null),g=j=>{x.value=j},C=j=>{m.value=j},k=j=>{if(x.value===null||x.value===j){x.value=null,m.value=null;return}const Z=[...s.value],[ne]=Z.splice(x.value,1);Z.splice(j,0,ne),s.value=Z,x.value=null,m.value=null},w=()=>{b.value&&b.value.click()},V=j=>{const Z=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tif"],ne=j.toLowerCase();return Z.some(de=>ne.endsWith(de))},R=j=>{const ne=j.target.files?.[0];if(!ne)return;const de=new FileReader;de.onload=me=>{try{const $e=me.target?.result;if(typeof $e=="string"){const Se=JSON.parse($e);Array.isArray(Se)&&s.value.push(...Se)}}catch($e){console.error("Error parsing file:",$e)}},de.readAsText(ne)},Y=()=>{const j=JSON.stringify(s.value,null,2),Z=new Blob([j],{type:"application/json"}),ne=URL.createObjectURL(Z),de=document.createElement("a");de.href=ne,de.download="data.json",de.click(),URL.revokeObjectURL(ne)},L=new Set(["autocomplete","select","radio","checkbox","combobox"]),B=new Map,S=(j,Z)=>{const ne=`/api/suggest/${j}`,de=ne.includes("?")?"&":"?",me=Z?`&val=${Z}`:"";return`${ne}${de}json=1${me}`},$=j=>j==null||j===""?null:typeof j=="object"?j?.id!==void 0&&j.id!==null&&j.id!==""?j.id:null:j,E=j=>{const Z=new Set;return Array.isArray(s.value)&&s.value.forEach(ne=>{const de=ne?.[j];if(de==null||de==="")return;if(Array.isArray(de)){de.forEach($e=>{const Se=$($e);Se!==null&&Z.add(Se)});return}const me=$(de);me!==null&&Z.add(me)}),Z},N=async()=>{if(!t.colModel?.length)return;const j=t.colModel.filter(Z=>Z.data&&L.has(Z.type?.toLowerCase()||""));j.length&&await Promise.all(j.map(async Z=>{const ne=Z.key||Z.name;if(!ne)return;const de=E(ne),me=Array.from(de).map(Ne=>String(Ne)).sort(),$e=me.join(",");if(!me.length||B.get(ne)===$e)return;B.set(ne,$e);const Se=me.map(encodeURIComponent).join(",");try{const Qe=await(await fetch(S(Z.data,Se))).json();i.value[ne]=Qe?.data??Qe}catch(Ne){console.error("Failed to fetch column values",Ne)}}))};e.watch([()=>t.colModel,()=>s.value],()=>{N()},{immediate:!0,deep:!0});const I=e.ref(""),v=e.ref(!1);let M="edit",D=0;const K=j=>(j?.format||j?.type||"").toString().toLowerCase(),W=e.computed(()=>(t.colModel?.filter(Z=>K(Z)!=="slot")??[]).map(Z=>{const ne=Z.key||Z.name;return ne?{...Z,name:ne,key:ne}:Z})),X=e.ref({}),re=e.ref({}),Ce=j=>typeof j!="string"?!1:!!n[j],ge=(j,Z)=>Z?Z.split(".").reduce((ne,de)=>ne==null?ne:ne[de.trim()],j):j,te=(j,Z)=>typeof j!="string"?"":j.replace(/{{\s*([^}]+)\s*}}/g,(ne,de)=>{const me=ge(Z,de.trim());return me??""}),se=j=>{if(j==null||j==="")return"";if(typeof j=="number")return j;if(typeof j=="boolean")return j?1:0;if(typeof j=="string")return j.toLowerCase();if(Array.isArray(j))return j.map(Z=>se(Z)).join(", ");if(typeof j=="object"){if(j.text!==void 0)return String(j.text).toLowerCase();if(j.label!==void 0)return String(j.label).toLowerCase();if(j.id!==void 0)return String(j.id).toLowerCase()}return String(j).toLowerCase()},we=j=>{const Z=j.key||j.name;if(Z){if(d.value===Z){u.value=u.value==="asc"?"desc":"asc";return}d.value=Z,u.value="asc"}};async function J(){I.value="Додати",v.value=!0,M="add",X.value={}}function ce(j,Z){if(!j?.length)return null;const ne=typeof Z=="object"?Z?.id:Z;return ne==null||ne===""?null:j.find(de=>de?.id?.toString()===ne.toString())?.text??null}function ye(j){return j==null||j===""?"-":Array.isArray(j)?j.map(Z=>typeof Z=="object"?Z?.text??Z?.id??"-":Z).join(", "):typeof j=="object"?j?.text??j?.id??"-":j}function Ee(j,Z){const ne=Z.key||Z.name,de=j?.[ne],me=i.value[ne];if(!de)return"-";if(Array.isArray(de)){const Se=de.map(Ne=>ce(me,Ne)).filter(Boolean);return Se.length?Se.join(", "):ye(de)}const $e=ce(me,de);return $e||ye(de)}async function Ae(j,Z){I.value="Редагувати",v.value=!0,M="edit",D=Z,X.value={...j}}function Re(){const j=re.value.validate();if(j){he.notify({type:"warning",title:"Помилка валідації",message:Object.entries(j).map(([Z,ne])=>`${Z}: ${ne}`).join(`
2
2
  `)});return}M==="add"?Array.isArray(s.value)?s.value=[...s.value,X.value]:s.value=[X.value]:s.value=s.value.map((Z,ne)=>ne===D?X.value:Z),v.value=!1}function Fe(j){s.value=s.value.filter((Z,ne)=>ne!==j)}function Be(){v.value=!1}return(j,Z)=>(e.openBlock(),e.createElementBlock("div",_i,[a.value?(e.openBlock(),e.createElementBlock("div",Ci,[r("search")?(e.openBlock(),e.createElementBlock("div",vi,[e.createVNode(e.unref(P.Search),{class:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-gray-400"}),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":Z[0]||(Z[0]=ne=>c.value=ne),placeholder:"Пошук",class:"w-full rounded-md border border-gray-200 bg-white pl-10 pr-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100"},null,512),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),e.createElementVNode("div",Ei,[r("import")?(e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"fileInput",ref:b,onChange:R,class:"hidden",accept:".json",type:"file"},null,544)):e.createCommentVNode("",!0),r("import")?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",onClick:w,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(P.Upload),{class:"h-4 w-4 text-gray-700"}),Z[4]||(Z[4]=e.createTextVNode(" Імпорт ",-1))])):e.createCommentVNode("",!0),r("export")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:Y,class:"inline-flex items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:border-gray-300 hover:bg-gray-50 transition-colors"},[e.createVNode(e.unref(P.Download),{class:"h-4 w-4 text-gray-700"}),Z[5]||(Z[5]=e.createTextVNode(" Експорт ",-1))])):e.createCommentVNode("",!0),r("add")?(e.openBlock(),e.createElementBlock("button",{key:3,onClick:J,type:"button",class:"inline-flex items-center gap-2 rounded-md bg-blue-500 px-3 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-600 transition-colors"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4 text-white"}),Z[6]||(Z[6]=e.createTextVNode(" Додати ",-1))])):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Bi,[e.createElementVNode("table",Vi,[e.createElementVNode("thead",Si,[e.createElementVNode("tr",$i,[e.createElementVNode("th",Ni,[e.createVNode(e.unref(P.GripVertical),{class:"mx-auto h-4 w-4 text-gray-400"})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,ne=>(e.openBlock(),e.createElementBlock("th",{key:ne.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[e.createElementVNode("button",{type:"button",onClick:de=>we(ne),class:"flex items-center gap-1 text-xs font-semibold text-gray-700 hover:text-gray-900 transition-colors"},[e.createElementVNode("span",null,e.toDisplayString(ne.ua||ne.label),1),d.value===(ne.key||ne.name)?(e.openBlock(),e.createElementBlock("span",Fi,e.toDisplayString(u.value==="asc"?"▲":"▼"),1)):e.createCommentVNode("",!0)],8,Ai)]))),128)),Z[7]||(Z[7]=e.createElementVNode("th",{class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 text-center w-[1%] whitespace-nowrap"}," Дії ",-1))])]),e.createElementVNode("tbody",{class:e.normalizeClass(["divide-y divide-gray-200",{"[&_tr:last-child]:border-0":!m.value}])},[p.value.length===0?(e.openBlock(),e.createElementBlock("td",Mi,[e.createElementVNode("div",Di,[e.createElementVNode("div",Ti,[e.createVNode(wi,{class:"w-48 mx-auto"}),Z[8]||(Z[8]=e.createElementVNode("div",{class:"max-w-sm mx-auto mt-6"},[e.createElementVNode("p",{class:"font-medium text-gray-800 dark:text-neutral-200"},"Нічого не знайдено"),e.createElementVNode("p",{class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"})],-1))])])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(ne,de)=>(e.openBlock(),e.createElementBlock("tr",{key:ne.id,class:e.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":x.value===de,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":m.value===de}]),draggable:"true",onDragstart:me=>g(de),onDragover:e.withModifiers(me=>C(de),["prevent"]),onDrop:me=>k(de)},[e.createElementVNode("td",Ii,[e.createElementVNode("div",Ri,[e.createVNode(e.unref(P.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,me=>(e.openBlock(),e.createElementBlock("td",{key:me.key,class:"px-4 py-3 align-middle"},[K(me)==="slot"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[Ce(me.slot)?e.renderSlot(j.$slots,me.slot,{key:0,row:ne,value:ne[me.key],column:me}):(e.openBlock(),e.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:te(me.slot,ne)},null,8,Oi))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[K(me)==="file"?(e.openBlock(),e.createElementBlock("div",zi,[V(Ee(ne,me))?(e.openBlock(),e.createElementBlock("div",Pi,[e.createElementVNode("img",{src:Ee(ne,me),alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,ji)])):(e.openBlock(),e.createElementBlock("div",Ui,[e.createVNode(e.unref(P.FileText),{class:"h-4 w-4 min-w-4"})]))])):K(me)==="color"?(e.openBlock(),e.createElementBlock("div",Hi,[e.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:e.normalizeStyle({backgroundColor:Ee(ne,me)||"#ffffff"})},null,4)])):(e.openBlock(),e.createElementBlock("div",qi,e.toDisplayString(Ee(ne,me)),1))],64))]))),128)),e.createElementVNode("td",Ki,[e.createElementVNode("div",Wi,[e.createElementVNode("button",{onClick:me=>Ae(ne,de),class:"p-1.5 text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors"},[e.createVNode(e.unref(P.Pencil),{class:"h-4 w-4"})],8,Gi),e.createElementVNode("button",{onClick:me=>Fe(de),class:"p-1.5 text-gray-600 hover:text-red-600 hover:bg-red-50 rounded transition-colors"},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})],8,Yi)])])],42,Li))),128))],2)])]),e.createVNode(e.unref(he.VsModal),{visible:v.value,title:I.value,size:"lg",onClose:Be,teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(rt,{schema:W.value,"form-id":"datatable-row",values:X.value,"onUpdate:values":Z[1]||(Z[1]=ne=>X.value=ne),form:re.value,"onUpdate:form":Z[2]||(Z[2]=ne=>re.value=ne)},null,8,["schema","values","form"]),e.createElementVNode("div",Xi,[e.createElementVNode("button",{type:"button",onClick:Z[3]||(Z[3]=ne=>v.value=!1),class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:Re,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])]),_:1},8,["visible","title"])]))}}),Zi={},Ji={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none","stroke-width":"2",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-line"};function Qi(o,t){return e.openBlock(),e.createElementBlock("svg",Ji,t[0]||(t[0]=[e.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),e.createElementVNode("path",{d:"M6 18m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M18 6m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"},null,-1),e.createElementVNode("path",{d:"M7.5 16.5l9 -9"},null,-1)]))}const ec=xe(Zi,[["render",Qi]]),tc={},nc={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:"icon icon-tabler icons-tabler-outline icon-tabler-polygon"};function oc(o,t){return e.openBlock(),e.createElementBlock("svg",nc,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 5m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M19 8m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M5 11m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M15 19m-2 0a2 2 0 1 0 4 0a2 2 0 1 0 -4 0"></path><path d="M6.5 9.5l3.5 -3"></path><path d="M14 5.5l3 1.5"></path><path d="M18.5 10l-2.5 7"></path><path d="M13.5 17.5l-7 -5"></path>',9)]))}const rc=xe(tc,[["render",oc]]),lc={},ac={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:"icon icon-tabler icons-tabler-outline icon-tabler-topology-ring-3"};function sc(o,t){return e.openBlock(),e.createElementBlock("svg",ac,t[0]||(t[0]=[e.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M8 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 18a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M20 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M8 6a2 2 0 1 0 -4 0a2 2 0 0 0 4 0z"></path><path d="M6 8v8"></path><path d="M18 16v-8"></path><path d="M8 6h8"></path><path d="M16 18h-8"></path>',9)]))}const ic=xe(lc,[["render",sc]]),cc={class:"bg-white/30 p-1 rounded-md shadow w-fit"},dc={class:"flex gap-2"},uc=["onClick","title"],pc=["src"],fc=e.defineComponent({__name:"map-layers",props:{basemaps:{}},emits:["onLayerChange"],setup(o,{emit:t}){const n=o,r=e.ref(Object.keys(n.basemaps)[0]),l=t;function a(c){l("onLayerChange",c),r.value=c}const s={z:13,x:4790,y:2762};function i(c){if(c?.preview)return c.preview;if(!c?.url)return;const d={"{z}":s.z,"{x}":s.x,"{y}":s.y};let u=c.url;return Object.entries(d).forEach(([p,h])=>{u=u.replace(new RegExp(p,"gi"),String(h))}),u}return(c,d)=>(e.openBlock(),e.createElementBlock("div",cc,[e.createElementVNode("div",dc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.basemaps,(u,p)=>(e.openBlock(),e.createElementBlock("div",{key:p,class:e.normalizeClass(["cursor-pointer border rounded-lg overflow-hidden hover:shadow-sm",{"ring-2 ring-blue-500 border-blue-300":r.value===p}]),onClick:h=>a(p),title:u.name||p,role:"button",tabindex:"0"},[e.createElementVNode("img",{src:i(u),alt:"",class:"w-10 h-10 object-cover"},null,8,pc)],10,uc))),128))])]))}}),Mt=1e-10,hn=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,mc=/^[+-]?\d+(?:\.\d+)?$/;function hc(o,t,n){const r=o.split(/\r?\n/).map(d=>d.trim()).filter(Boolean);if(r.length<3)return{ok:!1,errors:[{line:0,message:"Має бути щонайменше 3 рядки координат."}]};if(r.length>100)return{ok:!1,errors:[{line:0,message:"Допускається не більше 100 рядків координат."}]};const l=[],a=[];if(r.forEach((d,u)=>{const p=u+1,h=t==="decimal"?gc(d,p,n):Oo(d,p,n);if(!h.ok){l.push(...h.errors);return}const x=a[a.length-1];if(x&&Po(x,h.point)){l.push({line:p,message:"Послідовні точки не повинні дублюватися."});return}a.push(h.point)}),l.length)return{ok:!1,errors:l};if(new Set(a.map(bc)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const i=[...a];let c=!1;return Po(i[0],i[i.length-1])||(i.push(i[0]),c=!0),kc(i)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:i,wasClosedAutomatically:c}}function gc(o,t,n){return Ro(o,"decimal",n,t)}function Ro(o,t,n,r=1){return t==="decimal"?yc(o,r,n):Oo(o,r,n)}function yc(o,t,n){const r=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(o))return{ok:!1,errors:[{line:t,message:"У десятковому форматі не допускаються літери."}]};const l=o.split(/[\s,;]+/).filter(Boolean);if(l.length<2)return{ok:!1,errors:[{line:t,message:"Кожен рядок має містити дві координати."}]};if(l.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(!l.every(d=>mc.test(d)))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const a=Number(l[0]),s=Number(l[1]);if(!Number.isFinite(a)||!Number.isFinite(s))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const i=n==="lat-lon"?a:s,c=n==="lat-lon"?s:a;return(i<-90||i>90)&&r.push({line:t,message:"Широта поза діапазоном (-90..90)."}),(c<-180||c>180)&&r.push({line:t,message:"Довгота поза діапазоном (-180..180)."}),r.length?{ok:!1,errors:r}:{ok:!0,point:[c,i]}}function Oo(o,t,n){hn.lastIndex=0;const r=[...o.matchAll(hn)];if(r.length<2)return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати DMS-координати."}]};if(r.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(hn.lastIndex=0,o.replace(hn," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:t,message:"У рядку виявлено зайві символи або значення."}]};const a=zo(r[0],t,n==="lat-lon"?"lat":"lon"),s=zo(r[1],t,n==="lat-lon"?"lon":"lat"),i=[];if(a.ok||i.push(a.error),s.ok||i.push(s.error),i.length)return{ok:!1,errors:i};const c=n==="lat-lon"?a.value:s.value;return{ok:!0,point:[n==="lat-lon"?s.value:a.value,c]}}function zo(o,t,n){const r=Number(o[1]),l=Number(o[2]),a=Number(o[3]),s=String(o[4]).toUpperCase();if(!Number.isFinite(r)||!Number.isFinite(l)||!Number.isFinite(a))return{ok:!1,error:{line:t,message:"Невірні значення DMS-координат."}};if(n==="lat"&&!(s==="N"||s==="S")||n==="lon"&&!(s==="E"||s==="W"))return{ok:!1,error:{line:t,message:n==="lat"?"Для широти напрям повинен бути N або S.":"Для довготи напрям повинен бути E або W."}};if(l<0||l>59)return{ok:!1,error:{line:t,message:"Хвилини повинні бути в діапазоні 0..59."}};if(a<0||a>60)return{ok:!1,error:{line:t,message:"Секунди повинні бути в діапазоні 0..60."}};const d=Math.abs(r),u=n==="lat"?90:180;if(d>u)return{ok:!1,error:{line:t,message:n==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===u&&(l!==0||a!==0))return{ok:!1,error:{line:t,message:n==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const p=d+l/60+a/3600;return{ok:!0,value:s==="S"||s==="W"?-p:p}}function bc(o){return`${o[0].toFixed(12)}:${o[1].toFixed(12)}`}function Po(o,t){return Math.abs(o[0]-t[0])<Mt&&Math.abs(o[1]-t[1])<Mt}function kc(o){if(o.length<4)return!1;for(let t=0;t<o.length-1;t+=1){const n=o[t],r=o[t+1];for(let l=t+1;l<o.length-1;l+=1){if(Math.abs(t-l)<=1||t===0&&l===o.length-2)continue;const a=o[l],s=o[l+1];if(xc(n,r,a,s))return!0}}return!1}function xc(o,t,n,r){const l=gn(o,t,n),a=gn(o,t,r),s=gn(n,r,o),i=gn(n,r,t);return!!(l!==a&&s!==i||l===0&&yn(o,n,t)||a===0&&yn(o,r,t)||s===0&&yn(n,o,r)||i===0&&yn(n,t,r))}function gn(o,t,n){const r=(t[1]-o[1])*(n[0]-t[0])-(t[0]-o[0])*(n[1]-t[1]);return Math.abs(r)<Mt?0:r>0?1:2}function yn(o,t,n){return t[0]<=Math.max(o[0],n[0])+Mt&&t[0]+Mt>=Math.min(o[0],n[0])&&t[1]<=Math.max(o[1],n[1])+Mt&&t[1]+Mt>=Math.min(o[1],n[1])}const wc=["title"],_c={key:0,class:"vs-select__options absolute z-50 mt-1 w-auto min-w-full bg-white border border-gray-300 shadow-lg rounded-lg text-sm text-gray-900"},Cc=["onClick"],vc=["placeholder"],Ec={class:"absolute inset-y-0 right-2 flex items-center gap-1"},Bc={class:"flex items-center justify-between gap-2 px-3 py-2 border-b border-gray-100"},Vc={class:"text-xs font-semibold uppercase tracking-wide text-gray-500"},Sc={class:"max-h-[260px] overflow-auto"},$c={key:0,class:"divide-y divide-gray-100"},Nc=["onClick"],Ac={key:1,class:"px-3 py-3 text-xs text-gray-500"},jo="formMapSearchAddressHistory",Fc=12,Mc="https://geo.rv.ua/api-user/dzk.api",Dc="https://nominatim.openstreetmap.org/search",Tc=xe(e.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(o,{emit:t}){const n={mounted(z,q){if(typeof document>"u")return;let U=null;const F=8,H=()=>{const ie=String(q?.value??"");if(!ie)return;U=document.createElement("div"),U.textContent=ie,Object.assign(U.style,{position:"absolute",background:"#333",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"9999"}),document.body.appendChild(U);const ve=z.getBoundingClientRect();U.style.left=`${ve.right+window.scrollX+F}px`,U.style.top=`${ve.top+window.scrollY+(ve.height-U.offsetHeight)/2}px`},ee=()=>{U?.parentNode&&U.parentNode.removeChild(U),U=null};z.addEventListener("mouseenter",H),z.addEventListener("mouseleave",ee),Object.assign(z,{tooltipRightHandlers:{show:H,hide:ee}})},unmounted(z){if(typeof document>"u")return;const q=z.tooltipRightHandlers;q&&(z.removeEventListener("mouseenter",q.show),z.removeEventListener("mouseleave",q.hide))}},r=o,l=t,a=e.getCurrentInstance();function s(){return typeof globalThis<"u"&&globalThis.proxy?globalThis.proxy:typeof window<"u"&&window.proxy?window.proxy:null}function i(){const q=a?.appContext.config.globalProperties?.$settings?.map?.searchViewbox;if(q)return Array.isArray(q)?q.join(","):String(q);const F=s()?.map?.searchViewbox;if(F)return Array.isArray(F)?F.join(","):String(F)}function c(){const q=a?.appContext.config.globalProperties?.$settings?.map?.addressSuggest;if(typeof q=="string"&&q.trim())return q.trim();const F=s()?.map?.addressSuggest;if(typeof F=="string"&&F.trim())return F.trim()}const d=!!c(),u=!!i(),p=e.computed(()=>{const z=["nominatim","xy","parcel"];return d&&z.unshift("address"),u?z:z.filter(q=>q!=="nominatim")}),h=e.computed(()=>{const z=p.value,q=r.config?.tools?.filter(U=>z.includes(U));return q&&q.length?q:z}),x=e.computed(()=>r.config?.placeholder?.trim()||"Пошук…"),m=e.ref(h.value[0]);e.watch(h,z=>{z.includes(m.value)||(m.value=z[0])});const b=e.ref(""),g=e.ref(!1),C=e.ref(null),k=e.ref(null),w=e.ref(null),V=e.ref(null),R=e.ref([]),Y=e.ref(null),L=e.ref(!1),B=e.ref([]),S=e.computed(()=>(m.value==="address"||m.value==="nominatim")&&L.value),$=e.computed(()=>r.config?.addressDebounceMs??1e3);let E=null;const N=e.ref(!1),I=e.computed(()=>b.value.trim().length>0?R.value:B.value),v=e.computed(()=>b.value.trim().length?`Знайдено ${R.value.length}`:"Історія пошуку"),M=e.computed(()=>b.value.trim().length?"Нічого не знайдено":"Історія порожня");function D(){if(typeof window>"u")return[];try{const z=window.localStorage?.getItem?.(jo);if(!z)return[];const q=JSON.parse(z);return Array.isArray(q)?q:[]}catch{return[]}}function K(z){typeof window>"u"||window.localStorage?.setItem?.(jo,JSON.stringify(z))}function W(z){const U=[z,...B.value.filter(F=>F.id!==z.id)].slice(0,10);B.value=U,K(U)}const X=e.reactive({position:"absolute",left:"0px",top:"0px",width:"100%",display:"none"});function re(){if(!V.value)return;const z=V.value.getBoundingClientRect(),q=w.value?.getBoundingClientRect(),U=q?.width??z.width,F=(q?.left??z.left)+window.scrollX,H=z.bottom+window.scrollY+Fc;X.left=`${F}px`,X.top=`${H}px`,X.width=`${U}px`,X.display="block"}const Ce=()=>{S.value&&re()};function ge(){E&&(clearTimeout(E),E=null)}e.watch(m,()=>{b.value="",g.value=!1,R.value=[],L.value=!1,ge(),N.value=!1}),e.watch(S,z=>{z?e.nextTick(()=>{re()}):X.display="none"}),e.watch(b,z=>{if(m.value!=="address"&&m.value!=="nominatim"){R.value=[],ge();return}if(!z.trim()){R.value=[],L.value=B.value.length>0,ge();return}ge(),L.value=!0,E=window.setTimeout(()=>{Se(z).catch(q=>{const U=q?.message||"Помилка пошуку адреси";he.notify({type:"error",title:"Пошук адреси",message:U})})},$.value)});function te(z){const q=[];k.value&&q.push(k.value),z instanceof HTMLElement&&q.push(z),C.value?.querySelectorAll("li")?.forEach(F=>{q.push(F)}),q.forEach(F=>{F.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))})}function se(z){g.value&&te(z.target),g.value=!g.value}function we(z,q){te(q?.target),m.value=z}function J(){b.value="",R.value=[],L.value=!1,N.value=!1}function ce(z){const q=z.target;if(g.value){const U=C.value;U&&!U.contains(q)&&(te(q),g.value=!1)}if(S.value){const U=Y.value,F=V.value;U&&!U.contains(q)&&(!F||!F.contains(q))&&(L.value=!1)}}e.onMounted(()=>{B.value=D(),window.addEventListener("click",ce,!0),window.addEventListener("scroll",Ce,!0),window.addEventListener("resize",Ce)}),e.onBeforeUnmount(()=>{window.removeEventListener("click",ce,!0),window.removeEventListener("scroll",Ce,!0),window.removeEventListener("resize",Ce),ge()});function ye(z){return z==="xy"?"Координати":z==="parcel"?"Кадастр":z==="nominatim"?"Адреса":"Адресний"}function Ee(z){switch(z){case"xy":return"Пошук за географічними координатами. Введіть широту і довготу через пробіл або кому (lat lng або lng lat).";case"parcel":return"Пошук земельної ділянки за кадастровим номером у форматі 0000000000:00:000:0000.";case"nominatim":return"Пошук адрес та обʼєктів через Nominatim.";case"address":return"Пошук адрес через локальний сервіс addressSuggest.";default:return""}}function Ae(z){const q=Ro(z.trim(),"dms","lat-lon");if(q.ok){const[He,Ke]=q.point;return{lat:Ke,lng:He}}const U=z.replace(/[,]+/g," ").trim();if(!U)return null;const F=U.split(/\s+/).filter(Boolean);if(F.length<2)return null;const H=F.slice(0,2).map(Number);if(!H.every(He=>Number.isFinite(He)))return null;let[ee,ie]=H,ve=ee,et=ie;const qe=He=>Math.abs(He)<=90,gt=He=>Math.abs(He)<=180;if(!qe(ve)||!gt(et))if(qe(et)&&gt(ve))ve=ie,et=ee;else return null;return{lat:ve,lng:et}}function Re(z){const q=z?.result||z?.data||z;if(!q)return[];const U=q.geom_centroid;if(!U||!Array.isArray(U.coordinates))return[];const[F,H]=U.coordinates;return!Number.isFinite(H)||!Number.isFinite(F)?[]:[{id:"parcel",title:q.cadnum||q.cad_num||"Земельна ділянка",lat:H,lng:F}]}function Fe(z){return(Array.isArray(z?.features)?z.features:[]).map((U,F)=>{const H=U?.geometry?.coordinates,ee=Number(H?.[0]),ie=Number(H?.[1]);if(!Number.isFinite(ie)||!Number.isFinite(ee))return null;const ve=U?.properties||{},et=ve?.geocoding?.label||ve?.display_name||ve?.label||"Адреса";return{id:String(ve?.geocoding?.place_id||ve?.place_id||F),title:et,lat:ie,lng:ee}}).filter(U=>!!U)}function Be(z){return Number.isFinite(z.lat)&&Number.isFinite(z.lng)}function j(z){if(z==null||typeof z=="string"&&!z.trim())return null;const q=Number(z);return Number.isFinite(q)?q:null}function Z(z){const q=j(z.lng)??j(z.lon)??j(z.longitude)??j(z.x),U=j(z.lat)??j(z.latitude)??j(z.y);if(q!=null&&U!=null)return{lat:U,lng:q};const F=z?.geometry?.coordinates??z?.geom_centroid?.coordinates??z?.centroid?.coordinates??z?.geojson?.geometry?.coordinates??z?.geom?.coordinates;if(Array.isArray(F)&&F.length>=2){const H=j(F[0]),ee=j(F[1]);if(H!=null&&ee!=null)return{lat:ee,lng:H}}return null}function ne(z){return(Array.isArray(z?.data)?z.data:[]).map((U,F)=>{const H=Z(U),ee=String(U.text??U.title??U.label??U.name??U.address??U.display_name??U.id??"Адреса"),ie=String(U.id??U.code??U.value??F);return H?{id:ie,title:ee,...H}:{id:ie,title:ee}}).filter(U=>!!U?.title)}function de(z){const q=c();if(!q)return null;if(q.includes(":name"))return q.replace(":name",encodeURIComponent(z));try{const U=new URL(q,window.location.origin);return z.trim()&&U.searchParams.set("q",z),U.toString()}catch{return q}}async function me(z){const q=de(z);if(!q)return[];const U=await fetch(q);if(!U.ok)throw new Error(`HTTP ${U.status}`);const F=await U.json();return ne(F)}async function $e(z){const q=new URL(Dc);q.searchParams.set("format","geojson"),q.searchParams.set("q",z),q.searchParams.set("addressdetails","1"),q.searchParams.set("bounded","1");const U=i();U&&q.searchParams.set("viewbox",U);const F=await fetch(q.toString());if(!F.ok)throw new Error(`HTTP ${F.status}`);const H=await F.json();return Fe(H)}async function Se(z){if(R.value=[],ge(),m.value==="address"){if(!c()){he.notify({type:"warning",title:"Пошук адреси",message:"Не налаштовано addressSuggest"});return}const F=await me(z);if(!F.length){he.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}R.value=F;return}const q=await $e(z);if(!q.length){he.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}R.value=q}async function Ne(z){if(Be(z)){ae(z),W(z);return}he.notify({type:"warning",title:"Пошук адреси",message:"Геометрія для обраної адреси відсутня"})}function Qe(){m.value!=="address"&&m.value!=="nominatim"||(L.value=!0,e.nextTick(()=>{re()}))}function Q(z){const U=z.replace(/\s+/g,"").split(":");if(U.length!==4)return!1;const F=[10,2,3,4];return U.every((H,ee)=>H.length===F[ee]&&/^\d+$/.test(H))}function ae(z){l("goToCoordinates",[z.lat,z.lng]),N.value=!0}async function Me(){const z=b.value.trim();if(z){if(m.value==="xy"){const q=Ae(z);if(!q){he.notify({type:"warning",title:"Пошук координат",message:"Використайте `lat lon` або DMS у форматі `50°27'00\"N 30°31'24\"E`."});return}ae(q);return}if(m.value==="address"||m.value==="nominatim"){try{await Se(z)}catch(q){const U=q?.message||"Помилка пошуку адреси";he.notify({type:"error",title:"Пошук адреси",message:U})}return}try{if(!Q(z)){he.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}const q=new URL(Mc);q.searchParams.set("cad_num",z);const U=await fetch(q.toString());if(!U.ok)throw new Error(`HTTP ${U.status}`);const F=await U.json(),H=Re(F);if(!H.length)he.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const ee=H[0];ae(ee)}}catch(q){const U=q?.message||"Помилка пошуку";he.notify({type:"error",title:"Пошук",message:U})}}}return(z,q)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:w,class:"map-search-widget flex flex-col gap-2 rounded-xl widget min-w-[200px]"},[e.createElementVNode("form",{class:"flex gap-2 text-gray-900",onSubmit:e.withModifiers(Me,["prevent"])},[h.value.length>1?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:C,class:"relative search-type w-[100px]"},[e.createElementVNode("button",{type:"button",class:"vstSelect-input transition-all text-left bg-white border border-gray-200 text-gray-900 rounded-lg focus:ring-blue-500 focus:border-blue-100 block w-full py-1.5 px-3 text-sm cursor-pointer flex items-center justify-between gap-2",onClick:se},[e.withDirectives((e.openBlock(),e.createElementBlock("span",{ref_key:"selectedToolLabelRef",ref:k,class:"block w-full truncate",title:ye(m.value)},[e.createTextVNode(e.toDisplayString(ye(m.value)),1)],8,wc)),[[n,Ee(m.value)]]),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-4 h-4 text-gray-500 transition-transform",{"rotate-180":g.value}]),viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},q[3]||(q[3]=[e.createElementVNode("path",{d:"M6 9l6 6 6-6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2))]),g.value?(e.openBlock(),e.createElementBlock("div",_c,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(h.value,U=>e.withDirectives((e.openBlock(),e.createElementBlock("li",{key:U,class:"px-3 py-2 cursor-pointer hover:bg-gray-100 text-gray-900",onClick:F=>we(U,F)},[e.createTextVNode(e.toDisplayString(ye(U)),1)],8,Cc)),[[n,Ee(U)]])),128))])])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"searchWrapperRef",ref:V,class:"relative flex-1 min-w-[140px]"},[m.value==="parcel"?(e.openBlock(),e.createBlock(cn,{key:0,modelValue:b.value,"onUpdate:modelValue":q[0]||(q[0]=U=>b.value=U),mask:"0000000000:00:000:0000",class:e.normalizeClass(["vs-input !h-[34px] transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid py-1.5 pl-3 text-sm",N.value?"!pr-14":"!pr-8"])},null,8,["modelValue","class"])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":q[1]||(q[1]=U=>b.value=U),placeholder:x.value,type:"text",class:e.normalizeClass(["vs-input transition-all border block w-full border-gray-200 rounded-md focus:border-blue-100 border-solid py-1.5 pl-3 text-sm",N.value?"!pr-14":"!pr-8"]),onFocus:Qe},null,42,vc)),[[e.vModelText,b.value,void 0,{trim:!0}]]),e.createElementVNode("div",Ec,[N.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Очистити",onClick:J},q[4]||(q[4]=[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"M6 18L18 6M6 6l12 12"})],-1)]))):e.createCommentVNode("",!0),q[5]||(q[5]=e.createElementVNode("button",{type:"submit",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Пошук"},[e.createElementVNode("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor","stroke-width":"2"},[e.createElementVNode("path",{"stroke-linecap":"round","stroke-linejoin":"round",d:"m21 21-4.35-4.35m0 0A7.5 7.5 0 1 0 5 5a7.5 7.5 0 0 0 11.65 11.65Z"})])],-1))]),S.value?(e.openBlock(),e.createBlock(e.Teleport,{key:2,to:"body"},[e.createElementVNode("div",{ref_key:"addressResultsRef",ref:Y,class:"vs-select__options mt-1 bg-white border border-gray-300 rounded-lg shadow-lg text-sm text-gray-900 z-50",style:e.normalizeStyle(X)},[e.createElementVNode("div",Bc,[e.createElementVNode("span",Vc,e.toDisplayString(v.value),1),e.createElementVNode("button",{type:"button",class:"text-gray-400 hover:text-gray-600","aria-label":"Закрити",onClick:q[2]||(q[2]=U=>L.value=!1)}," ✕ ")]),e.createElementVNode("div",Sc,[I.value.length?(e.openBlock(),e.createElementBlock("ul",$c,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(I.value,U=>(e.openBlock(),e.createElementBlock("li",{key:U.id,class:"px-3 py-2 cursor-pointer hover:bg-gray-50",onClick:F=>Ne(U)},e.toDisplayString(U.title),9,Nc))),128))])):(e.openBlock(),e.createElementBlock("div",Ac,e.toDisplayString(M.value),1))])],4)])):e.createCommentVNode("",!0)],512)],32)],512))}}),[["__scopeId","data-v-64b5dcb8"]]),Lc={class:"pt-1 border-t border-gray-100"},Ic={class:"space-y-1"},Rc=e.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(o,{emit:t}){const n=t,r=e.ref(null),l=e.ref(null),a=(c,d,u)=>Math.min(Math.max(c,d),u),s=()=>{if(r.value===null||l.value===null||!Number.isFinite(r.value)||!Number.isFinite(l.value))return;const c=a(r.value,-90,90),d=a(l.value,-180,180);n("submit",{lat:c,lng:d}),r.value=null,l.value=null},i=()=>{r.value=null,l.value=null,n("cancel")};return(c,d)=>(e.openBlock(),e.createElementBlock("div",Lc,[d[2]||(d[2]=e.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),e.createElementVNode("div",Ic,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[0]||(d[0]=u=>r.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта (50.4501)"},null,512),[[e.vModelText,r.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=u=>l.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота (30.5234)"},null,512),[[e.vModelText,l.value,void 0,{number:!0}]]),e.createElementVNode("div",{class:"flex gap-1.5"},[e.createElementVNode("button",{class:"flex-1 px-2 py-1 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors",type:"button",onClick:s}," Додати "),e.createElementVNode("button",{class:"px-2 py-1 bg-gray-200 hover:bg-gray-300 text-gray-700 text-xs font-medium rounded transition-colors",type:"button",onClick:i}," Скасувати ")])])]))}}),Oc=e.defineComponent({__name:"BtnAdd",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(P.Plus),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Додати ",-1))]))}}),zc=e.defineComponent({__name:"BtnClear",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"w-full px-2 py-1.5 bg-rose-500 hover:bg-rose-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(P.Trash2),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Очистити ",-1))]))}}),Pc=e.defineComponent({__name:"BtnComplete",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(P.Circle),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode("Замкнути ",-1))]))}}),jc=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function Dt(o){return jc.format(o)}function Uo(o){return o>=1e3?`${Dt(o/1e3)} км`:`${Dt(o)} м`}const Uc={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},Hc={key:0,class:"flex-1 flex gap-1"},qc={key:1,class:"flex-1 font-mono text-gray-700"},Kc=e.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(o,{emit:t}){const n=o,r=t,l=e.computed(()=>`${n.coords.lat.toFixed(4)}°, ${n.coords.lng.toFixed(4)}°`),a=e.ref(!1),s=e.ref(n.coords.lat),i=e.ref(n.coords.lng);e.watch(()=>n.coords,h=>{s.value=h.lat,i.value=h.lng},{deep:!0,immediate:!0});const c=(h,x,m)=>Math.min(Math.max(h,x),m),d=()=>{a.value=!0},u=()=>{if(!Number.isFinite(s.value)||!Number.isFinite(i.value))return;const h=c(s.value,-90,90),x=c(i.value,-180,180);r("update",{id:n.id,coords:{lat:h,lng:x}}),a.value=!1},p=()=>{r("delete",n.id)};return(h,x)=>(e.openBlock(),e.createElementBlock("div",Uc,[e.createVNode(e.unref(P.MapPin),{size:12,"stroke-width":2,class:"text-gray-400 flex-shrink-0"}),a.value?(e.openBlock(),e.createElementBlock("div",Hc,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":x[0]||(x[0]=m=>s.value=m),type:"number",step:"0.0001",min:"-90",max:"90",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":x[1]||(x[1]=m=>i.value=m),type:"number",step:"0.0001",min:"-180",max:"180",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота"},null,512),[[e.vModelText,i.value,void 0,{number:!0}]]),e.createElementVNode("button",{class:"px-1.5 py-0.5 bg-emerald-500 text-white rounded hover:bg-emerald-600 text-xs",type:"button",onClick:u}," ✓ ")])):(e.openBlock(),e.createElementBlock("span",qc,e.toDisplayString(l.value),1)),a.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("button",{key:2,class:"text-blue-500 hover:text-blue-600 px-0.5",type:"button",onClick:d}," ✎ ")),e.createElementVNode("button",{class:"text-rose-500 hover:text-rose-600 px-0.5",type:"button",onClick:p}," ✕ ")]))}}),Wc={class:"ruler-control px-3 py-2.5 space-y-2"},Gc={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},Yc={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Сумарна довжина всіх відрізків","aria-hidden":"true"},Xc={class:"text-sm font-semibold text-slate-700"},Zc={class:"ruler-row"},Jc={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},Qc={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Площа замкнутого контуру","aria-hidden":"true"},ed={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},td=["onClick"],nd={class:"flex items-center gap-2 mt-0.5 pl-7"},od={key:0,class:"text-base font-semibold text-green-600"},rd={key:1,class:"text-xs text-gray-400"},ld={class:"ruler-row flex items-center gap-2 cursor-pointer"},ad={class:e.normalizeClass(["flex items-center justify-center w-5 h-5 rounded-full shrink-0 transition-colors pointer-events-none"]),title:"Список точок","aria-hidden":"true"},sd={class:"text-xs font-medium text-gray-600 flex-1"},id={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},cd=e.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(o){const t=o,n=e.ref(!1),r=e.ref("km2"),l=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],a=()=>{n.value=!n.value},s=(m,b)=>{const g=S=>S*Math.PI/180,C=g(b.lat-m.lat),k=g(b.lng-m.lng),w=g(m.lat),V=g(b.lat),R=Math.sin(C/2),Y=Math.sin(k/2);return 6371e3*(2*Math.asin(Math.sqrt(R*R+Math.cos(w)*Math.cos(V)*Y*Y)))},i=e.computed(()=>{if(t.points.length<2)return 0;let m=0;for(let b=1;b<t.points.length;b+=1)m+=s(t.points[b-1].coords,t.points[b].coords);return t.isShapeClosed&&t.points.length>=2&&(m+=s(t.points[t.points.length-1].coords,t.points[0].coords)),m}),c=e.computed(()=>i.value>=1e3?`${Dt(i.value/1e3)} км`:`${Dt(i.value)} м`);function d(m){if(m.length<3)return 0;const b=m[0].lat,g=m[0].lng,C=(w,V)=>{const R=(w-b)*110574;return{x:(V-g)*111320*Math.cos(b*Math.PI/180),y:R}};let k=0;for(let w=0;w<m.length;w++){const V=(w+1)%m.length,R=C(m[w].lat,m[w].lng),Y=C(m[V].lat,m[V].lng);k+=R.x*Y.y-R.y*Y.x}return Math.abs(k)*.5}const u=e.computed(()=>{if(!t.isShapeClosed||t.points.length<3)return 0;const m=t.points.map(b=>b.coords);return d(m)}),p=e.computed(()=>u.value>0),h=e.computed(()=>{const m=u.value;if(m===0)return"—";if(r.value==="km2"){const g=m/1e6;return`${Dt(g)} км²`}if(r.value==="ha"){const g=m/1e4;return`${Dt(g)} га`}const b=m>=1?Math.round(m):m;return`${Dt(b)} м²`}),x=e.computed(()=>{const m=t.points.length;return m===1?"1 точка":m>=2&&m<=4?`${m} точки`:`${m} точок`});return e.watch(()=>t.points.length,()=>{t.points.length===0&&(n.value=!1)}),(m,b)=>(e.openBlock(),e.createElementBlock("div",Wc,[e.createElementVNode("button",Gc,[e.createElementVNode("span",Yc,[e.createVNode(e.unref(P.Info),{size:12,"stroke-width":2.5})]),b[1]||(b[1]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),e.createElementVNode("span",Xc,e.toDisplayString(c.value),1)]),e.createElementVNode("div",Zc,[e.createElementVNode("button",Jc,[e.createElementVNode("span",Qc,[e.createVNode(e.unref(P.Info),{size:12,"stroke-width":2.5})]),b[2]||(b[2]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),e.createElementVNode("div",ed,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,(g,C)=>e.createElementVNode("button",{key:g.id,type:"button",class:e.normalizeClass(["px-2.5 py-1 text-xs font-medium transition-colors border-r border-gray-200 last:border-r-0",C===0&&"rounded-l-md",C===l.length-1&&"rounded-r-md",r.value===g.id?"bg-white text-green-600 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-50"]),onClick:e.withModifiers(k=>r.value=g.id,["stop"])},e.toDisplayString(g.label),11,td)),64))])]),e.createElementVNode("div",nd,[p.value?(e.openBlock(),e.createElementBlock("span",od,e.toDisplayString(h.value),1)):(e.openBlock(),e.createElementBlock("span",rd,"—"))])]),e.createElementVNode("div",ld,[e.createElementVNode("span",ad,[e.createVNode(e.unref(P.Info),{size:12,"stroke-width":2.5})]),e.createElementVNode("span",sd,e.toDisplayString(x.value),1),e.createElementVNode("button",{type:"button",class:"text-xs text-blue-500 hover:text-blue-600 font-medium transition-colors",onClick:e.withModifiers(a,["stop"])}," Координати ")]),n.value?(e.openBlock(),e.createElementBlock("div",id,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.points,(g,C)=>(e.openBlock(),e.createBlock(Kc,{key:g.id,id:g.id,index:C+1,coords:g.coords,onUpdate:b[0]||(b[0]=k=>m.$emit("update-point",k)),onDelete:k=>m.$emit("delete-point",g.id)},null,8,["id","index","coords","onDelete"]))),128))])):e.createCommentVNode("",!0)]))}}),dd={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},ud={class:"flex items-start gap-2"},pd=e.defineComponent({__name:"InfoHint",setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",dd,[e.createElementVNode("div",ud,[e.createVNode(e.unref(P.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),n[0]||(n[0]=e.createElementVNode("div",{class:"space-y-1"},[e.createElementVNode("p",{class:"text-xs font-medium text-blue-900"}," Натискайте на карту, щоб додати точки вимірювання "),e.createElementVNode("p",{class:"text-[10px] text-blue-700"},' Або скористайтесь кнопкою "Додати" внизу для введення координат вручну ')],-1))])]))}}),fd={class:"space-y-1.5"},md={class:"space-y-1 max-h-40 overflow-y-auto"},hd={class:"text-gray-700"},gd={class:"font-semibold text-slate-800"},yd=e.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(o){const t=o;function n(a,s){const i=x=>x*Math.PI/180,c=i(s.lat-a.lat),d=i(s.lng-a.lng),u=i(a.lat),p=i(s.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(c/2)**2+Math.cos(u)*Math.cos(p)*Math.sin(d/2)**2)))}function r(a){return Uo(a)}const l=e.computed(()=>{const a=[],s=t.points;if(s.length<2)return a;for(let i=0;i<s.length;i++){const c=i===s.length-1&&t.isShapeClosed?0:i+1;if(c>=s.length)break;const d=n(s[i].coords,s[c].coords);a.push({from:i+1,to:c+1,label:r(d)})}return a});return(a,s)=>(e.openBlock(),e.createElementBlock("div",fd,[s[0]||(s[0]=e.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),e.createElementVNode("div",md,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(i,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[e.createElementVNode("span",hd,"Точка "+e.toDisplayString(i.from)+" → Точка "+e.toDisplayString(i.to),1),e.createElementVNode("span",gd,e.toDisplayString(i.label),1)]))),128))])]))}}),bd={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},kd={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},xd={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},wd={class:"flex items-center gap-2"},_d={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},Cd={class:"flex border-b border-gray-200"},vd={key:1,class:"px-3 py-2.5"},Ed={key:1,class:"text-xs text-gray-500"},Bd={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},Vd={class:"flex gap-1.5"},Sd=e.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(o,{expose:t,emit:n}){const r=n,l=e.ref([]),a=e.computed(()=>l.value.length>0),s=e.ref(!1),i=e.ref(!1),c=e.ref("general");function d($){c.value=$,r("tab-change",$)}e.onMounted(()=>{r("tab-change",c.value)});const u=e.computed(()=>l.value.length>=3&&!i.value);let p=1;const h=()=>l.value.map($=>({id:$.id,coords:{...$.coords}})),x=()=>{l.value.length<3&&i.value&&(i.value=!1,r("shape-closed-change",!1)),r("points-change",h())},m=()=>{const $=p;return p+=1,$},b=$=>{l.value=[...l.value,{id:m(),coords:{lat:$.lat,lng:$.lng}}],x()},g=({id:$,coords:E})=>{const N=l.value.findIndex(v=>v.id===$);if(N===-1)return;const I=[...l.value];I[N]={id:$,coords:{...E}},l.value=I,x()},C=$=>{l.value=l.value.filter(E=>E.id!==$),x()},k=()=>{l.value=[],i.value&&(i.value=!1,r("shape-closed-change",!1)),x()},w=$=>{g($)},V=$=>{C($)},R=()=>{s.value=!0,r("add-request")},Y=$=>{b($),s.value=!1},L=()=>{s.value=!1},B=()=>{u.value&&(i.value=!0,r("complete"),r("shape-closed-change",!0))},S=()=>{k(),s.value=!1,r("close")};return t({addPoint:b,clearPoints:k}),($,E)=>(e.openBlock(),e.createElementBlock("div",bd,[e.createElementVNode("div",kd,[e.createElementVNode("div",xd,[e.createElementVNode("div",wd,[e.createElementVNode("div",_d,[e.createVNode(e.unref(P.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),E[2]||(E[2]=e.createElementVNode("h3",{class:"text-white font-semibold text-xs"},"Вимірювання",-1))]),e.createElementVNode("button",{class:"w-5 h-5 flex items-center justify-center rounded hover:bg-white/20 transition-colors","aria-label":"Закрити",onClick:S},[e.createVNode(e.unref(P.X),{size:14,"stroke-width":2,class:"text-white"})])]),e.createElementVNode("div",Cd,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:E[0]||(E[0]=N=>d("general"))}," Загальна ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:E[1]||(E[1]=N=>d("topoint"))}," До точки ",2)]),c.value==="general"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.value?(e.openBlock(),e.createBlock(cd,{key:1,points:l.value,"is-shape-closed":i.value,onUpdatePoint:w,onDeletePoint:V},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createBlock(pd,{key:0}))],64)):(e.openBlock(),e.createElementBlock("div",vd,[a.value?(e.openBlock(),e.createBlock(yd,{key:0,points:l.value,"is-shape-closed":i.value},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createElementBlock("p",Ed,"Додайте точки на карті, щоб бачити відстані між ними."))])),e.createElementVNode("div",Bd,[e.createElementVNode("div",Vd,[s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Oc,{key:0,onClick:R})),u.value?(e.openBlock(),e.createBlock(Pc,{key:1,onClick:B})):e.createCommentVNode("",!0)]),s.value?(e.openBlock(),e.createBlock(Rc,{key:0,onSubmit:Y,onCancel:L})):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(zc,{key:1,onClick:k})):e.createCommentVNode("",!0)])])]))}}),Ge="ruler-points",wt="ruler-line",_t="ruler-polygon",Ct="ruler-segments",$d=e.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(o){function t(m,b){const g=Y=>Y*Math.PI/180,C=g(b.lat-m.lat),k=g(b.lng-m.lng),w=g(m.lat),V=g(b.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(C/2)**2+Math.cos(w)*Math.cos(V)*Math.sin(k/2)**2)))}function n(m){return Uo(m)}const r=o;function l(){return{type:"FeatureCollection",features:[]}}function a(m,b,g){const C=g??"general",k=[];let w=0;k.push(0);for(let V=1;V<m.length;V++)w+=t(m[V-1].coords,m[V].coords),k.push(w);return b&&m.length>=2&&(w+=t(m[m.length-1].coords,m[0].coords)),{type:"FeatureCollection",features:m.map((V,R)=>{const Y=C==="general"?R===0?"0":n(k[R]):R===0?"0":n(t(m[R-1].coords,m[R].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[V.coords.lng,V.coords.lat]},properties:{id:V.id,index:R+1,label:Y}}})}}function s(m,b){if(m.length<2)return l();const g=[];for(let C=0;C<m.length;C++){const k=C===m.length-1&&b?0:C+1;if(k>=m.length)break;const w=m[C].coords,V=m[k].coords,R=t(w,V);g.push({type:"Feature",geometry:{type:"LineString",coordinates:[[w.lng,w.lat],[V.lng,V.lat]]},properties:{distance:n(R)}})}return{type:"FeatureCollection",features:g}}function i(m,b){if(m.length<2)return l();const g=m.map(C=>[C.coords.lng,C.coords.lat]);return b&&g.push(g[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:g},properties:{}}]}}function c(m){if(m.length<3)return l();const b=m.map(g=>[g.coords.lng,g.coords.lat]);return b.push(b[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[b]},properties:{}}]}}let d=!1;function u(m){m.getSource(Ge)||(m.addSource(Ge,{type:"geojson",data:l()}),m.addLayer({id:`${Ge}-circle`,type:"circle",source:Ge,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),m.addLayer({id:`${Ge}-labels`,type:"symbol",source:Ge,layout:{"text-field":["get","label"],"text-size":14,"text-offset":[0,1.3]},paint:{"text-color":"#0f172a","text-halo-color":"#ffffff","text-halo-width":1}})),m.getSource(Ct)||(m.addSource(Ct,{type:"geojson",data:l()}),m.addLayer({id:`${Ct}-labels`,type:"symbol",source:Ct,layout:{"text-field":["get","distance"],"text-size":13,"symbol-placement":"line-center","text-rotation-alignment":"map","text-pitch-alignment":"map"},paint:{"text-color":"#1e293b","text-halo-color":"#ffffff","text-halo-width":1.5}})),m.getSource(wt)||(m.addSource(wt,{type:"geojson",data:l()}),m.addLayer({id:`${wt}-layer`,type:"line",source:wt,paint:{"line-color":"#3b82f6","line-width":2}})),m.getSource(_t)||(m.addSource(_t,{type:"geojson",data:l()}),m.addLayer({id:`${_t}-layer`,type:"fill",source:_t,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function p(m){if(m){try{m.getLayer(`${_t}-layer`)&&m.removeLayer(`${_t}-layer`),m.getSource(_t)&&m.removeSource(_t),m.getLayer(`${wt}-layer`)&&m.removeLayer(`${wt}-layer`),m.getSource(wt)&&m.removeSource(wt),m.getLayer(`${Ct}-labels`)&&m.removeLayer(`${Ct}-labels`),m.getSource(Ct)&&m.removeSource(Ct),m.getLayer(`${Ge}-labels`)&&m.removeLayer(`${Ge}-labels`),m.getLayer(`${Ge}-circle`)&&m.removeLayer(`${Ge}-circle`),m.getSource(Ge)&&m.removeSource(Ge)}catch{}d=!1}}function h(m){if(!m)return;const b=m.getSource(Ge),g=m.getSource(wt),C=m.getSource(_t),k=m.getSource(Ct),w=r.points,V=r.labelMode??"general";b&&b.setData(a(w,r.isShapeClosed,V)),g&&g.setData(i(w,r.isShapeClosed)),C&&C.setData(c(w)),k&&k.setData(V==="topoint"?s(w,r.isShapeClosed):l())}function x(){const m=r.map;m&&(d||u(m),h(m))}return e.watch(()=>[r.points,r.isShapeClosed,r.labelMode],()=>x(),{deep:!0,immediate:!0}),e.watch(()=>r.map,()=>x(),{immediate:!0}),e.onBeforeUnmount(()=>{p(r.map)}),(m,b)=>null}});function Nd(o={}){const t=e.ref(!1),n=e.ref([]),r=e.ref(!1),l=e.ref("general"),a=e.ref(null);function s(){t.value?i():(t.value=!0,o.onActivate?.())}function i(){t.value=!1,n.value=[],r.value=!1,a.value?.clearPoints(),o.onDeactivate?.()}function c(x){n.value=x}function d(x){l.value=x}function u(x){r.value=x}function p(x){t.value&&a.value?.addPoint({lat:x.lat,lng:x.lng})}const h=e.computed(()=>n.value.length>0);return{isRulerActive:t,rulerPoints:n,rulerShapeClosed:r,rulerActiveTab:l,rulerPanelRef:a,hasRulerPoints:h,toggleRuler:s,closeRuler:i,onRulerPointsChange:c,onRulerTabChange:d,onRulerShapeClosedChange:u,handleRulerMapClick:p}}const Ad={key:0,class:"absolute top-4 left-4 z-[1000] w-[calc(100%-20px)] sm:w-[350px]"},Fd={key:1,class:"form-geom__panel flex gap-1 items-start mt-2"},Md={class:"flex items-center gap-1"},Dd=["disabled"],Td={key:0,class:"absolute z-[1600] mt-1 min-w-[120px] bg-white border border-gray-300 shadow-lg rounded-lg text-sm overflow-hidden"},Ld=["disabled"],Id=["disabled"],Rd={class:"mt-4 flex justify-end gap-2"},Od=["disabled"],zd={class:"absolute top-4 right-4 z-[1000]"},Pd={class:"flex flex-col gap-[2px]"},jd=["disabled"],Ud=["disabled"],Hd=["disabled"],qd=["disabled"],Kd={class:"bg-white/95 border border-gray-200 rounded-md shadow-xl px-3 py-2 max-w-[240px] text-[11px] sm:text-xs text-gray-900"},Wd={class:"space-y-0.5"},Gd={class:"text-gray-500"},Yd={class:"text-gray-900 text-right break-all"},Xd={class:"absolute left-4 bottom-[36px] z-[1000]"},Zd={class:"flex flex-col gap-2"},Jd={key:0,class:"bg-white/95 border border-gray-200 rounded-md shadow-sm px-3 py-2 text-xs text-gray-700 min-w-[200px]"},Qd={class:"flex flex-col gap-1"},eu=["checked","disabled","onChange"],tu={class:"text-gray-700 text-xs font-medium"},nu={class:"absolute bottom-0 left-0 right-0 z-[1000] min-h-[28px] bg-white/95 border-t border-gray-200 text-xs text-gray-700 flex items-center gap-4 pt-1"},ou={key:0,class:"form-geom__feature flex items-center text-xs transition-all gap-2 w-full px-2 pb-1"},ru={class:"mr-auto flex items-center gap-2 min-w-0 relative"},lu={class:"shrink-0"},au={key:0,class:"font-bold"},su=["onClick","disabled"],iu={key:0},cu={class:"flex items-center"},du={class:"text-xs mr-2"},uu={key:0},pu={key:1},fu={key:0,class:"text-xs mr-2"},mu={key:1,class:"text-xs mr-2"},hu=["disabled"],gu=["disabled"],bn="__vs_form_maplibre_loader__",kn="vs-global-bounds-src",xn="vs-global-bounds-line",Ho=xe(e.defineComponent({__name:"vs-input-map",props:{tools:{},multi:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},handleZoom:{type:Boolean,default:!0},ctrlZoom:{type:Boolean,default:!0},geomType:{default:()=>[]},prefix:{default:""},katottg:{default:""},layers:{default:()=>[]},bounds:{},api:{},center:{default:void 0},zoom:{default:void 0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue","valueSelected"],setup(o,{emit:t}){const n=o,r=t,l=e.useAttrs(),a=e.computed(()=>{const f=l?.multiple,y=l?.multi,_=A=>A===""||A===!0||A==="true"||A===1||A==="1";return!!n.multi||!!n.multiple||_(y)||_(f)}),s=e.computed(()=>!!n.disabled),i=e.ref(!1),c=e.ref(null),d=e.ref(0),u=e.ref(""),p=e.ref(null),h=e.ref([]),x=e.ref(null),m=e.ref(null),b=Nd({onActivate(){if(ae)try{ae.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""},onDeactivate(){}});function g(){b.toggleRuler()}const C=e.getCurrentInstance(),k=C?.appContext?.config?.globalProperties?.$settings??{},w=k?.map??{},V=C?.vnode?.props??{};function R(f){return Object.prototype.hasOwnProperty.call(V,f)||Object.prototype.hasOwnProperty.call(V,f.replace(/[A-Z]/g,y=>`-${y.toLowerCase()}`))}const Y=Array.isArray(w.center)&&w.center.length===2?w.center:Array.isArray(k.center)&&k.center.length===2?k.center:[30,50],L=typeof w.zoom=="number"?w.zoom:typeof k.zoom=="number"?k.zoom:typeof k.defaultZoom=="number"?k.defaultZoom:10,B=e.computed(()=>R("center")?n.center:w.center??n.center),S=e.computed(()=>R("zoom")?n.zoom:w.zoom??n.zoom),$=e.computed(()=>R("katottg")?String(n.katottg??""):String(w.katottg??n.katottg??"")),E=e.computed(()=>R("layers")?n.layers??[]:w.layers??n.layers??[]),N=e.computed(()=>R("bounds")?n.bounds:w.bounds??n.bounds),I=e.ref(Array.isArray(B.value)&&B.value.length===2?[...B.value]:Y),v=e.ref(typeof S.value=="number"?S.value:L),M=e.ref(n.modelValue),D=e.ref(null),K=e.ref(null),W=e.ref([]),X=e.ref(!1),re=e.ref(!1),Ce=e.ref([]),ge=e.ref({coordinates:"",format:"decimal",order:"lat-lon"}),te={coordinates:{type:"Textarea",label:"Координати вершин полігону (3-100 точок)",placeholder:`50.4501, 30.5234
3
3
  50.4510, 30.5242
4
- 50.4494, 30.5260`},format:{type:"Radio",label:"Формат координат",options:[{id:"decimal",text:"Десяткові (Decimal)"},{id:"dms",text:"Градуси-хвилини-секунди (DMS)"}]},order:{type:"Radio",label:"Порядок координат",options:[{id:"lat-lon",text:"lat, lon"},{id:"lon-lat",text:"lon, lat"}]}};let se=!1,we=!1;const J=e.reactive({}),ce=e.ref([]),ye=e.computed(()=>ce.value.map(f=>J[f]).filter(Boolean)),Ee=e.ref(null),Ae=e.computed(()=>Ee.value?.entries??[]),Re=e.computed(()=>{if(Ee.value)return{left:`${Ee.value.point.x+12}px`,top:`${Ee.value.point.y+12}px`}}),Fe=e.computed(()=>{if(Array.isArray(n.tools)&&n.tools.length)return n.tools;const f=l?.tools;return Array.isArray(f)?f.map(y=>String(y)):typeof f=="string"?f.split(",").map(y=>y.trim()).filter(Boolean):[]}),Be=e.computed(()=>{const f={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Fe.value.length)return{...f,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const y=new Set(Fe.value.map(_=>_.toLowerCase()));return{search:y.has("search"),import:y.has("import"),export:y.has("export"),point:y.has("point"),line:y.has("line"),polygon:y.has("polygon"),rectangle:y.has("rectangle"),ruler:y.has("ruler")}});function j(f){if(typeof f!="string"||!f.trim())return"";if(/^https?:\/\//i.test(f))return f;const y=window?.location?.origin??"",_=f.replace(/^\/+/,"");return _?y?`${y}/${_}`:`/${_}`:y}function Z(){const f=Array.isArray(w.basemaps)&&w.basemaps.length?w.basemaps:k.basemaps;if(Array.isArray(f)&&f.length){const _=f.map((A,T)=>{const G=String(A?.key??A?.id??A?.name??`b${T}`),le=j(String(A?.url??""));if(!le)return null;const pe=typeof A?.preview=="string"&&A.preview?j(A.preview):"";return[G,{...A,url:le,preview:pe}]}).filter(A=>Array.isArray(A)&&A.length===2).reduce((A,[T,G])=>(A[T]=G,A),{});if(Object.keys(_).length)return _}return{voyager:{name:"Оглядова карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/voyager/ua/13/4790/2762.png"},orto10:{name:"Ортофото 1:10K",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4790/2762.png"},osmb:{name:"Open Street Maps",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",preview:"https://tile.openstreetmap.org.ua/styles/osm-bright/13/4790/2762.png"}}}const ne=Z(),de=Object.keys(ne),me=e.ref(de.length?de[0]:"");async function $e(){if(typeof window>"u")return null;const f=window;if(f[bn])return f[bn];const y=G=>{if(Array.from(document.styleSheets).some(Le=>Le?.href?.includes(G)))return;const pe=document.createElement("link");pe.rel="stylesheet",pe.href=G,document.head.appendChild(pe)},_=async()=>{const G=new Function("u","return import(u)"),le=await G("https://esm.sh/maplibre-gl@3.6.2"),pe=le?.default??le;if(!pe)throw new Error("maplibre esm fallback failed");window.maplibregl=pe,window.mapboxgl=pe;const Le=await G("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),nt=Le?.default??Le;if(!nt)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=nt},T=(async()=>{y("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),y("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await _();const G=window.maplibregl,le=window.MapboxDraw;if(!G)throw new Error("maplibregl not available after load");if(!le)throw new Error("MapboxDraw not available after load");return{maplibregl:G,MapboxDraw:le}})().catch(G=>{throw delete f[bn],G});return f[bn]=T,T}function Se(f){return{version:8,sources:{rasterSource:{type:"raster",tiles:[f],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let Ne=null,Qe=null,Q=null,ae=null,Me=[],z=null,q=null,U=null,F=!1,H=!1,ee=!1,ie=null;function ve(){return{onSetup(){const f=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(f),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:f,startPoint:null,hasCoordinates:!1}},onMouseMove(f,y){if(!f.startPoint)return;const[_,A]=f.startPoint,T=y.lngLat.lng,G=y.lngLat.lat;f.rectangle.setCoordinates([[[_,A],[T,A],[T,G],[_,G],[_,A]]])},onClick(f,y){if(!f.startPoint){f.startPoint=[y.lngLat.lng,y.lngLat.lat],f.hasCoordinates=!0,f.rectangle.setCoordinates([[[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat]]]);return}const[_,A]=f.startPoint,T=y.lngLat.lng,G=y.lngLat.lat;return Math.abs(_-T)>0&&Math.abs(A-G)>0?(f.rectangle.setCoordinates([[[_,A],[T,A],[T,G],[_,G],[_,A]]]),this.map.fire("draw.create",{features:[f.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[f.rectangle.id]})):(this.deleteFeature([f.rectangle.id],{silent:!0}),f.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(f){this.deleteFeature([f.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(f,y,_){const A=y.properties.id===f.rectangle.id;A&&!f.hasCoordinates||(y.properties.active=A?"true":"false",_(y))}}}const et=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["!=","active","true"]],paint:{"fill-color":"#3b82f6","fill-outline-color":"#3b82f6","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":"#2563eb","fill-outline-color":"#2563eb","fill-opacity":.2}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","$type","Polygon"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-lines-inactive",type:"line",filter:["all",["==","$type","LineString"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-lines-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","active","true"]],paint:{"circle-radius":5,"circle-color":"#3b82f6"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","meta","midpoint"],["==","$type","Point"]],paint:{"circle-radius":4,"circle-color":"#1d4ed8"}}];function qe(){const f=me.value;return!f||!ne[f]?.url?"":ne[f].url}function gt(f,y){return f?.id?String(f.id):f?.url?`${f.url}-${y}`:`layer-${y}`}function He(f){const y=String(f?.url??"").trim();if(!y)return"";if(/^https?:\/\//i.test(y))return y;const _=window.location?.origin??"",A=y.replace(/^\/+/,"");return`${_}/${A}`}function Ke(f){f&&Ee.value?.layerId!==f||(Ee.value=null)}function yt(f,y={}){return f.popup===!1?[]:Array.isArray(f.popup)?f.popup.length?f.popup.map(_=>{const A=_?.field||_?.name;if(!A)return null;const T=y[A];return T==null||T===""?null:{key:_.label||A,value:String(T)}}).filter(Boolean):[]:Object.entries(y).slice(0,5).map(([_,A])=>({key:_,value:A==null?"—":String(A)}))}function lt(f){if(!Array.isArray(f))return[];const y=A=>Array.isArray(A)&&A.length>=2&&Number.isFinite(Number(A[0]))&&Number.isFinite(Number(A[1])),_=A=>{if(!A.length)return A;const T=A[0],G=A[A.length-1];return!G||T[0]!==G[0]||T[1]!==G[1]?[...A,T]:A};if(f.length&&y(f[0])){const A=f.map(T=>[Number(T[0]),Number(T[1])]).filter(y);return A.length?[_(A)]:[]}return f.length&&Array.isArray(f[0])&&y(f[0][0])?f.map(T=>Array.isArray(T)?T.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(T=>T.length).map(_):f.length&&Array.isArray(f[0])&&Array.isArray(f[0][0])&&y(f[0][0][0])?f.flatMap(T=>Array.isArray(T)?T:[]).map(T=>Array.isArray(T)?T.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(T=>T.length).map(_):[]}function It(f){const y=f.style??{},_=y.color??"#3b82f6";if(!y.colorAttr||!y.colorSet)return _;const A=Object.keys(y.colorSet);if(!A.length)return _;const T=["match",["to-string",["get",y.colorAttr]]];return A.forEach(G=>{T.push(String(G),y.colorSet?.[G]??_)}),T.push(_),T}function Nt(f){if(!Q)return;f.handlers.forEach(_=>{try{Q.off(_.type,_.layerId,_.handler)}catch{}}),f.handlers=[],[...f.layerIds,...f.boundsIds].forEach(_=>{Q.getLayer(_)&&Q.removeLayer(_)}),Q.getSource(f.sourceId)&&Q.removeSource(f.sourceId);const y=`vs-ov-bounds-src-${f.id}`;Q.getSource(y)&&Q.removeSource(y),Ke(f.id)}function ho(f,y){if(!Q)return[];const _=`vs-ov-bounds-src-${y}`,A=`vs-ov-bounds-line-${y}`,T=f.bounds??N.value??W.value,G=lt(T);if(!G.length)return[];const le={type:"FeatureCollection",features:G.map(pe=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:pe}}))};return Q.getSource(_)&&Q.removeSource(_),Q.addSource(_,{type:"geojson",data:le}),Q.addLayer({id:A,type:"line",source:_,paint:{"line-color":f.style?.stroke??f.style?.color??"#2563eb","line-width":f.style?.width??2,"line-opacity":f.style?.opacity??.8,"line-dasharray":[2,2]}}),[A]}function At(f){if(!Q)return;Nt(f);const y=f.config,_=He(y);if(!_)return;const A=[],T=[];if(/\.v(?:m)?t(?:\?|$)/i.test(_)||/\.pbf(?:\?|$)/i.test(_)){const pe=y.sourceLayer||y.layer||y.service_layer||y.dataset?.layer||y.id;Q.addSource(f.sourceId,{type:"vector",tiles:[_]});const Le=String(y.style?.type??"polygon").toLowerCase(),nt=It(y),ut=y.style?.opacity??.5;if(Le==="point"){const xt=`vs-ov-point-${f.id}`;Q.addLayer({id:xt,type:"circle",source:f.sourceId,"source-layer":pe,paint:{"circle-color":nt,"circle-radius":5,"circle-opacity":ut}}),A.push(xt)}else if(Le==="polyline"||Le==="line"){const xt=`vs-ov-line-${f.id}`;Q.addLayer({id:xt,type:"line",source:f.sourceId,"source-layer":pe,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":nt,"line-width":y.style?.width??2,"line-opacity":ut}}),A.push(xt)}else{const xt=`vs-ov-fill-${f.id}`,an=`vs-ov-border-${f.id}`;Q.addLayer({id:xt,type:"fill",source:f.sourceId,"source-layer":pe,paint:{"fill-color":nt,"fill-opacity":ut}}),Q.addLayer({id:an,type:"line",source:f.sourceId,"source-layer":pe,paint:{"line-color":y.style?.stroke??y.style?.color??"#2563eb","line-width":y.style?.width??1,"line-opacity":ut}}),A.push(xt,an)}}else{Q.addSource(f.sourceId,{type:"raster",tiles:[_],tileSize:256});const pe=`vs-ov-raster-${f.id}`;Q.addLayer({id:pe,type:"raster",source:f.sourceId,paint:{"raster-opacity":y.style?.opacity??1}}),A.push(pe)}A.forEach(pe=>{const Le=ut=>{if(!ut?.features?.length){Ke(f.id);return}const xt=ut.features[0]?.properties??{},an=yt(f.config,xt);if(!an.length){Ke(f.id);return}Ee.value={layerId:f.id,entries:an,point:{x:ut.point.x,y:ut.point.y}}},nt=()=>Ke(f.id);Q.on("mousemove",pe,Le),Q.on("mouseleave",pe,nt),T.push({layerId:pe,type:"mousemove",handler:Le},{layerId:pe,type:"mouseleave",handler:nt})}),f.layerIds=A,f.boundsIds=ho(f.config,f.id),f.handlers=T;const le=f.visible?"visible":"none";[...f.layerIds,...f.boundsIds].forEach(pe=>{Q.getLayer(pe)&&Q.setLayoutProperty(pe,"visibility",le)})}function Rt(){if(!Q)return;const y={type:"FeatureCollection",features:lt(N.value??W.value).map(_=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:_}}))};Q.getSource(kn)?Q.getSource(kn).setData(y):Q.addSource(kn,{type:"geojson",data:y}),Q.getLayer(xn)||Q.addLayer({id:xn,type:"line",source:kn,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function go(f){if(!Q||s.value)return;const y=J[f];if(!y)return;y.visible=!y.visible;const _=y.visible?"visible":"none";[...y.layerIds,...y.boundsIds].forEach(A=>{Q.getLayer(A)&&Q.setLayoutProperty(A,"visibility",_)}),bt(),y.visible||Ke(f)}function bt(){if(!Q)return;const f=[],y=[],_=[],A=[];ce.value.forEach(le=>{const pe=J[le];if(!pe)return;const Le=String(pe.config?.url??""),nt=/\.v(?:m)?t(?:\?|$)/i.test(Le),ut=/\.png(?:\?|$)/i.test(Le);nt?_.push(...pe.layerIds):ut?f.push(...pe.layerIds):y.push(...pe.layerIds),A.push(...pe.boundsIds)}),[...f,...y,..._,...A].forEach(le=>{Q.getLayer(le)&&Q.moveLayer(le)}),Q.getLayer(xn)&&Q.moveLayer(xn),(Q.getStyle?.()?.layers??[]).map(le=>String(le?.id??"")).filter(le=>le.startsWith("gl-draw-")).forEach(le=>{Q.getLayer(le)&&Q.moveLayer(le)})}function yo(f){if(!ne[f]||(me.value=f,!Q))return;const y=qe();if(!y)return;const _=Q.getCenter?.(),A=Q.getZoom?.(),T=ae?.getAll?.();Q.setStyle(Se(y)),Q.once("style.load",()=>{if(Q&&(_&&Number.isFinite(A)&&Q.jumpTo({center:[_.lng,_.lat],zoom:A}),Rt(),ce.value.forEach(G=>{const le=J[G];le&&At(le)}),bt(),T?.features?.length&&ae))try{T.features.forEach(G=>ae.add(G)),d.value=T.features.length}catch{d.value=0}})}function on(f){return{type:"Feature",properties:{},geometry:f}}function tt(f){if(!f)return null;try{return JSON.parse(JSON.stringify(f))}catch{return null}}function O(f){if(!f)return null;const y=tt(f.geometry);return y?{...f.id!==void 0?{id:f.id}:{},type:"Feature",properties:{...f.properties??{}},geometry:y}:null}function oe(f){if(!f)return[];const y=(T,G)=>{if(!T?.type)return[];const le={...G??{}};return T.type==="MultiPoint"&&Array.isArray(T.coordinates)?T.coordinates.map(pe=>on({type:"Point",coordinates:pe})).map(pe=>({...pe,properties:le})):T.type==="MultiLineString"&&Array.isArray(T.coordinates)?T.coordinates.map(pe=>on({type:"LineString",coordinates:pe})).map(pe=>({...pe,properties:le})):T.type==="MultiPolygon"&&Array.isArray(T.coordinates)?T.coordinates.map(pe=>on({type:"Polygon",coordinates:pe})).map(pe=>({...pe,properties:le})):T.type==="GeometryCollection"&&Array.isArray(T.geometries)?T.geometries.flatMap(pe=>y(pe,le)):[{type:"Feature",properties:le,geometry:tt(T)}]},_=T=>{if(!T)return null;if(T.type==="Feature"){const G=O(T);return G?y(G.geometry,G.properties):null}return T.geom?.type&&Array.isArray(T.geom.coordinates)?y({type:T.geom.type,coordinates:T.geom.coordinates},T.properties??{}):T.type==="GeometryCollection"&&Array.isArray(T.geometries)?y(T,T.properties??{}):typeof T.type=="string"&&Array.isArray(T.coordinates)?y(tt(T),T.properties??{}):null};if(f.type==="FeatureCollection")return(f.features??[]).flatMap(_).filter(Boolean);if(Array.isArray(f))return f.flatMap(T=>T?.type==="FeatureCollection"?oe(T):[_(T)]).flat().filter(Boolean);const A=_(f);return A?Array.isArray(A)?A:[A]:[]}function ue(f){if(!f.length)return null;if(!a.value)return tt(f[0]?.geometry??null);const y=f.map(G=>tt(G?.geometry)).filter(Boolean);return y.every(G=>G?.type==="Point")?{type:"MultiPoint",coordinates:y.map(G=>G.coordinates)}:y.every(G=>G?.type==="LineString")?{type:"MultiLineString",coordinates:y.map(G=>G.coordinates)}:y.every(G=>G?.type==="Polygon")?{type:"MultiPolygon",coordinates:y.map(G=>G.coordinates)}:{type:"GeometryCollection",geometries:y}}function Ve(f){if(!f)return"__null__";try{return JSON.stringify(f)}catch{return"__invalid__"}}function Te(f,y){if(!Array.isArray(f)||!Array.isArray(y)||f.length<2||y.length<2)return!1;const _=1e-12;return Math.abs(Number(f[0])-Number(y[0]))<_&&Math.abs(Number(f[1])-Number(y[1]))<_}function Oe(f,y){if(!Array.isArray(f)||f.length<4)return null;const A=Te(f[0],f[f.length-1])?f.slice(0,-1):f.slice();return!Number.isInteger(y)||y<0||y>=A.length||A.length<=3||(A.splice(y,1),A.length<3)?null:[...A,[...A[0]]]}function De(f,y){if(!Array.isArray(f)||f.length<2||!Number.isInteger(y)||y<0||y>=f.length||f.length<=2)return null;const _=f.slice();return _.splice(y,1),_.length<2?null:_}function at(f,y){const _=tt(f);if(!_||!Array.isArray(y))return null;if(_.type==="LineString"){const[A]=y,T=De(_.coordinates,A);return T?(_.coordinates=T,_):null}if(_.type==="MultiLineString"){const[A,T]=y,G=_.coordinates?.[A],le=De(G,T);return le?(_.coordinates[A]=le,_):null}if(_.type==="Polygon"){const[A,T]=y,G=_.coordinates?.[A],le=Oe(G,T);return le?(_.coordinates[A]=le,_):null}if(_.type==="MultiPolygon"){const[A,T,G]=y,le=_.coordinates?.[A]?.[T],pe=Oe(le,G);return pe?(_.coordinates[A][T]=pe,_):null}return null}function kt(f){return f?f.split(".").map(y=>Number(y)).filter(y=>Number.isInteger(y)&&y>=0):[]}function st(f){return!ae||!f?null:typeof ae.get=="function"?ae.get(f)??null:ae.getAll?.()?.features?.find(_=>String(_?.id??"")===f)??null}function dt(f){const y=f?.properties?.id??f?.id;return y==null||y===""?null:String(y)}function it(f){if(!Q||!f)return null;const y=[[f.x-8,f.y-8],[f.x+8,f.y+8]],A=Q.queryRenderedFeatures(y).find(T=>{const G=String(T?.properties?.meta??"");return G&&G!=="feature"?!1:!!dt(T)});return dt(A)}function rn(f,y){if(!ae||!f||!y.length)return;const _=st(f);if(!_?.geometry)return;const A=at(_.geometry,y);if(!A)return;const T={..._,id:_.id??f,geometry:A};we=!0,se=!0;try{ae.delete(f),ae.add(T)}finally{se=!1,we=!1}Ft(),vt()}function p0(f){if(!Q||!ae||s.value||b.isRulerActive.value||u.value!=="edit")return;const y=f?.point;if(!y)return;const _=[[y.x-8,y.y-8],[y.x+8,y.y+8]],T=Q.queryRenderedFeatures(_).find(le=>le?.properties?.meta==="vertex"&&le?.properties?.parent&&le?.properties?.coord_path);if(!T)return;f?.originalEvent?.preventDefault?.(),f?.originalEvent?.stopPropagation?.();const G=kt(String(T.properties.coord_path));G.length&&rn(String(T.properties.parent),G)}function f0(f){const y=Kr(f);if(!y)return null;const[[_,A],[T,G]]=y;return{lat:(A+G)/2,lng:(_+T)/2}}function Ur(f){if(!Array.isArray(f)||f.length<3)return 0;const y=(A,T)=>{const G=A*2003750834e-2/180,le=Math.log(Math.tan((90+T)*Math.PI/360))/(Math.PI/180);return[G,le*2003750834e-2/180]};let _=0;for(let A=0;A<f.length-1;A+=1){const[T,G]=y(Number(f[A][0]),Number(f[A][1])),[le,pe]=y(Number(f[A+1][0]),Number(f[A+1][1]));_+=T*pe-le*G}return Math.abs(_/2)/1e6}function m0(f){if(!f?.type||!f?.coordinates)return null;if(f.type==="Polygon"){const y=f.coordinates?.[0];return Array.isArray(y)?Ur(y):null}return f.type==="MultiPolygon"?f.coordinates.reduce((y,_)=>{const A=_?.[0];return Array.isArray(A)?y+Ur(A):y},0):null}function bo(f){if(!f){p.value=null;return}const y=f0(f);if(!y){p.value=null;return}p.value={type:String(f.type??"Feature"),center:y,areaKm2:m0(f)}}function ko(f){if(!f){const A=Me[Me.length-1],T=tt(A?.geometry??null);z=T,bo(T);return}const y=Me.find(A=>String(A?.id??"")===String(f))??null,_=tt(y?.geometry??null);z=_,bo(_)}function xo(f){h.value=(f??[]).map((y,_)=>{const A=String(y?.id??`feature-${_+1}`),T=Hr(String(y?.geometry?.type??"Feature"));return{id:A,label:`${T} ${_+1}`}})}function Hr(f){switch(String(f)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(f||"Невідомо")}}function qr(f,y){if(!Array.isArray(f)||!Array.isArray(y)||f.length!==2||y.length!==2)return!1;const _=1e-9;return Math.abs(Number(f[0])-Number(y[0]))<_&&Math.abs(Number(f[1])-Number(y[1]))<_}function Kr(f){if(!f)return null;let y=1/0,_=1/0,A=-1/0,T=-1/0;const G=le=>{if(Array.isArray(le)){if(le.length>=2&&Number.isFinite(le[0])&&Number.isFinite(le[1])){const pe=Number(le[0]),Le=Number(le[1]);y=Math.min(y,pe),_=Math.min(_,Le),A=Math.max(A,pe),T=Math.max(T,Le);return}le.forEach(G)}};return G(f.coordinates),!Number.isFinite(y)||!Number.isFinite(_)?null:[[y,_],[A,T]]}function Wr(f){if(!Q||!f)return;const y=Kr(f);if(!y)return;const[[_,A],[T,G]]=y;if(_===T&&A===G){Q.easeTo({center:[_,A],zoom:Math.max(v.value,14)});return}Q.fitBounds(y,{padding:30,duration:250,maxZoom:18})}function wo(){if(!ae){d.value=0;return}const f=ae.getAll();d.value=f?.features?.length??0}function ln(){if(!ae)return null;const y=ae.getAll?.()?.features??[],_=G=>!!G&&y.some(le=>String(le?.id??"")===String(G??"")),A=ae.getSelectedIds?.();if(Array.isArray(A)&&A.length>0){const G=A[0];return G!=null?String(G):null}if(_(U))return String(U);if(!y.length)return null;const T=a.value?y[y.length-1]:y[0];return T?.id!==void 0&&T?.id!==null?String(T.id):null}function Ft(){if(!ae)return;const f=ae.getAll();if(d.value=f?.features?.length??0,!f?.features?.length){Me=[],h.value=[],z=null,U=null,p.value=null,se||(q="__null__",r("update:modelValue",null));return}const y=(f.features??[]).map(O).filter(Boolean);if(Me=y,xo(y),U=ln(),ko(U),!se){const _=ue(y);q=Ve(_),r("update:modelValue",_)}}function Ln(){if(!ae)return;(ae.getAll()?.features||[]).forEach(y=>ae.delete(y.id)),h.value=[],wo()}function In(f){if(!ae)return;const y=oe(f),_=a.value?y:y.slice(0,1);se=!0,Ln(),_.forEach(G=>{try{ae.add(G)}catch{}}),se=!1,Me=(ae.getAll?.()?.features??_).map(O).filter(Boolean),xo(Me),U=null;const T=tt(Me[Me.length-1]?.geometry??null);z=tt(T),wo(),bo(T),T&&(Wr(T),s.value||vt())}function h0(){ae&&(se=!0,Ln(),Me.forEach(f=>{try{ae.add(f)}catch{}}),se=!1,xo(Me),wo(),ko(U))}function jt(){if(ae){try{ae.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""}}function Rn(f){if(s.value||!ae)return;b.isRulerActive.value&&b.closeRuler(),ee=!0,jt(),u.value=f;const y=f==="marker"?"draw_point":f==="polyline"?"draw_line_string":f==="rectangle"?"draw_rectangle":"draw_polygon";a.value||(se=!0,Ln(),se=!1);try{ae.changeMode(y)}catch{u.value=""}finally{requestAnimationFrame(()=>{ee=!1})}}function vt(f){if(s.value||!ae||!ae.getAll()?.features?.length)return;const _=f||ln();if(_)try{ae.changeMode("direct_select",{featureId:_}),U=_,ko(U),u.value="edit"}catch{u.value=""}}function g0(f){s.value||!ae||!f||vt(f)}function y0(){if(!(s.value||!ae)){if(a.value){const f=ln();if(f)try{F=!0,ae.delete(f),F=!1,Ft();const y=ln();y?vt(y):jt();return}catch{F=!1}}jt(),Ln(),Me=[],h.value=[],U=null,q="__null__",p.value=null,r("update:modelValue",null)}}function b0(){s.value||!z||Wr(z)}function k0(f){if(!Q||!Ne)return;const y=[f[1],f[0]];ie||(ie=new Ne.Marker({color:"#2563eb"})),ie.setLngLat(y).addTo(Q),Q.easeTo({center:y,zoom:13,duration:250})}function x0(){s.value||D.value?.click()}function w0(){s.value||(X.value=!X.value)}function Gr(f){if(!X.value)return;const y=K.value;y&&!y.contains(f.target)&&(X.value=!1)}function _0(){X.value=!1,x0()}function C0(){s.value||(Ce.value=[],X.value=!1,re.value=!0)}function v0(){re.value=!1,Ce.value=[]}function E0(){if(s.value||!ae)return;const f=hc(ge.value.coordinates??"",ge.value.format||"decimal",ge.value.order||"lat-lon");if(!f.ok){Ce.value=f.errors,B0(f.errors);return}Ce.value=[],In({type:"Polygon",coordinates:[f.ring]}),Ft(),re.value=!1,f.wasClosedAutomatically&&he.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function B0(f){if(!f.length)return;const y=5;f.slice(0,y).forEach(_=>{const A=_.line>0?`Рядок ${_.line}`:"Загальна помилка";he.notify({type:"warning",title:"Імпорт координат",message:`${A} — ${_.message}`})}),f.length>y&&he.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${f.length-y}`})}function V0(f){if(s.value||!ae)return;X.value=!1;const y=f.target,_=y.files?.[0];if(!_)return;const A=new FileReader;A.onload=()=>{try{const T=JSON.parse(String(A.result));if(!oe(T).length){he.notify({type:"warning",title:"Імпорт файлу",message:"Файл не містить коректний GeoJSON-обʼєкт."});return}In(T),Ft()}catch{he.notify({type:"error",title:"Імпорт файлу",message:"Не вдалося прочитати файл. Перевірте формат GeoJSON/JSON."})}finally{y.value=""}},A.onerror=()=>{he.notify({type:"error",title:"Імпорт файлу",message:"Помилка читання файлу."}),y.value=""},A.readAsText(_)}function S0(){if(s.value||!ae)return;const f=ae.getAll(),y=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),_=URL.createObjectURL(y),A=document.createElement("a");A.href=_,A.download="data.geojson",A.click(),URL.revokeObjectURL(_)}return e.onMounted(async()=>{if(window.addEventListener("click",Gr,!0),!c.value)return;const f=await $e();Ne=f.maplibregl,Qe=f.MapboxDraw;const y=qe();y&&(Q=new Ne.Map({container:c.value,style:Se(y),center:[I.value[0],I.value[1]],zoom:v.value,attributionControl:!1}),x.value=Q,Q.addControl(new Ne.NavigationControl({showCompass:!0}),"bottom-right"),Q.on("load",()=>{if(!(!Qe||!Q)){if(ae=new Qe({displayControlsDefault:!1,modes:{...Qe.modes,draw_rectangle:ve()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:et}),Q.addControl(ae),Q.on("click",_=>{if(b.isRulerActive.value){const T=_?.lngLat;if(!T)return;m.value?.addPoint?.({lat:T.lat,lng:T.lng});return}if(!ae||s.value||u.value!=="edit")return;const A=it(_?.point);!A||A===U||requestAnimationFrame(()=>{!ae||s.value||vt(A)})}),Q.on("draw.create",()=>{if(ae&&!b.isRulerActive.value){if(!a.value){const _=ae.getAll();if(_.features.length>1){const A=_.features[_.features.length-1];se=!0,_.features.slice(0,-1).forEach(T=>ae.delete(T.id)),se=!1,A&&(se=!0,ae.add(A),se=!1)}}Ft(),vt()}}),Q.on("draw.update",_=>{if(H||b.isRulerActive.value)return;const A=Array.isArray(_?.features)?_.features:[],T=_?.action==="move"&&A.length>0&&A.every(G=>G?.geometry?.type==="Point");if(_?.action==="move"){if(T){Ft();return}if(H=!0,h0(),H=!1,u.value==="edit"){const G=ln(),le=G?st(G):ae?.getAll?.()?.features?.[0];if(le?.id)try{ae.changeMode("direct_select",{featureId:le.id}),U=String(le.id)}catch{u.value=""}}return}Ft()}),Q.on("draw.delete",()=>{we||F||b.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle"||(Ft(),ae?.getAll?.()?.features?.length||(U=null),u.value="",jt())}),Q.on("draw.selectionchange",_=>{if(!ae||H||b.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle")return;const A=_?.features?.[0]?.id!==void 0&&_?.features?.[0]?.id!==null?String(_.features[0].id):null;if(!s.value&&A){if(u.value==="edit"&&U===A)return;requestAnimationFrame(()=>{!ae||s.value||vt(A)});return}const T=ae.getSelectedIds?.(),G=Array.isArray(T)&&T.length>0?String(T[0]):null;if(!s.value&&G){if(u.value==="edit"&&U===G)return;requestAnimationFrame(()=>{!ae||s.value||vt(G)});return}try{ae.changeMode("simple_select",{featureIds:[]})}catch{}}),M.value!==void 0){const _=M.value;M.value=void 0,requestAnimationFrame(()=>{ae&&In(_)})}Rt(),ce.value.forEach(_=>{const A=J[_];A&&At(A)}),bt()}}),Q.on("contextmenu",p0),Q.on("zoomend",()=>{Q&&(v.value=Q.getZoom())}))}),e.onUnmounted(()=>{b.isRulerActive.value&&b.closeRuler(),window.removeEventListener("click",Gr,!0),Object.values(J).forEach(f=>{Q&&Nt(f)}),Ke(),ie?.remove&&ie.remove(),ie=null,Q?.remove&&Q.remove(),Q=null,ae=null,x.value=null}),e.watch(()=>n.modelValue,f=>{if(!ae){M.value=f;return}const y=ue((a.value?oe(f):oe(f).slice(0,1))||[]),_=Ve(y);if(q&&_===q){q=null;return}q=null,In(f)},{deep:!0}),e.watch(()=>E.value,f=>{const y=Array.isArray(f)?f:[],_=[],A=new Set;y.forEach((T,G)=>{if(!T)return;const le=gt(T,G);_.push(le),A.add(le);const pe={...T,id:le},Le=J[le],nt=Le?.visible??!!pe.visible;Le&&Q&&Nt(Le),J[le]={id:le,config:pe,visible:nt,sourceId:`vs-ov-src-${le}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(J).forEach(T=>{if(A.has(T))return;const G=J[T];G&&Q&&Nt(G),delete J[T]}),ce.value=_,Q&&(ce.value.forEach(T=>{const G=J[T];G&&At(G)}),bt())},{immediate:!0,deep:!0}),e.watch(()=>N.value,()=>{Q&&(Rt(),ce.value.forEach(f=>{const y=J[f];y&&At(y)}),bt())},{deep:!0}),e.watch(()=>$.value,async f=>{if(W.value=[],!f){Q&&(Rt(),ce.value.forEach(y=>{const _=J[y];_&&At(_)}),bt());return}try{const y=await fetch(`https://data.gki.com.ua/api-user/atu/${f}`);if(!y?.ok)return;const A=(await y.json())?.geometry?.coordinates;Array.isArray(A)&&A.length&&(W.value=A)}catch(y){console.error("Failed to fetch KATOTTG bounds",y)}finally{if(!Q)return;Rt(),ce.value.forEach(y=>{const _=J[y];_&&At(_)}),bt()}},{immediate:!0}),e.watch(()=>B.value,f=>{if(!Array.isArray(f)||f.length!==2)return;const y=[Number(f[0]),Number(f[1])];if(qr(I.value,y)||(I.value=[...y],!Q))return;const _=Q.getCenter?.();_&&qr([_.lng,_.lat],I.value)||Q.easeTo({center:[I.value[0],I.value[1]]})},{deep:!0}),e.watch(()=>S.value,f=>{typeof f=="number"&&(v.value=f,Q&&Q.setZoom(f))}),e.watch(s,f=>{f&&jt()}),e.watch(d,f=>{if(f>0){s.value||vt();return}ee||jt()}),e.watch(i,()=>{setTimeout(()=>{Q?.resize&&Q.resize()},50)}),(f,y)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!i.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:i.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:c,class:"w-full h-[calc(100%-28px)]"},null,512),Be.value.search||Be.value.import||Be.value.export?(e.openBlock(),e.createElementBlock("div",Ad,[Be.value.search?(e.openBlock(),e.createBlock(Tc,{key:0,onGoToCoordinates:k0})):e.createCommentVNode("",!0),Be.value.import||Be.value.export?(e.openBlock(),e.createElementBlock("div",Fd,[e.createElementVNode("div",Md,[Be.value.import?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:K,class:"relative"},[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:w0,disabled:s.value},[y[8]||(y[8]=e.createTextVNode(" Імпорт ",-1)),e.createVNode(e.unref(P.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":X.value}])},null,8,["class"])],8,Dd),X.value?(e.openBlock(),e.createElementBlock("div",Td,[Be.value.import?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:_0}," З файлу ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:C0}," З координат ")])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),Be.value.export?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:S0,disabled:s.value||d.value===0}," Експорт ",8,Ld)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:D,type:"file",onChange:V0,accept:".json,.geojson",class:"hidden",disabled:s.value},null,40,Id)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(he.VsModal),{visible:re.value,"onUpdate:visible":y[1]||(y[1]=_=>re.value=_),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(rt,{schema:te,values:ge.value,"onUpdate:values":y[0]||(y[0]=_=>ge.value=_)},null,8,["values"]),e.createElementVNode("div",Rd,[e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:v0}," Скасувати "),e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:E0,disabled:s.value}," Побудувати ",8,Od)])]),_:1},8,["visible"]),e.createElementVNode("div",zd,[e.createElementVNode("div",Pd,[Be.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="marker"}]),title:"Point",onClick:y[2]||(y[2]=_=>Rn("marker")),disabled:s.value},[e.createVNode(e.unref(P.MapPin),{class:"h-4 w-4"})],10,jd)):e.createCommentVNode("",!0),Be.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polyline"}]),title:"Line",onClick:y[3]||(y[3]=_=>Rn("polyline")),disabled:s.value},[e.createVNode(ec)],10,Ud)):e.createCommentVNode("",!0),Be.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polygon"}]),title:"Polygon",onClick:y[4]||(y[4]=_=>Rn("polygon")),disabled:s.value},[e.createVNode(rc)],10,Hd)):e.createCommentVNode("",!0),Be.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="rectangle"}]),title:"Rectangle",onClick:y[5]||(y[5]=_=>Rn("rectangle")),disabled:s.value},[e.createVNode(ic)],10,qd)):e.createCommentVNode("",!0),Be.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(b).isRulerActive.value}]),title:"Ruler",onClick:g},[e.createVNode(e.unref(P.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:y[6]||(y[6]=_=>i.value=!i.value),title:"Full Screen"},[e.createVNode(e.unref(P.Maximize),{class:"h-4 w-4"})])])]),Be.value.ruler&&e.unref(b).isRulerActive.value?(e.openBlock(),e.createBlock(Sd,{key:1,ref_key:"rulerPanelRefEl",ref:m,onClose:y[7]||(y[7]=_=>e.unref(b).closeRuler()),onTabChange:e.unref(b).onRulerTabChange,onPointsChange:e.unref(b).onRulerPointsChange,onShapeClosedChange:e.unref(b).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),Be.value.ruler&&e.unref(b).isRulerActive.value&&e.unref(b).hasRulerPoints.value?(e.openBlock(),e.createBlock($d,{key:2,map:x.value,points:e.unref(b).rulerPoints.value,"is-shape-closed":e.unref(b).rulerShapeClosed.value,"label-mode":e.unref(b).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),Ae.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(Re.value)},[e.createElementVNode("div",Kd,[e.createElementVNode("dl",Wd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ae.value,_=>(e.openBlock(),e.createElementBlock("div",{key:`${_.key}-${_.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",Gd,e.toDisplayString(_.key),1),e.createElementVNode("dd",Yd,e.toDisplayString(_.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Xd,[e.createElementVNode("div",Zd,[e.createVNode(fc,{basemaps:e.unref(ne),onOnLayerChange:yo},null,8,["basemaps"]),ye.value.length?(e.openBlock(),e.createElementBlock("div",Jd,[y[9]||(y[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",Qd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ye.value,_=>(e.openBlock(),e.createElementBlock("label",{key:_.id,class:"flex items-center gap-2 cursor-pointer select-none"},[e.createElementVNode("input",{type:"checkbox",class:"rounded border-gray-300 text-blue-600 focus:ring-blue-500",checked:_.visible,disabled:s.value,onChange:A=>go(_.id)},null,40,eu),e.createElementVNode("span",tu,e.toDisplayString(_.config.title||_.config.name||_.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",nu,[h.value.length||p.value?(e.openBlock(),e.createElementBlock("div",ou,[e.createElementVNode("div",ru,[e.createElementVNode("div",lu,[y[10]||(y[10]=e.createTextVNode(" Тип: ",-1)),h.value.length<=1?(e.openBlock(),e.createElementBlock("span",au,e.toDisplayString(p.value?Hr(p.value.type):h.value[0]?.label||"—"),1)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(h.value,(_,A)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:_.id},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["font-bold underline-offset-2",_.id===e.unref(U)?"text-blue-700 underline":"text-gray-700 hover:text-blue-700 hover:underline"]),onClick:T=>g0(_.id),disabled:s.value},e.toDisplayString(_.label),11,su),A<h.value.length-1?(e.openBlock(),e.createElementBlock("span",iu,", ")):e.createCommentVNode("",!0)],64))),128))])]),e.createElementVNode("div",cu,[e.createElementVNode("div",du,[y[11]||(y[11]=e.createTextVNode(" Центр: ",-1)),p.value?(e.openBlock(),e.createElementBlock("b",uu,e.toDisplayString(p.value.center.lng.toFixed(5))+", "+e.toDisplayString(p.value.center.lat.toFixed(5)),1)):(e.openBlock(),e.createElementBlock("b",pu,"—"))]),p.value&&p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",fu,[y[12]||(y[12]=e.createTextVNode(" Площа: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",mu,y[13]||(y[13]=[e.createTextVNode("Площа: ",-1),e.createElementVNode("b",null,"—",-1)]))),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md mr-1 cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Zoom to feature",onClick:b0,disabled:s.value},[e.createVNode(e.unref(P.ZoomIn),{class:"h-3 w-3"})],8,hu),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Delete feature",onClick:y0,disabled:s.value},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})],8,gu)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-33669cd5"]]),yu=["data-focus"],bu={class:"flex items-center"},ku={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},xu=["onClick","aria-label"],wu={key:0,class:"absolute text-gray-500 truncate pl-2"},_u={class:"flex-1 min-w-[2px]"},Cu=["placeholder"],vu={class:"flex items-center shrink-0"},Eu=["disabled"],qo=e.defineComponent({__name:"vs-input-tag",props:e.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t;ze(n.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),i=e.ref(!1),c=e.ref(""),d=e.useModel(o,"modelValue"),u=e.computed(()=>n.placeholder||"Add tag…"),p=e.computed(()=>d.value?.length===0&&c.value===""),h=e.computed(()=>!n.disabled&&d.value?.length>0),x=e.computed(()=>n.disabled),m=async()=>{x.value||await e.nextTick(()=>s.value?.focus())},b=Y=>{const L=Y.trim();L!==""&&(!d.value||!Array.isArray(d.value)?d.value=[L]:n.unique?d.value.includes(L)||(d.value=[...d.value,L]):d.value=[...d.value,L],c.value="")},g=()=>{const Y=c.value;Y.trim()!==""&&b(Y),c.value=""},C=Y=>{const L=d.value.slice();L.splice(Y,1),r("update:modelValue",L)},k=()=>{r("update:modelValue",[])},w=()=>{x.value||(i.value=!0)},V=()=>{i.value=!1,!x.value&&g()},R=Y=>{const{key:L}=Y;L==="Enter"?(Y.preventDefault(),g()):L==="Backspace"&&c.value===""&&d.value.length>0&&C(d.value.length-1)};return(Y,L)=>(e.openBlock(),e.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:l,onClick:L[1]||(L[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass]),role:"group","aria-label":"Tag input"},[e.createElementVNode("div",{class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",i.value?"border-blue-500 ring-1 ring-blue-500":"",x.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":i.value?"true":"false",onClick:m},[e.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:a},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(B,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",bu,[e.createElementVNode("div",ku,e.toDisplayString(B),1)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border hover:bg-[#ffbdad] hover:text-[#de350b]",onClick:e.withModifiers($=>C(S),["stop"]),"aria-label":`Remove ${B}`},[e.createVNode(e.unref(P.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,xu)]))),128)),p.value?(e.openBlock(),e.createElementBlock("div",wu,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",_u,[x.value?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:s,class:"pl-2 w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-label":"Add tag","onUpdate:modelValue":L[0]||(L[0]=B=>c.value=B),onFocus:w,onBlur:V,onKeydown:R,placeholder:d.value&&d.value.length?"":void 0},null,40,Cu)),[[e.vModelText,c.value]])])],512),e.createElementVNode("div",vu,[h.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-label":"Clear all tags",disabled:x.value,onClick:e.withModifiers(k,["stop"])},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,Eu)):e.createCommentVNode("",!0)])],10,yu)],2)],512))}}),Bu={class:"relative flex gap-1 bg-white w-full"},Vu=["disabled","placeholder"],Ko=xe(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.inject("values"),n=o,r=e.useModel(o,"modelValue");function l(s){const i={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return s.toLowerCase().split("").map(c=>i[c]||c).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[n.parent||""]?.toString(),i=l(s);r.value=i.toString()};return(s,i)=>(e.openBlock(),e.createElementBlock("div",Bu,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:s.disabled,placeholder:s.placeholder,"onUpdate:modelValue":i[0]||(i[0]=c=>r.value=c),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Vu),[[e.vModelText,r.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:a}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),Su={class:"relative flex gap-1 bg-white w-full"},$u=["disabled","placeholder"],Nu=["disabled"],Au={key:0},Fu={key:1},Wo=xe(e.defineComponent({__name:"vs-input-codegen",props:e.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(!1),l=e.computed(()=>t.init!==!1),a=e.computed(()=>!!t.table&&!!t.code),s=()=>{if(!a.value)return"";const d=encodeURIComponent(String(t.table)),u=encodeURIComponent(String(t.code));return`/api/code-gen/${d}/${u}`},i=async()=>{if(!a.value||r.value)return;const d=s();if(d){r.value=!0;try{const p=await(await fetch(d)).text();n.value=p}finally{r.value=!1}}},c=()=>{l.value&&(n.value||i())};return e.onMounted(()=>{c()}),e.watch(()=>[t.table,t.code,t.init],()=>{c()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",Su,[e.withDirectives(e.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":u[0]||(u[0]=p=>n.value=p),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,$u),[[e.vModelText,n.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:r.value||d.disabled||!a.value,onClick:i},[r.value?(e.openBlock(),e.createElementBlock("span",Fu,"...")):(e.openBlock(),e.createElementBlock("span",Au,"Gen"))],8,Nu)]))}}),[["__scopeId","data-v-6ee5237d"]]),Mu={class:"w-full"},Du={ref:"sortableContainer",class:"flex flex-col gap-1"},Tu=["onDragstart","onDrop"],Lu={class:"cursor-move",type:"button"},Iu={class:"w-1/3"},Ru={class:"w-2/3"},Ou=["onClick"],zu={key:0,class:"text-[14px] text-gray-700"},Pu={class:"mt-2 w-full flex items-center"},ju=["disabled"],Go=xe(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,r=e.inject("values"),l=o,a=t,s=l.addButtonText??"Додати",i=l.ignore??[],c=e.ref([]),d=e.ref(null);(()=>{const g=l.parent&&r?.value?.[l.parent]||l.modelValue||{};c.value=Object.entries(g).filter(([C])=>!i.includes(C)).map(([C,k])=>({id:n("key-value-"),key:C,value:k}))})();function p(g){d.value=g}function h(g){if(d.value===null||d.value===g)return;const C=c.value.splice(d.value,1)[0];c.value.splice(g,0,C),d.value=null}const x=e.computed(()=>c.value.some(g=>g.key&&!g.value||!g.key&&g.value)),m=()=>{c.value.push({id:n("key-value-"),key:"",value:""})},b=g=>{c.value=c.value.filter(C=>C.id!==g)};return e.watch(c,g=>{const C={};g.forEach(w=>{w.key&&w.value!==void 0&&(C[w.key]=w.value)});const k={};i.length&&i.forEach(w=>{k[w]=l.parent?r?.value?.[l.parent]?.[w]:void 0}),r?.value&&l.parent&&(r.value[l.parent]={...k,...C}),a("update:modelValue",C)},{deep:!0}),(g,C)=>(e.openBlock(),e.createElementBlock("div",Mu,[e.createElementVNode("div",Du,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(k,w)=>(e.openBlock(),e.createElementBlock("div",{key:k.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===w}]),draggable:"true",onDragstart:V=>p(w),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:V=>h(w)},[e.createElementVNode("button",Lu,[e.createVNode(e.unref(P.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",Iu,[e.createVNode(Ot,{modelValue:k.key,"onUpdate:modelValue":V=>k.key=V,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",Ru,[e.createVNode(Ot,{modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:V=>b(k.id),class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,Ou)],42,Tu))),128))],512),c.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",zu," Дані для відображення відсутні ")),e.createElementVNode("div",Pu,[e.createElementVNode("button",{type:"button",onClick:m,disabled:x.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(s)),1)],8,ju)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),Uu={class:"w-full"},Hu={ref:"sortableContainer",class:"flex flex-col gap-1"},qu=["onDragstart","onDrop"],Ku=["disabled"],Wu={class:"flex-1"},Gu=["onClick","disabled"],Yu={key:0,class:"text-[14px] text-gray-700"},Xu={class:"mt-2 w-full flex items-center"},Zu=["disabled"],Yo=xe(e.defineComponent({__name:"vs-input-text-array",props:e.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),i=e.computed(()=>t.addButtonText??"Додати");let c=!1;const d=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,u=g=>{const C=g??n.value??[];r.value=C.map((k,w)=>({id:r.value[w]?.id??d("text-array"),value:k??""}))};u(),e.watch(()=>n.value,g=>{if(c){c=!1;return}u(g||[])},{deep:!0}),e.watch(r,g=>{c=!0,n.value=g.map(C=>C.value).filter(C=>C!=null&&C!=="")},{deep:!0});const p=e.computed(()=>a.value||r.value.some(g=>!g.value));function h(){p.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function x(g){a.value||(r.value=r.value.filter(C=>C.id!==g))}function m(g){a.value||(l.value=g)}function b(g){if(a.value||l.value===null||l.value===g)return;const C=[...r.value],[k]=C.splice(l.value,1);C.splice(g,0,k),r.value=C,l.value=null}return(g,C)=>(e.openBlock(),e.createElementBlock("div",Uu,[e.createElementVNode("div",Hu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(k,w)=>(e.openBlock(),e.createElementBlock("div",{key:k.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":l.value===w}]),draggable:"true",onDragstart:V=>m(w),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:V=>b(w)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(P.GripVertical),{class:"h-4 w-4"})],8,Ku),e.createElementVNode("div",Wu,[g.inputType==="text"?(e.openBlock(),e.createBlock(Ot,{key:0,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="tel"?(e.openBlock(),e.createBlock(Un,{key:1,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="email"?(e.openBlock(),e.createBlock(jn,{key:2,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="mask"?(e.openBlock(),e.createBlock(cn,{key:3,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,mask:g.mask,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:V=>x(k.id),disabled:a.value,class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200 disabled:opacity-50"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,Gu)],42,qu))),128))],512),r.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Yu," Дані для відображення відсутні ")),e.createElementVNode("div",Xu,[e.createElementVNode("button",{type:"button",onClick:h,disabled:p.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(i.value),1)],8,Zu)])]))}}),[["__scopeId","data-v-2c229b1f"]]),Ju={class:"flex items-center gap-2 w-full"},Qu=["disabled"],ep=["disabled"],Xo=e.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=ze(n.style),l=t,a=e.computed({get:()=>n.modelValue||"#000000",set:i=>l("update:modelValue",i)}),s=e.computed(()=>!!n.disabled);return(i,c)=>(e.openBlock(),e.createElementBlock("div",Ju,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":c[0]||(c[0]=d=>a.value=d),disabled:s.value,ref:"color",class:e.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[i.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,Qu),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":c[1]||(c[1]=d=>a.value=d),disabled:s.value},null,8,ep),[[e.vModelText,a.value]])]))}}),tp={class:"flex items-center gap-2 w-full"},np=["min","max","step","disabled"],op=["value","min","max","step","disabled"],Zo=e.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=ze(n.style),l=t,a=u=>{const p=Number(u),h=Number(n.min),x=Number(n.max);return Number.isNaN(p)?h:Math.min(x,Math.max(h,p))},s=e.computed({get:()=>a(n.modelValue??n.min),set:u=>l("update:modelValue",a(u))}),i=u=>{const p=u.target,h=a(p.value);p.value=String(h),l("update:modelValue",h)},c=u=>{Number(n.min)>=0&&u.key==="-"&&u.preventDefault()},d=e.computed(()=>!!n.disabled);return(u,p)=>(e.openBlock(),e.createElementBlock("div",tp,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":p[0]||(p[0]=h=>s.value=h),min:u.min,max:u.max,step:u.step,disabled:d.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[u.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")])},null,10,np),[[e.vModelText,s.value]]),e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number",value:s.value,min:u.min,max:u.max,step:u.step,onInput:i,onKeydown:c,disabled:d.value},null,40,op)]))}}),rp=["placeholder","disabled","name"],lp=["type","value","onInput","placeholder","disabled"],ap=["onClick"],Jo=e.defineComponent({__name:"vs-input-array",props:e.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.ref(t.count),r=e.computed(()=>t.limit),{inputClass:l}=ze(t.style),a=e.useModel(o,"modelValue"),s=e.computed(()=>!!t.disabled),i=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const b=a.value?.length??0;b<n.value&&(a.value=[...a.value??[],...Array(n.value-b)])});const c=e.ref({}),d=e.ref({});function u(b,g){b&&(c.value[g]=b)}async function p(b,g){if(!b||t.inputType!=="mask")return;const{default:C}=await Promise.resolve().then(()=>so);d.value[g]&&d.value[g].destroy(),d.value[g]=C(b,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[g].on("accept",()=>{const k=[...a.value||[]];k[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=k}),d.value[g].on("complete",()=>{const k=[...a.value||[]];k[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=k}),a.value?.[g]&&(d.value[g].value=a.value[g])}function h(b,g){if(s.value)return;const C=b.target.value??null,k=[...a.value];k[g]=t.inputType==="text"?C:Number(C),a.value=k}function x(){n.value+=1;const b=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,b],t.inputType==="mask"&&setTimeout(()=>{const g=n.value-1;c.value[g]&&p(c.value[g],g)},0)}function m(b){if(n.value>1){d.value[b]&&(d.value[b].destroy(),delete d.value[b]),n.value-=1,a.value=a.value.filter((C,k)=>k!==b);const g={};Object.keys(d.value).forEach(C=>{const k=parseInt(C,10);k>b?g[k-1]=d.value[k]:k<b&&(g[k]=d.value[k])}),d.value=g}}return e.onMounted(()=>{if(t.inputType==="mask")for(let b=0;b<n.value;b+=1)c.value[b]&&p(c.value[b],b)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(b=>{b&&b.destroy()})}),e.watch(()=>t.mask,b=>{t.inputType==="mask"&&Object.values(d.value).forEach(g=>{g&&g.updateOptions({mask:b,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,b=>{t.inputType==="mask"&&b&&b.forEach((g,C)=>{d.value[C]&&d.value[C].value!==g&&(d.value[C].value=g||"")})},{deep:!0}),(b,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["grid gap-2",`grid-cols-${r.value}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,C=>(e.openBlock(),e.createElementBlock("div",{key:C,class:"flex items-center gap-2 w-full"},[b.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:k=>u(k,C-1),placeholder:b.placeholder,disabled:b.disabled,name:`${b.name}[${C-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":b.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,rp)):(e.openBlock(),e.createElementBlock("input",{key:1,type:b.inputType,value:a.value?.[C-1],onInput:k=>h(k,C-1),placeholder:i.value,disabled:s.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":b.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,lp)),!b.disabled&&C===n.value&&b.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(x,["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-green-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"})])):e.createCommentVNode("",!0),!b.disabled&&n.value>1&&b.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(k=>m(C-1),["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-red-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,ap)):e.createCommentVNode("",!0)]))),128))],2))}}),sp={class:"flex gap-1 w-full"},ip=["aria-expanded","data-focus"],cp=["placeholder","disabled","readonly"],dp={class:"max-h-full"},up=["onClick","disabled"],pp={key:0,class:"px-3 py-2 text-sm text-stone-500"},fp=["disabled"],mp={class:"flex flex-col gap-1"},hp=["onDragstart","onDrop"],gp=["disabled"],yp=["title"],bp=["disabled","onClick","aria-label"],kp={key:0,class:"text-xs text-stone-500"},wn=xe(e.defineComponent({__name:"vs-input-array-select",props:e.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},add:{},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t,l=e.useModel(o,"modelValue"),a=e.ref([]),s=e.ref(n.options??[]),i=e.ref({}),c=e.ref({}),d=e.ref({keyword:"",parent:null}),u=e.ref(""),p=e.ref(!1),h=e.ref(null),x=e.ref(null),m=e.ref(null),b=e.ref(null),g=e.ref(null),C=e.ref({});let k=!1,w=!1;const V=e.inject("values"),R=e.computed(()=>!!n.disabled),Y=e.computed(()=>n.placeholder??"Оберіть значення"),L=e.computed(()=>n.search!==!1),B=e.computed(()=>{const F=n.parent??n.parentValue;return F?String(F):""}),S=e.computed(()=>B.value?V?.value?.[B.value]??null:null),$=F=>F==null?"__null__":String(F),E=F=>{if(!F)return"";const H=F.label??F.text??F.name??F.ua??F.en;return H?String(H):F.id!==void 0&&F.id!==null?String(F.id):""},N=F=>{const H=$(F);return c.value[H]||(c.value[H]=`array-select-${H}-${Math.random().toString(36).slice(2,8)}`),c.value[H]},I=e.computed(()=>new Set(a.value.map(F=>$(F.id)))),v=e.computed(()=>{const F=I.value;let H=[...s.value];if(!n.data&&u.value.trim()){const ee=u.value.toLowerCase();H=H.filter(ie=>E(ie).toLowerCase().includes(ee))}return H.filter(ee=>!F.has($(ee.id)))}),M=()=>{if(!n.data)return"";const F=n.prefix??"api",H=n.api??`/${F}/suggest/${n.data}`;return`${n.host??""}${H}`},D=()=>{a.value.length&&(k=!0,a.value=a.value.map(F=>({...F,text:i.value[$(F.id)]??F.text})))},K=F=>{const H=$(F.id),ee=E(F);ee&&(i.value[H]=ee)},W=F=>{s.value=F?[...F]:[],F?.forEach(K),D()},X=F=>{if(!F.length)return;const H=new Map(s.value.map(ee=>[$(ee.id),ee]));F.forEach(ee=>{const ie=$(ee.id);H.set(ie,ee),K(ee)}),s.value=Array.from(H.values()),D()},re=async(F="")=>{if(!n.data)return[];const H=M();if(!H)return[];const ee=new URLSearchParams;ee.set("json","1"),F&&ee.set("key",F),n.start===1&&ee.set("start","1"),S.value!==null&&S.value!==void 0&&S.value!==""&&ee.set("parent",String(S.value));try{return(await(await fetch(`${H}?${ee.toString()}`)).json())?.data??[]}catch{return[]}},Ce=async F=>{if(!n.data||!F.length)return[];const H=M();if(!H)return[];const ee=Array.from(new Set(F.map(ve=>$(ve)))),ie=new URLSearchParams;ie.set("json","1"),ie.set("val",ee.join(",")),n.start===1&&ie.set("start","1"),S.value!==null&&S.value!==void 0&&S.value!==""&&ie.set("parent",String(S.value));try{const qe=(await(await fetch(`${H}?${ie.toString()}`)).json())?.data??[];return X(qe),qe}catch{return[]}},ge=async F=>{if(F==null||F==="")return null;const H=$(F),ee=s.value.find(ve=>$(ve.id)===H);if(ee)return ee;const[ie]=await Ce([F]);return ie??null},te=async(F="",{force:H=!1}={})=>{if(!n.data)return;const ee=S.value??null;if(!H&&d.value.keyword===F&&d.value.parent===ee&&s.value.length>0)return;d.value={keyword:F,parent:ee};const ve=await re(F);W(ve)},we=((F,H=200)=>{let ee;return(...ie)=>{ee&&clearTimeout(ee),ee=setTimeout(()=>F(...ie),H)}})(async F=>{n.data&&await te(F,{force:!0})},250),J=e.ref(null),ce=()=>{if(!m.value)return;const F=m.value.getBoundingClientRect(),H=window.innerHeight??document.documentElement.clientHeight,ee=window.innerWidth??document.documentElement.clientWidth,ie=8,ve=8,et=n.maxHeight??280,qe=H-F.bottom-ve-ie,gt=F.top-ve-ie,He=qe>=gt,Ke=Math.max(ee-ie*2,0);let{width:yt}=F;Ke>0&&yt>Ke&&(yt=Ke);let{left:lt}=F;lt+yt+ie>ee&&(lt=ee-yt-ie),lt=Math.max(lt,ie);const It=Math.min(et,Math.max(He?qe:gt,50));C.value={position:"fixed",left:`${lt}px`,width:`${yt}px`,maxHeight:`${It}px`,transform:He?"none":"translateY(-100%)",top:He?`${F.bottom+ve}px`:`${F.top-ve}px`}},ye=async(F="click")=>{R.value||p.value||(J.value=F,await te(u.value.trim()),p.value=!0,await e.nextTick(),ce(),g.value?.focus())},Ee=()=>{p.value=!1,J.value=null,e.nextTick(()=>{g.value?.blur()})},Ae=async F=>{if(F.stopPropagation(),!R.value){if(p.value){if(J.value==="focus"){J.value=null;return}Ee();return}await ye("click")}},Re=F=>{F.key==="Escape"&&Ee()},Fe=F=>{if(!p.value)return;const H=F.target;b.value?.contains(H)||Ee()},Be=F=>{const H=F.target;x.value?.contains(H)||b.value?.contains(H)||Ee()},j=F=>{if(F.key==="Escape"){F.preventDefault(),Ee();return}if(F.key==="Enter"){F.preventDefault();const H=v.value[0];H&&Z(H)}},Z=F=>{if(!F)return;const H=$(F.id);if(I.value.has(H))return;K(F);const ee={id:F.id,text:E(F)||String(F.id??""),key:N(F.id)};a.value=[...a.value,ee],ne(F),u.value="",e.nextTick(()=>{g.value?.focus()})},ne=F=>{const H=a.value.map(ee=>ee.id);r("value-selected",{name:n.name,value:H,option:F})},de=F=>{if(R.value)return;const H=a.value.filter(ee=>$(ee.id)!==$(F));a.value=H},{isOpenAdd:me,addData:$e,addSchema:Se,addForm:Ne,addTitle:Qe,addOption:Q,onAddValue:ae}=Mo({props:n,fetchOptionByValue:ge,optionsList:s,selectedOption:e.ref(null),modelValue:l,onCreated:async(F,H)=>{const ee=F??await ge(H),ie=ee?.id??H;I.value.has($(ie))||(ee&&K(ee),a.value=[...a.value,{id:ie,text:ee?E(ee):String(ie),key:N(ie)}],ne(ee??null))}}),Me=F=>{R.value||(h.value=F)},z=F=>{if(R.value||h.value===null||h.value===F)return;const H=[...a.value],[ee]=H.splice(h.value,1);H.splice(F,0,ee),h.value=null,a.value=H},q=async()=>{const H=(Array.isArray(l.value)?[...l.value]:[]).filter(ie=>ie!=null);if(n.data&&H.length){const ie=H.filter(ve=>!i.value[$(ve)]);ie.length&&await Ce(ie)}const ee=H.map(ie=>({id:ie,text:i.value[$(ie)]??String(ie),key:N(ie)}));k=!0,a.value=ee};e.watch(a,F=>{if(k){k=!1;return}const H=F.map(ee=>ee.id);w=!0,l.value=H,r("change",H)},{deep:!0}),e.watch(l,()=>{if(w){w=!1;return}q()},{deep:!0}),e.watch(u,F=>{!n.data||!p.value||we(F.trim())}),e.watch(R,F=>{F&&Ee()}),e.watch(()=>n.options,async F=>{n.data||(W(F??[]),await q())},{immediate:!0,deep:!0}),e.watch(()=>n.data,async F=>{F&&(await te(u.value.trim()),await q())},{immediate:!0});const U=e.ref(!1);return e.watch(S,async()=>{if(n.data){if(!U.value){U.value=!0;return}a.value=[],await te(u.value.trim()),await q()}}),e.onMounted(async()=>{document.addEventListener("click",Be,!0),window.addEventListener("keydown",Re),window.addEventListener("scroll",Fe,!0),await q()}),e.onUnmounted(()=>{document.removeEventListener("click",Be,!0),window.removeEventListener("keydown",Re),window.removeEventListener("scroll",Fe,!0)}),(F,H)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(he.VsModal),{visible:e.unref(me),"onUpdate:visible":H[1]||(H[1]=ee=>e.isRef(me)?me.value=ee:null),class:"z-[1000]",title:e.unref(Qe),buttonText:"Додати",onDone:e.unref(Q)},{default:e.withCtx(()=>[e.createVNode(rt,{schema:e.unref(Se),modelValue:e.unref($e),"onUpdate:modelValue":H[0]||(H[0]=ee=>e.isRef($e)?$e.value=ee:null),ref_key:"addForm",ref:Ne},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),e.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:x},[e.createElementVNode("div",sp,[e.createElementVNode("div",{class:"relative flex-1",onClick:H[4]||(H[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",p.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",R.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),role:"combobox","aria-expanded":p.value,"aria-haspopup":"listbox","data-focus":p.value?"true":"false",onClick:Ae},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":H[2]||(H[2]=ee=>u.value=ee),placeholder:Y.value,disabled:R.value,readonly:!L.value,onFocus:H[3]||(H[3]=()=>ye("focus")),onKeydown:j,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,cp),[[e.vModelText,u.value]]),e.createElementVNode("span",{class:e.normalizeClass(["text-stone-400 transition-transform duration-150",p.value?"rotate-180":""]),"aria-hidden":"true"},[e.createVNode(e.unref(P.ChevronDown),{class:"h-4 w-4"})],2)],10,ip),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:b,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(C.value)},[e.createElementVNode("div",dp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,ee=>(e.openBlock(),e.createElementBlock("button",{key:$(ee.id),type:"button",class:"w-full px-3 py-2 text-left text-sm text-stone-900 hover:bg-stone-100 disabled:opacity-50",onClick:e.withModifiers(ie=>Z(ee),["stop"]),disabled:R.value},e.toDisplayString(E(ee)),9,up))),128)),v.value.length===0?(e.openBlock(),e.createElementBlock("p",pp," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:H[5]||(H[5]=(...ee)=>e.unref(ae)&&e.unref(ae)(...ee)),class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:R.value,type:"button"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),H[8]||(H[8]=e.createElementVNode("span",null,"Додати",-1))],8,fp)):e.createCommentVNode("",!0)]),e.createElementVNode("div",mp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(ee,ie)=>(e.openBlock(),e.createElementBlock("div",{key:ee.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":h.value===ie}]),draggable:"true",onDragstart:ve=>Me(ie),onDragover:H[6]||(H[6]=e.withModifiers(()=>{},["prevent"])),onDrop:ve=>z(ie),onDragend:H[7]||(H[7]=ve=>h.value=null)},[e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-500 hover:text-stone-900",disabled:R.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(P.GripVertical),{class:"h-4 w-4"})],8,gp),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:ee.text},e.toDisplayString(ee.text),9,yp),e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-400 hover:text-stone-900",disabled:R.value,onClick:e.withModifiers(ve=>de(ee.id),["stop"]),"aria-label":`Видалити ${ee.text}`},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,bp)],42,hp))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",kp,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-da4b4da7"]]),xp={class:"flex items-center gap-2 w-full"},wp={class:"relative flex-1"},_p=["placeholder","disabled","onKeydown"],Cp=["disabled"],vp={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},Ep={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},Bp={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},Vp=["onClick"],Sp={key:0,class:"p-4 text-sm text-gray-500"},Qo=e.defineComponent({__name:"vs-input-address",props:e.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(o,{emit:t}){const n=/{{\s*([^}]+?)\s*}}/g,r=o,l=t,{inputClass:a}=ze(r.style),s=e.useModel(o,"modelValue"),i=e.computed({get:()=>s.value,set:L=>{s.value=L}}),c=e.ref(!1),d=e.ref([]),u=e.ref(!1),p=e.ref(null);e.watch(u,L=>{typeof document>"u"||(L?(p.value=document.body.style.overflow,document.body.style.overflow="hidden"):p.value!=null?(document.body.style.overflow=p.value,p.value=null):document.body.style.removeProperty("overflow"))}),e.onBeforeUnmount(()=>{typeof document>"u"||(p.value!=null?document.body.style.overflow=p.value:document.body.style.removeProperty("overflow"))});const h=e.computed(()=>r.placeholder??""),x=e.computed(()=>!!r.disabled),m=L=>{if(!L)return null;if(Array.isArray(L))return L;if(typeof L=="string"){const B=L.split(",").map(S=>S.trim()).filter(Boolean);return B.length!==4?null:B.map(Number)}return null},b=e.computed(()=>{const L=m(r.bbox);if(!L||L.length!==4)return null;const B=L.map(Number);return B.some(S=>Number.isNaN(S))?null:B}),g=e.computed(()=>{const L=b.value;if(!L)return"";const[B,S,$,E]=L;return`${B},${Math.max(S,E)},${$},${Math.min(S,E)}`});e.computed(()=>g.value?"1":"0");const C=e.inject("values");function k(){!x.value&&i.value.trim()&&w()}async function w(){const L=(i.value||"").trim();if(!L)return;let B=L;if(r.includes?.length&&C?.value){const $=r.includes.map(E=>C.value?.[E]).filter(Boolean);$.length&&(B=`${$.join(", ")}, ${L}`)}const S=Y(B);if(S){c.value=!0;try{const E=await(await fetch(S)).json();d.value=Array.isArray(E)?E:[],u.value=!0}catch($){console.error("Address search error:",$)}finally{c.value=!1}}}function V(){u.value=!u.value}function R(L){if(!L)return;u.value=!1;const B=parseFloat(L.lat),$={type:"Point",coordinates:[parseFloat(L.lon),B]};r.geom&&C?.value&&(C.value[r.geom]=$),l("update:geom",$)}function Y(L){if(!r.api)return"";const B={value:encodeURIComponent(L),bbox:b.value?b.value.join(","):""};return r.api.replace(n,(S,$)=>B[$.trim()]??"")}return(L,B)=>(e.openBlock(),e.createElementBlock("div",xp,[e.createElementVNode("div",wp,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":B[0]||(B[0]=S=>i.value=S),placeholder:h.value,disabled:x.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white border rounded-md placeholder:text-gray-400 focus:ring-2 focus:ring-blue-500",[e.unref(a),{"!border-red-600":r.error}]]),style:{border:"1px solid #CFD9E0"},onKeydown:e.withKeys(e.withModifiers(k,["prevent"]),["enter"])},null,42,_p),[[e.vModelText,i.value]]),d.value.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick:V,title:"Show search results"},[e.createVNode(e.unref(P.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:w,class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px]",disabled:c.value||!i.value?.trim()},[c.value?(e.openBlock(),e.createBlock(e.unref(P.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(P.Search),{key:0,class:"h-4 w-4"}))],8,Cp),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[u.value?(e.openBlock(),e.createElementBlock("div",vp,[e.createElementVNode("div",Ep,[e.createElementVNode("div",Bp,[B[2]||(B[2]=e.createElementVNode("span",null,"Результати пошуку",-1)),e.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:B[1]||(B[1]=S=>u.value=!1),title:"Close"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(S,$)=>(e.openBlock(),e.createElementBlock("li",{key:$,onClick:E=>R(S),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(S.display_name),9,Vp))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Sp," Не знайдено результатів "))])])):e.createCommentVNode("",!0)]))]))}}),$p={class:"vs-datalist space-y-3"},Np={class:"space-y-3"},Ap=["onClick","disabled"],Fp={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Mp=["disabled"],Dp=xe(e.defineComponent({__name:"vs-input-datalist",props:e.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>Array.isArray(n.value)?n.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(b=>({...b,disabled:t.disabled||b.disabled}))??[]),s=e.computed(()=>a.value.map(b=>m(b))),i=e.computed(()=>t.disabled?!1:t.maxItems?r.value.length<t.maxItems:!0),c=e.computed(()=>t.disabled||r.value.length<=(t.minItems||0));e.watch(()=>r.value.length,()=>{d(),u()},{immediate:!0}),e.watch(()=>t.schema,u,{immediate:!0,deep:!0});function d(){const b=r.value.length;l.value.length<b?l.value=[...l.value,...Array.from({length:b-l.value.length},()=>Gn())]:l.value.length>b&&l.value.splice(b)}function u(){if(!t.minItems||r.value.length>=t.minItems)return;const b=t.minItems-r.value.length,g=Array.from({length:b},p);n.value=[...r.value,...g]}function p(){const b={};return a.value.forEach(g=>{b[g.name]=g?.default??null}),b}function h(){i.value&&(n.value=[...r.value,p()],d())}function x(b){c.value||(n.value=r.value.filter((g,C)=>C!==b),d(),u())}function m(b){return{...b}}return(b,g)=>(e.openBlock(),e.createElementBlock("div",$p,[e.createElementVNode("div",Np,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(C,k)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[k],class:"flex items-center gap-3"},[e.createVNode(rt,{schema:s.value,layout:"inline",navigation:!1,values:r.value[k],"onUpdate:values":w=>r.value[k]=w,"form-id":l.value[k]},null,8,["schema","values","onUpdate:values","form-id"]),e.createElementVNode("button",{type:"button",class:"h-[38px] w-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",onClick:w=>x(k),disabled:c.value},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})],8,Ap)]))),128)),r.value.length===0?(e.openBlock(),e.createElementBlock("div",Fp,e.toDisplayString(t.emptyLabel),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:h,disabled:!i.value},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Mp)]))}}),[["__scopeId","data-v-260e3e66"]]),Tp={class:"vs-dataform space-y-4"},Lp=["draggable","onDragstart","onDragover","onDragenter","onDrop"],Ip={class:"flex items-center gap-2"},Rp=["onClick"],Op={class:"text-sm font-medium text-gray-700"},zp={class:"flex items-center gap-2"},Pp=["title","onClick","disabled"],jp=["title","onClick","disabled"],Up={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Hp=["disabled"],qp=xe(e.defineComponent({__name:"vs-input-dataform",props:e.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),i=e.ref(null),c=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),u=e.computed(()=>t.emptyLabel??"Ще немає груп"),p=e.computed(()=>t.schema?.map(te=>({...te,disabled:t.disabled||te.disabled}))??[]),h=e.computed(()=>p.value.map(te=>S(te))),x=e.computed(()=>t.view==="accordion"),m=e.computed(()=>!!(t.collapsible||x.value)),b=e.computed(()=>t.draggable!==!1),g=e.computed(()=>t.disabled?!1:t.maxGroups?n.value.length<t.maxGroups:!0),C=e.computed(()=>t.disabled||n.value.length<=(t.minGroups||0));e.watch(()=>n.value.length,()=>{k(),w(),V()},{immediate:!0}),e.watch(()=>t.schema,V,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{w()},{immediate:!0});function k(){const te=n.value.length;r.value.length<te?r.value=[...r.value,...Array.from({length:te-r.value.length},()=>Gn())]:r.value.length>te&&r.value.splice(te)}function w(){const te=n.value.length;x.value?te===0?a.value=-1:a.value>=te?a.value=te-1:a.value<0&&(a.value=0):l.value.length<te?l.value=[...l.value,...Array.from({length:te-l.value.length},()=>!1)]:l.value.length>te&&l.value.splice(te)}function V(){if(!t.minGroups||n.value.length>=t.minGroups)return;const te=t.minGroups-n.value.length,se=Array.from({length:te},R);n.value=[...n.value,...se],w()}function R(){const te={};return p.value.forEach(se=>{te[se.name]=se?.default??null}),te}function Y(){g.value&&(n.value=[...n.value,R()],k(),w())}function L(te){C.value||(n.value=n.value.filter((se,we)=>we!==te),k(),x.value?a.value>=n.value.length&&(a.value=n.value.length-1):l.value.splice(te,1),V())}function B(te){if(t.disabled)return;const se=JSON.parse(JSON.stringify(n.value[te]??{}));n.value=[...n.value.slice(0,te+1),se,...n.value.slice(te+1)],k(),x.value?a.value>te&&(a.value+=1):l.value.splice(te+1,0,l.value[te]??!1)}function S(te){return{...te}}function $(te){return x.value?a.value===-1&&te===0?!1:a.value!==te:!!l.value[te]}function E(te){if(m.value){if(x.value){a.value=te;return}l.value[te]=!l.value[te]}}function N(te,se){if(!b.value||t.disabled){se.preventDefault();return}s.value=te,i.value=te,c.value={groups:JSON.parse(JSON.stringify(n.value)),keys:[...r.value],states:[...l.value]},se.dataTransfer?.setData("text/plain",String(te)),se.dataTransfer?.setDragImage?.(se.currentTarget,0,0)}function I(te,se){!b.value||t.disabled||s.value!==null&&X(te,se)}function v(te,se){X(te,se)}function M(te){!b.value||t.disabled||ge()}function D(){c.value&&W(),s.value=null,i.value=null,c.value=null}function K(te,se){const we=[...n.value],[J]=we.splice(te,1);we.splice(se,0,J),n.value=we;const ce=[...r.value],[ye]=ce.splice(te,1);if(ce.splice(se,0,ye),r.value=ce,x.value)a.value===te&&(a.value=se);else{const Ee=[...l.value],[Ae]=Ee.splice(te,1);Ee.splice(se,0,Ae),l.value=Ee}}function W(){c.value&&(n.value=c.value.groups,r.value=c.value.keys,l.value=c.value.states,c.value=null,i.value=null)}function X(te,se){if(s.value===null)return;const we=re(te,se);i.value=we,Ce(we)}function re(te,se){if(!se?.currentTarget)return te;const we=se.currentTarget.getBoundingClientRect(),ce=se.clientY-we.top>we.height/2?te+1:te;return Math.max(0,Math.min(ce,n.value.length))}function Ce(te){const se=s.value;if(se===null)return;let we=te;if(we>n.value.length&&(we=n.value.length),we===se||we===se+1)return;const J=we>se?we-1:we;K(se,J),s.value=J,i.value=we>se?J+1:J}function ge(){c.value=null,s.value=null,i.value=null}return(te,se)=>(e.openBlock(),e.createElementBlock("div",Tp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(we,J)=>(e.openBlock(),e.createElementBlock("div",{key:r.value[J],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":$(J)?"pt-6 px-6":"p-6"]]),draggable:b.value&&!t.disabled,onDragstart:ce=>N(J,ce),onDragend:D,onDragover:e.withModifiers(ce=>I(J,ce),["prevent"]),onDragenter:e.withModifiers(ce=>v(J,ce),["prevent"]),onDrop:e.withModifiers(ce=>M(),["prevent"])},[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3",[t.view!=="accordion"?"-mx-6 -mt-6 px-6":"",t.view!=="accordion"&&!$(J)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",Ip,[b.value?(e.openBlock(),e.createBlock(e.unref(P.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:ce=>E(J)},[e.createVNode(e.unref(P.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",$(J)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,Rp)):e.createCommentVNode("",!0),e.createElementVNode("div",Op,e.toDisplayString(`${d.value} (${J+1})`),1)]),e.createElementVNode("div",zp,[e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.duplicateTitle,onClick:ce=>B(J),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(P.Copy),{class:"h-4 w-4"})],8,Pp),e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.removeTitle,onClick:ce=>L(J),disabled:C.value,draggable:"false"},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})],8,jp)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(rt,{class:"vs-dataform__form",schema:h.value,layout:"inline",navigation:!1,values:n.value[J],"onUpdate:values":ce=>n.value[J]=ce,"form-id":r.value[J],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!$(J)]])],42,Lp))),128)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",Up,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:Y,disabled:!g.value},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Hp)]))}}),[["__scopeId","data-v-cfbcfed8"]]),_n="__vs_form_monaco_loader__",Tt="__vs_form_monaco_script_loader__",Cn="__vs_form_monaco_editor_loader__",Yn=e.defineComponent({__name:"vs-input-monaco",props:e.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:t}){const n=o,r=e.useModel(o,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof n.height=="number"?`${n.height}px`:n.height||"280px");let s=null,i=null,c=!1;const d=()=>{if(i)return Promise.resolve(i);if(typeof window>"u")return Promise.resolve(null);const m=window;if(m.monaco?.editor?.create)return i=m.monaco,Promise.resolve(i);if(m[_n])return m[_n];const g=(async()=>{const C=V=>{if(Array.from(document.styleSheets||[]).some(L=>L?.href?.includes(V)))return;const Y=document.createElement("link");Y.rel="stylesheet",Y.href=V,document.head.appendChild(Y)},k=V=>{if(m[Tt]?.[V])return m[Tt][V];m[Tt]||={};const R=Array.from(document.scripts).find(Y=>Y.src===V);return R?(m[Tt][V]=new Promise((Y,L)=>{const B=R.readyState;if(R.dataset.loaded==="true"||B==="loaded"||B==="complete"){Y();return}R.addEventListener("load",()=>{R.dataset.loaded="true",Y()},{once:!0}),R.addEventListener("error",S=>L(S),{once:!0})}),m[Tt][V]):(m[Tt][V]=new Promise((Y,L)=>{const B=document.createElement("script");B.src=V,B.async=!0,B.onload=()=>{B.dataset.loaded="true",Y()},B.onerror=S=>L(S),document.body.appendChild(B)}),m[Tt][V])},w="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return C(`${w}/editor/editor.main.min.css`),await k(`${w}/loader.min.js`),m[Cn]||(m[Cn]=new Promise((V,R)=>{window.require.config({paths:{vs:w}}),window.require(["vs/editor/editor.main"],()=>{i=window.monaco,m.monaco=i,V(i)},Y=>R(Y))}).catch(V=>{throw delete m[Cn],V})),m[Cn]})().catch(C=>{throw delete m[_n],C});return m[_n]=g,g},u=()=>{!l.value||!i||(s&&(s.dispose(),s=null),s=i.editor.create(l.value,{value:r.value||"",language:n.syntax,theme:n.theme,automaticLayout:!0,minimap:{enabled:!!n.minimap},readOnly:!!n.disabled}),s.onDidChangeModelContent(()=>{c||(r.value=s.getValue())}))},p=()=>{s?.focus()},h=()=>s,x=()=>i;return e.watch(()=>r.value,m=>{if(!s)return;const b=s.getValue();m!==b&&(c=!0,s.setValue(m||""),c=!1)}),e.watch(()=>n.syntax,m=>{!s||!i||i.editor.setModelLanguage(s.getModel(),m||"xml")}),e.watch(()=>n.theme,m=>{i&&i.editor.setTheme(m||"vs-light")}),e.watch(()=>n.disabled,m=>{s&&s.updateOptions({readOnly:!!m})}),e.watch(()=>n.minimap,m=>{s&&s.updateOptions({minimap:{enabled:!!m}})}),e.onMounted(async()=>{try{const m=await d();if(!m||!m.editor)return;i=m,u()}catch(m){console.error("Failed to load Monaco editor",m)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:p,getEditor:h,getMonaco:x}),(m,b)=>(e.openBlock(),e.createElementBlock("div",{class:"w-full",style:e.normalizeStyle({height:a.value})},[e.createElementVNode("div",{ref_key:"editorContainer",ref:l,class:"w-full h-full overflow-hidden border border-[#CFD9E0] rounded"},null,512)],4))}}),er={VsInputText:Ot,VsInputRadio:Hn,VsInputInlineSelect:mn,"vs-input-text":Ot,"vs-input-password":gl,"vs-input-textarea":To,"vs-input-richtext":Lo,"vs-input-mask":cn,"vs-input-number":Co,"vs-input-radio":Hn,"vs-input-select":Wn,"vs-input-inline-select":mn,"inline-select":mn,"vs-input-switcher":zn,"vs-input-static":Pn,"vs-input-container":Fo,"vs-input-date":pa,"vs-input-checkbox":Bo,"vs-input-file":$o,"vs-input-file2":Kn,file2:Kn,File2:Kn,"vs-input-html":Pn,"vs-input-email":jn,"vs-input-tel":Un,"vs-input-datatable":Io,"vs-input-map":Ho,"vs-input-file-list":No,"vs-input-tags":qo,"vs-input-slug":Ko,"vs-input-codegen":Wo,"vs-input-key-value":Go,"vs-input-text[]":Yo,"vs-input-range":Zo,"vs-input-color":Xo,"vs-input-native-select":Wn,VsInputArraySelect:wn,"vs-input-array":Jo,"vs-input-array-select":wn,"array-select":wn,"vs-input-address":Qo,"vs-input-datalist":Dp,"vs-input-dataform":qp,"vs-input-monaco":Yn},Kp=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(o){const t=o,n=e.inject("values");async function r(){try{if(!t.api)return;const l=t.api.replace("{{value}}",t.value),a=await fetch(l);if(!a.ok){he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!n)return;for(const[i,c]of Object.entries(t.set))n.value[i]=s.result[c]}catch(l){console.error(t.error,l)}}return(l,a)=>(e.openBlock(),e.createElementBlock("button",{onClick:r,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},e.toDisplayString(l.button),1))}}),Wp={class:"flex flex-col gap-1 w-full"},Gp={class:"w-full"},Yp=["disabled"],Xp=["innerHTML"],Zp=2e3,Jp=10,tr=e.defineComponent({__name:"vs-compact-form-layout",props:e.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:e.mergeModels(["value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),l=t,a=e.computed(()=>ml[`${n.layout}`]),s=["label","placeholder","info","description","text","html"],i=e.ref(S()),c=e.computed(()=>Y(n.item,i.value)),d=e.computed(()=>er?.[`vs-input-${n.item.type}`]),u=e.inject("field-props"),p=e.computed(()=>{const E=e.unref(d);if(!E)return new Set;const N=E.props??E.__vccOpts?.props;if(!N)return new Set;const I=Array.isArray(N)?N:Object.keys(N);return new Set(I)}),x=[...["min","max","step"],"api","set","mask"],m=e.computed(()=>{const E={...c.value??{}},N=n.item?.name;N&&u?.value?.[N]&&Object.assign(E,u.value[N]);const I=p.value;let v;return I.size?v=Object.fromEntries(Object.entries(E).filter(([M])=>I.has(M))):v=E,x.forEach(M=>{const D=E[M];D!=null&&(v[M]=D)}),v}),b=E=>{const N=typeof E=="object"&&E!==null?E:{value:E};l("value-selected",{...N,name:N.name??n.item?.name})},g=/{{\s*([^}]+?)\s*}}/g,C=e.inject("values"),k=e.ref(!1),w=e.computed(()=>{const E=n.item?.api;return typeof E=="string"&&E.trim().length>0&&(n.item?.type==="text"||n.item?.type.toLowerCase()==="markedtext")});function V(E,N){if(!(E==null||!N))return N.split(".").reduce((I,v)=>I?.[v.trim()],E)}async function R(){const E=String(r.value??"").trim();if(!E)return;const N=(n.item?.api??"").trim();if(!N)return;const I=N.replace(g,(v,M)=>M.trim()==="value"?encodeURIComponent(E):"");k.value=!0;try{let v=await fetch(I),M=0;for(;v.status===202&&M<Jp;)M+=1,await new Promise(re=>{setTimeout(re,Zp)}),v=await fetch(I);if(v.status===202){he.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!v.ok){he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const D=await v.json(),K=D?.result!==void 0?D.result:D,W=n.item?.set;if(!W||!C?.value)return;const X=n.item?.name;Object.entries(W).forEach(([re,Ce])=>{if(!re)return;let ge=Ce;X&&ge.startsWith(`${X}.`)&&(ge=ge.slice(X.length+1));const te=V(K,ge);C.value[re]=te??null})}catch(v){console.error("API lookup error:",v),he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{k.value=!1}}e.onMounted(()=>{i.value=S(),window.addEventListener("storage",$)}),e.onUnmounted(()=>{window.removeEventListener("storage",$)});function Y(E,N){if(!E)return{};const I={...E};return s.forEach(v=>{const M=B(E,v,N);M!=null&&(I[v]=M)}),Array.isArray(E.options)&&(I.options=E.options.map(v=>L(v,N))),I}function L(E,N){if(!E)return E;const I={...E},v=B(E,"label",N),M=B(E,"text",N);return v!=null&&(I.label=v),M!=null?I.text=M:v!=null&&(I.text=v),I}function B(E,N,I){const v=`${N}:${I}`;if(E?.[v]!=null)return E[v];if(N==="label"&&E?.[I]!=null)return E[I];if(E?.[N]!=null)return E[N];if(N==="label"){if(E?.ua!=null)return E.ua;if(E?.en!=null)return E.en}if(N==="text"||N==="html"){if(E?.ua!=null)return E.ua;if(E?.en!=null)return E.en}return null}function S(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function $(){i.value=S()}return(E,N)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:c.value.ua,error:n.error||"",item:c.value,columns:n.columns,label:c.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${n.item.type}-component`])},[e.createElementVNode("div",Wp,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":w.value}])},[e.createElementVNode("div",Gp,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),e.mergeProps(m.value,{modelValue:r.value,"onUpdate:modelValue":N[0]||(N[0]=I=>r.value=I),onValueSelected:b}),null,16,["modelValue"]))]),w.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px] shrink-0",disabled:k.value||!r.value?.toString().trim(),onClick:R},[k.value?(e.openBlock(),e.createBlock(e.unref(P.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(P.Search),{key:0,class:"h-4 w-4"}))],8,Yp)):e.createCommentVNode("",!0)],2),c.value.description&&n.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:c.value.description},null,8,Xp)):e.createCommentVNode("",!0)]),c.value.behavior?.api&&c.value.behavior?.button?(e.openBlock(),e.createBlock(Kp,e.mergeProps({key:0},c.value.behavior,{value:r.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),Qp={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},ef={class:"vs-compact-form-navigation__rail mt-[6px]"},tf=["onClick"],nf=xe(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(o,{expose:t}){const n=o,r=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!n.enabled),i=e.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),c=e.computed(()=>{const E=n.width;if(E==null)return{};const N=typeof E=="number"?`${E}px`:`${E}`;return{width:N,minWidth:N}});let d=null,u=0,p=0,h=null,x=null,m=null;const b=()=>S(),g=()=>k();e.watch(()=>n.target,async E=>{if(Y(),!E){h=null,r.value=[],l.value="";return}h=E,s.value&&(await e.nextTick(),R(E),k())},{immediate:!0}),e.watch(()=>n.scrollContainer,E=>{if(!s.value){x=E??null;return}C(E??null),e.nextTick(()=>k())},{immediate:!0}),e.onMounted(()=>{n.scrollContainer||C(null),k()}),e.onBeforeUnmount(()=>{Y(),C(null,!0),h=null,typeof window<"u"&&(u&&window.cancelAnimationFrame(u),p&&window.cancelAnimationFrame(p))});function C(E,N=!1){if(m&&(m(),m=null),N){x=null;return}if(x=E??null,typeof window>"u")return;const I=E??window,v=window;I.addEventListener("scroll",b,{passive:!0}),v.addEventListener("resize",g),m=()=>{I.removeEventListener("scroll",b),v.removeEventListener("resize",g)}}function k(){if(!s.value||!h)return;u&&typeof window<"u"&&window.cancelAnimationFrame(u);const E=()=>{w(),u=0};typeof window>"u"?E():u=window.requestAnimationFrame(E)}function w(){if(!s.value||!h)return;const E=Array.from(h.querySelectorAll("h1, h2")),N=new Set,I=[];E.forEach((v,M)=>{const D=v.textContent?.trim()??"";if(!D)return;let K=(v.getAttribute("id")??"").trim();K||(K=V(D)||`heading-${M+1}`);let W=K,X=1;for(;N.has(W);)W=`${K}-${X+=1}`;v.id!==W&&Object.assign(v,{id:W}),N.add(W),I.push({id:W,text:D,level:v.tagName.toLowerCase()==="h1"?1:2})}),r.value=I,I.length||(l.value=""),B()}function V(E){return E.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function R(E){!E||!s.value||typeof MutationObserver>"u"||(Y(),d=new MutationObserver(()=>k()),d.observe(E,{childList:!0,subtree:!0}))}function Y(){d&&(d.disconnect(),d=null)}function L(E){const N=x;if(!N)return typeof window>"u"?E.offsetTop:E.getBoundingClientRect().top+window.scrollY;const I=E.getBoundingClientRect(),v=N.getBoundingClientRect();return I.top-v.top+N.scrollTop}function B(){if(!s.value||!r.value.length)return;const E=x,N=(E?E.scrollTop:null)||(typeof window<"u"?window.scrollY:0),I=(E?E.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),v=N+I;let M=null;for(let K=0;K<r.value.length;K+=1){const W=r.value[K],X=document.getElementById(W.id);if(X){const re=L(X);re+X.offsetHeight>N&&re<v&&(M=W.id)}}!M&&a.value&&(M=a.value),M&&(a.value=M);const D=E?E.scrollHeight-E.clientHeight:document.documentElement.scrollHeight-window.innerHeight;N+5>=D&&(M=r.value[r.value.length-1].id),M&&(l.value=M)}function S(){s.value&&(p&&window.cancelAnimationFrame(p),p=window.requestAnimationFrame(()=>{B(),p=0}))}function $(E){if(!s.value)return;const N=document.getElementById(E);if(!N)return;const I=x,v=Math.max(0,L(N));I?I.scrollTo({top:v,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:v,behavior:"smooth"})}return t({refresh:k}),(E,N)=>s.value&&r.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(i.value),style:e.normalizeStyle(c.value)},[e.createElementVNode("h2",Qp,e.toDisplayString(E.title),1),e.createElementVNode("div",ef,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,I=>(e.openBlock(),e.createElementBlock("div",{key:I.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",I.level===2?"vs-compact-form-navigation__item--nested":"",I.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:v=>$(I.id),class:e.normalizeClass(["vs-compact-form-navigation__button flex gap-x-3 py-[6px] pr-3 text-sm duration-200 hover:text-gray-800",I.level===2?"pl-[15px]":"pl-[18px]",I.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(I.text),1)],10,tf)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),pt={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:o=>`Мінімальна довжина — ${o} символів`,maxlength:o=>`Максимальна довжина — ${o} символів`,min:o=>`Значення має бути не менше ${o}`,max:o=>`Значення має бути не більше ${o}`},of=o=>typeof o=="string"?o.trim()?!1:pt.required:Array.isArray(o)?o.map(n=>typeof n=="string"?n.trim():n).filter(n=>n!=null&&n!=="").length?!1:pt.required:typeof o=="number"?Number?.isNaN(o)?pt?.required:!1:o?!1:pt.required,rf=o=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return o?t.test(o)?!1:pt.email:!1},lf=o=>{const t=/^\+[1-9]\d{1,14}$/;return o?t.test(o)?!1:pt.tel:!1},nr=o=>o==null?0:typeof o=="string"?o.trim().length:Array.isArray(o)?o.length:typeof o=="number"?o.toString().length:String(o).length,af=(o,t)=>{if(o==null)return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&nr(o)<n?t?.message||pt.minlength(n):!1},sf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&nr(o)>n?t?.message||pt.maxlength(n):!1},or=o=>{if(typeof o=="number")return o;if(typeof o=="string"){const t=o.trim().replace(",",".");return t?Number(t):Number.NaN}return Number(o)},cf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=or(o);return Number.isFinite(r)&&r<n?t?.message||pt.min(n):!1},df=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=or(o);return Number.isFinite(r)&&r>n?t?.message||pt.max(n):!1},uf=(o,t)=>{const n=t.pattern??t.regexp,r=typeof n=="string"?new RegExp(n):n;if(Array.isArray(o)){const l=o.filter(Boolean);return l.length===0||l.every(a=>r.test(a))?!1:t.message}return!r.test(o)&&o?t.message:!1},pf=(o,t)=>!1,ff=(o,t)=>{switch(typeof t=="string"?t:t.type){case"required":return of(o);case"email":return rf(o);case"tel":return lf(o);case"regexp":return uf(o,t);case"minlength":return af(o,t);case"maxlength":return sf(o,t);case"min":return cf(o,t);case"max":return df(o,t);case"custom":return pf();default:return!1}},mf={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file",inlineselect:"inline-select"};function rr(o){const t=o?.toLowerCase();return mf[t]||t}function Xn(o,t=!1){if(Array.isArray(o)){const r=[];return o.forEach(l=>{const a={...l};a.name=(l.name||l.id||l.key||"").toString(),a.type=rr(l.type),a.label=l.label||l.ua,a.rules=l.rules||l.validators,a.type==="email"&&!a.rules&&(a.rules=["email"]),l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=Xn(a.schema,a.disabled)),r.push(a)}),r}const n=[];return Object.entries(o).forEach(r=>{const l={name:r[0],...r[1],type:rr(r[1].type),label:r[1].label||r[1].ua,rules:r[1].rules||r[1].validators,disabled:r[1].disabled??t};l.type==="email"&&!l.rules&&(l.rules=["email"]),r[1].type?.includes("list")&&(l.multiple=!0),!l.api&&r[1].data&&(l.api=`/api/suggest/${r[1].data}`),Array.isArray(l.schema)&&(l.schema=Xn(l.schema,l.disabled)),n.push(l)}),n}function hf(o,t,n=!1){const r=e.computed(()=>Xn((Array.isArray(t),t),typeof n=="boolean"?n:n.value)),l=e.ref({});function a(d){const u=d?.conditions;if(!u)return!0;const p=Array.isArray(u)?u[0]:u,h=o?.value?.[p];return Ao(h,u)}const s=(d=r.value,u=!0)=>(d.forEach(p=>{const h=[],x=Number(p?.minlength),m=Number(p?.maxlength),b=Number(p?.min),g=Number(p?.max);!Number.isNaN(x)&&Number.isFinite(x)&&h.push({type:"minlength",value:x}),!Number.isNaN(m)&&Number.isFinite(m)&&h.push({type:"maxlength",value:m}),!Number.isNaN(b)&&Number.isFinite(b)&&h.push({type:"min",value:b}),!Number.isNaN(g)&&Number.isFinite(g)&&h.push({type:"max",value:g});const C=[...h,...p.rules||[]];if(C.length){if(!a(p)){delete l.value[p.name];return}let k=!1,w=null;C.forEach(V=>{const R=ff(o.value[p.name],V);R&&(k=!0,!w&&typeof R=="string"&&(w=R))}),k&&w?l.value[p.name]=w:delete l.value[p.name]}p.schema&&s(p.schema,!1)}),u&&Object.values(l.value).some(Boolean)?l.value:null),i=e.computed(()=>r.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{o.value={},l.value={}},visibleSchema:i}}const gf={class:"flex w-full h-full min-h-0 gap-6"},yf={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},rt=e.defineComponent({__name:"vs-compact-form",props:e.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:e.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(o,{expose:t,emit:n}){const r=n,l=o,a=e.useModel(o,"form"),s=e.useModel(o,"modelValue"),i=e.useModel(o,"values"),c=e.computed({get:()=>i.value??s.value,set:v=>{s.value=v,i.value=v}}),{errors:d,validate:u,reset:p,visibleSchema:h}=hf(c,l.schema,e.toRef(l,"disabled")),x=e.ref(null),m=e.ref(null),b=e.ref({}),g=e.computed(()=>l.navigation),C=e.computed(()=>l.navWidth),k=e.computed(()=>l.style?.columns),w=Object.freeze({container:12,label:3}),V=e.computed(()=>l.columns??k.value??w),R=e.computed(()=>l.columns!=null||k.value!=null),Y=e.computed(()=>R.value?"horizontal":l.layout),L=v=>v?.columns?"horizontal":Y.value,B=v=>v?.columns??V.value,S=()=>{!l.formId&&c.value&&delete c.value.id,r("update:modelValue",c.value),u(),r("handle-submit",c.value)},$=v=>{r("value-selected",v)};t({validate:u,reset:p,errors:d}),e.onMounted(()=>{a.value={value:c.value,errors:d.value,reset:p,validate:u,formId:l.formId}});function E(v,M){if(v===M)return!0;if(typeof v!="object"||typeof M!="object"||!v||!M)return!1;const D=Object.keys(v),K=Object.keys(M);return D.length!==K.length?!1:D.every(W=>v[W]===M[W])}function N(v){return Array.isArray(v)?[...v]:v&&typeof v=="object"?{...v}:v}function I(v){Array.isArray(v)&&v.forEach(M=>{if(!M)return;const D=M.name,K=M.default!==void 0;D&&K&&c.value[D]===void 0&&(c.value[D]=N(M.default)),Array.isArray(M.schema)&&I(M.schema)})}return e.watch(h,v=>{I(v)},{immediate:!0,deep:!0}),e.provide("form",a),e.provide("values",c),e.provide("field-props",b),(v,M)=>(e.openBlock(),e.createElementBlock("div",gf,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:m},[e.createElementVNode("form",{ref_key:"formRef",ref:x,onSubmit:e.withModifiers(S,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",Y.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(h),(D,K)=>(e.openBlock(),e.createElementBlock("div",{key:D.name,class:e.normalizeClass(L(D)==="horizontal"?"col-span-12":`col-span-${D.col||12}`)},[e.createVNode(tr,{style:e.normalizeStyle(v.style),item:D,layout:L(D),columns:B(D),"model-value":c.value[D.name],"onUpdate:modelValue":W=>{if(D.name==="id"&&!v.formId)return;const X=c.value[D.name];E(X,W)||(c.value[D.name]=W)},error:e.unref(d)[D.name],onValueSelected:$},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),L(D)==="settings"&&K+1!==e.unref(h).length?(e.openBlock(),e.createElementBlock("div",yf)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode(nf,{target:x.value,"scroll-container":m.value,enabled:g.value,width:C.value},null,8,["target","scroll-container","enabled","width"])]))}}),bf={class:"relative"},kf={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},xf={class:"m-[10px] fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 min-h-0 h-fit max-h-[80vh] overflow-hidden opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl lg:w-7/12 w-11/12"},wf={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},_f={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Cf={class:"p-4 mim-h-0 h-full overflow-auto"},lr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(o,{emit:t}){const n=o,r=t,l=e.ref(n.schema),a=e.ref(n.defaultValue?JSON.parse(JSON.stringify(n.defaultValue)):{}),s=e.ref({}),i=e.ref(n.token||""),c=e.ref(n.token||""),d=e.ref(n.mode),u=()=>{const g=n.method?.trim().toUpperCase();return g==="GET"||g==="POST"||g==="PUT"?g:d.value==="add"?"POST":"PUT"},p=()=>{he.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},h=g=>{const C={};g.id!==void 0&&g.id!==null&&(C.id=g.id,c.value=g.id.toString()),g.obj&&typeof g.obj=="object"&&Object.assign(C,g.obj),Object.keys(C).length&&(a.value={...a.value,...C})},x=async g=>{if(console.log(g),g.ok){await g.json().catch(()=>({})),p(),r("save",a.value);return}const C=await g.json().catch(()=>({})),k=C.message||C.error;if(g.status===400){he.notify({type:"warning",title:"Помилка валідації",message:k||"Некоректні дані (400)"});return}if(g.status===500){he.notify({type:"error",title:"Серверна помилка",message:k||"Виникла помилка на сервері (500)"});return}he.notify({type:"error",title:"Помилка",message:`Статус: ${g.status}`})};async function m(){const g=s.value.validate();if(g){he.notify({type:"warning",title:"Помилка валідації",message:Object.entries(g).map(([k,w])=>`${k}: ${w}`).join(`
4
+ 50.4494, 30.5260`},format:{type:"Radio",label:"Формат координат",options:[{id:"decimal",text:"Десяткові (Decimal)"},{id:"dms",text:"Градуси-хвилини-секунди (DMS)"}]},order:{type:"Radio",label:"Порядок координат",options:[{id:"lat-lon",text:"lat, lon"},{id:"lon-lat",text:"lon, lat"}]}};let se=!1,we=!1;const J=e.reactive({}),ce=e.ref([]),ye=e.computed(()=>ce.value.map(f=>J[f]).filter(Boolean)),Ee=e.ref(null),Ae=e.computed(()=>Ee.value?.entries??[]),Re=e.computed(()=>{if(Ee.value)return{left:`${Ee.value.point.x+12}px`,top:`${Ee.value.point.y+12}px`}}),Fe=e.computed(()=>{if(Array.isArray(n.tools)&&n.tools.length)return n.tools;const f=l?.tools;return Array.isArray(f)?f.map(y=>String(y)):typeof f=="string"?f.split(",").map(y=>y.trim()).filter(Boolean):[]}),Be=e.computed(()=>{const f={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Fe.value.length)return{...f,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const y=new Set(Fe.value.map(_=>_.toLowerCase()));return{search:y.has("search"),import:y.has("import"),export:y.has("export"),point:y.has("point"),line:y.has("line"),polygon:y.has("polygon"),rectangle:y.has("rectangle"),ruler:y.has("ruler")}});function j(f){if(typeof f!="string"||!f.trim())return"";if(/^https?:\/\//i.test(f))return f;const y=window?.location?.origin??"",_=f.replace(/^\/+/,"");return _?y?`${y}/${_}`:`/${_}`:y}function Z(){const f=Array.isArray(w.basemaps)&&w.basemaps.length?w.basemaps:k.basemaps;if(Array.isArray(f)&&f.length){const _=f.map((A,T)=>{const G=String(A?.key??A?.id??A?.name??`b${T}`),le=j(String(A?.url??""));if(!le)return null;const pe=typeof A?.preview=="string"&&A.preview?j(A.preview):"";return[G,{...A,url:le,preview:pe}]}).filter(A=>Array.isArray(A)&&A.length===2).reduce((A,[T,G])=>(A[T]=G,A),{});if(Object.keys(_).length)return _}return{voyager:{name:"Оглядова карта",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/voyager/ua/13/4790/2762.png"},orto10:{name:"Ортофото 1:10K",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",preview:"https://data.gki.com.ua/api-user/rtile/orto10/ua/13/4790/2762.png"},osmb:{name:"Open Street Maps",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",preview:"https://tile.openstreetmap.org.ua/styles/osm-bright/13/4790/2762.png"}}}const ne=Z(),de=Object.keys(ne),me=e.ref(de.length?de[0]:"");async function $e(){if(typeof window>"u")return null;const f=window;if(f[bn])return f[bn];const y=G=>{if(Array.from(document.styleSheets).some(Le=>Le?.href?.includes(G)))return;const pe=document.createElement("link");pe.rel="stylesheet",pe.href=G,document.head.appendChild(pe)},_=async()=>{const G=new Function("u","return import(u)"),le=await G("https://esm.sh/maplibre-gl@3.6.2"),pe=le?.default??le;if(!pe)throw new Error("maplibre esm fallback failed");window.maplibregl=pe,window.mapboxgl=pe;const Le=await G("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),nt=Le?.default??Le;if(!nt)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=nt},T=(async()=>{y("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),y("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await _();const G=window.maplibregl,le=window.MapboxDraw;if(!G)throw new Error("maplibregl not available after load");if(!le)throw new Error("MapboxDraw not available after load");return{maplibregl:G,MapboxDraw:le}})().catch(G=>{throw delete f[bn],G});return f[bn]=T,T}function Se(f){return{version:8,sources:{rasterSource:{type:"raster",tiles:[f],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let Ne=null,Qe=null,Q=null,ae=null,Me=[],z=null,q=null,U=null,F=!1,H=!1,ee=!1,ie=null;function ve(){return{onSetup(){const f=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(f),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:f,startPoint:null,hasCoordinates:!1}},onMouseMove(f,y){if(!f.startPoint)return;const[_,A]=f.startPoint,T=y.lngLat.lng,G=y.lngLat.lat;f.rectangle.setCoordinates([[[_,A],[T,A],[T,G],[_,G],[_,A]]])},onClick(f,y){if(!f.startPoint){f.startPoint=[y.lngLat.lng,y.lngLat.lat],f.hasCoordinates=!0,f.rectangle.setCoordinates([[[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat],[y.lngLat.lng,y.lngLat.lat]]]);return}const[_,A]=f.startPoint,T=y.lngLat.lng,G=y.lngLat.lat;return Math.abs(_-T)>0&&Math.abs(A-G)>0?(f.rectangle.setCoordinates([[[_,A],[T,A],[T,G],[_,G],[_,A]]]),this.map.fire("draw.create",{features:[f.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[f.rectangle.id]})):(this.deleteFeature([f.rectangle.id],{silent:!0}),f.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(f){this.deleteFeature([f.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(f,y,_){const A=y.properties.id===f.rectangle.id;A&&!f.hasCoordinates||(y.properties.active=A?"true":"false",_(y))}}}const et=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","$type","Polygon"],["!=","active","true"]],paint:{"fill-color":"#3b82f6","fill-outline-color":"#3b82f6","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","$type","Polygon"],["==","active","true"]],paint:{"fill-color":"#2563eb","fill-outline-color":"#2563eb","fill-opacity":.2}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","$type","Polygon"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","$type","Polygon"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-lines-inactive",type:"line",filter:["all",["==","$type","LineString"],["!=","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3b82f6","line-width":2}},{id:"gl-draw-lines-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#2563eb","line-width":2}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["!=","active","true"]],paint:{"circle-radius":5,"circle-color":"#3b82f6"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":6,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-and-line-vertex-halo-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-active",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#2563eb"}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","meta","midpoint"],["==","$type","Point"]],paint:{"circle-radius":4,"circle-color":"#1d4ed8"}}];function qe(){const f=me.value;return!f||!ne[f]?.url?"":ne[f].url}function gt(f,y){return f?.id?String(f.id):f?.url?`${f.url}-${y}`:`layer-${y}`}function He(f){const y=String(f?.url??"").trim();if(!y)return"";if(/^https?:\/\//i.test(y))return y;const _=window.location?.origin??"",A=y.replace(/^\/+/,"");return`${_}/${A}`}function Ke(f){f&&Ee.value?.layerId!==f||(Ee.value=null)}function yt(f,y={}){return f.popup===!1?[]:Array.isArray(f.popup)?f.popup.length?f.popup.map(_=>{const A=_?.field||_?.name;if(!A)return null;const T=y[A];return T==null||T===""?null:{key:_.label||A,value:String(T)}}).filter(Boolean):[]:Object.entries(y).slice(0,5).map(([_,A])=>({key:_,value:A==null?"—":String(A)}))}function lt(f){if(!Array.isArray(f))return[];const y=A=>Array.isArray(A)&&A.length>=2&&Number.isFinite(Number(A[0]))&&Number.isFinite(Number(A[1])),_=A=>{if(!A.length)return A;const T=A[0],G=A[A.length-1];return!G||T[0]!==G[0]||T[1]!==G[1]?[...A,T]:A};if(f.length&&y(f[0])){const A=f.map(T=>[Number(T[0]),Number(T[1])]).filter(y);return A.length?[_(A)]:[]}return f.length&&Array.isArray(f[0])&&y(f[0][0])?f.map(T=>Array.isArray(T)?T.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(T=>T.length).map(_):f.length&&Array.isArray(f[0])&&Array.isArray(f[0][0])&&y(f[0][0][0])?f.flatMap(T=>Array.isArray(T)?T:[]).map(T=>Array.isArray(T)?T.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(T=>T.length).map(_):[]}function It(f){const y=f.style??{},_=y.color??"#3b82f6";if(!y.colorAttr||!y.colorSet)return _;const A=Object.keys(y.colorSet);if(!A.length)return _;const T=["match",["to-string",["get",y.colorAttr]]];return A.forEach(G=>{T.push(String(G),y.colorSet?.[G]??_)}),T.push(_),T}function Nt(f){if(!Q)return;f.handlers.forEach(_=>{try{Q.off(_.type,_.layerId,_.handler)}catch{}}),f.handlers=[],[...f.layerIds,...f.boundsIds].forEach(_=>{Q.getLayer(_)&&Q.removeLayer(_)}),Q.getSource(f.sourceId)&&Q.removeSource(f.sourceId);const y=`vs-ov-bounds-src-${f.id}`;Q.getSource(y)&&Q.removeSource(y),Ke(f.id)}function ho(f,y){if(!Q)return[];const _=`vs-ov-bounds-src-${y}`,A=`vs-ov-bounds-line-${y}`,T=f.bounds??N.value??W.value,G=lt(T);if(!G.length)return[];const le={type:"FeatureCollection",features:G.map(pe=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:pe}}))};return Q.getSource(_)&&Q.removeSource(_),Q.addSource(_,{type:"geojson",data:le}),Q.addLayer({id:A,type:"line",source:_,paint:{"line-color":f.style?.stroke??f.style?.color??"#2563eb","line-width":f.style?.width??2,"line-opacity":f.style?.opacity??.8,"line-dasharray":[2,2]}}),[A]}function At(f){if(!Q)return;Nt(f);const y=f.config,_=He(y);if(!_)return;const A=[],T=[];if(/\.v(?:m)?t(?:\?|$)/i.test(_)||/\.pbf(?:\?|$)/i.test(_)){const pe=y.sourceLayer||y.layer||y.service_layer||y.dataset?.layer||y.id;Q.addSource(f.sourceId,{type:"vector",tiles:[_]});const Le=String(y.style?.type??"polygon").toLowerCase(),nt=It(y),ut=y.style?.opacity??.5;if(Le==="point"){const xt=`vs-ov-point-${f.id}`;Q.addLayer({id:xt,type:"circle",source:f.sourceId,"source-layer":pe,paint:{"circle-color":nt,"circle-radius":5,"circle-opacity":ut}}),A.push(xt)}else if(Le==="polyline"||Le==="line"){const xt=`vs-ov-line-${f.id}`;Q.addLayer({id:xt,type:"line",source:f.sourceId,"source-layer":pe,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":nt,"line-width":y.style?.width??2,"line-opacity":ut}}),A.push(xt)}else{const xt=`vs-ov-fill-${f.id}`,an=`vs-ov-border-${f.id}`;Q.addLayer({id:xt,type:"fill",source:f.sourceId,"source-layer":pe,paint:{"fill-color":nt,"fill-opacity":ut}}),Q.addLayer({id:an,type:"line",source:f.sourceId,"source-layer":pe,paint:{"line-color":y.style?.stroke??y.style?.color??"#2563eb","line-width":y.style?.width??1,"line-opacity":ut}}),A.push(xt,an)}}else{Q.addSource(f.sourceId,{type:"raster",tiles:[_],tileSize:256});const pe=`vs-ov-raster-${f.id}`;Q.addLayer({id:pe,type:"raster",source:f.sourceId,paint:{"raster-opacity":y.style?.opacity??1}}),A.push(pe)}A.forEach(pe=>{const Le=ut=>{if(!ut?.features?.length){Ke(f.id);return}const xt=ut.features[0]?.properties??{},an=yt(f.config,xt);if(!an.length){Ke(f.id);return}Ee.value={layerId:f.id,entries:an,point:{x:ut.point.x,y:ut.point.y}}},nt=()=>Ke(f.id);Q.on("mousemove",pe,Le),Q.on("mouseleave",pe,nt),T.push({layerId:pe,type:"mousemove",handler:Le},{layerId:pe,type:"mouseleave",handler:nt})}),f.layerIds=A,f.boundsIds=ho(f.config,f.id),f.handlers=T;const le=f.visible?"visible":"none";[...f.layerIds,...f.boundsIds].forEach(pe=>{Q.getLayer(pe)&&Q.setLayoutProperty(pe,"visibility",le)})}function Rt(){if(!Q)return;const y={type:"FeatureCollection",features:lt(N.value??W.value).map(_=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:_}}))};Q.getSource(kn)?Q.getSource(kn).setData(y):Q.addSource(kn,{type:"geojson",data:y}),Q.getLayer(xn)||Q.addLayer({id:xn,type:"line",source:kn,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function go(f){if(!Q||s.value)return;const y=J[f];if(!y)return;y.visible=!y.visible;const _=y.visible?"visible":"none";[...y.layerIds,...y.boundsIds].forEach(A=>{Q.getLayer(A)&&Q.setLayoutProperty(A,"visibility",_)}),bt(),y.visible||Ke(f)}function bt(){if(!Q)return;const f=[],y=[],_=[],A=[];ce.value.forEach(le=>{const pe=J[le];if(!pe)return;const Le=String(pe.config?.url??""),nt=/\.v(?:m)?t(?:\?|$)/i.test(Le),ut=/\.png(?:\?|$)/i.test(Le);nt?_.push(...pe.layerIds):ut?f.push(...pe.layerIds):y.push(...pe.layerIds),A.push(...pe.boundsIds)}),[...f,...y,..._,...A].forEach(le=>{Q.getLayer(le)&&Q.moveLayer(le)}),Q.getLayer(xn)&&Q.moveLayer(xn),(Q.getStyle?.()?.layers??[]).map(le=>String(le?.id??"")).filter(le=>le.startsWith("gl-draw-")).forEach(le=>{Q.getLayer(le)&&Q.moveLayer(le)})}function yo(f){if(!ne[f]||(me.value=f,!Q))return;const y=qe();if(!y)return;const _=Q.getCenter?.(),A=Q.getZoom?.(),T=ae?.getAll?.();Q.setStyle(Se(y)),Q.once("style.load",()=>{if(Q&&(_&&Number.isFinite(A)&&Q.jumpTo({center:[_.lng,_.lat],zoom:A}),Rt(),ce.value.forEach(G=>{const le=J[G];le&&At(le)}),bt(),T?.features?.length&&ae))try{T.features.forEach(G=>ae.add(G)),d.value=T.features.length}catch{d.value=0}})}function on(f){return{type:"Feature",properties:{},geometry:f}}function tt(f){if(!f)return null;try{return JSON.parse(JSON.stringify(f))}catch{return null}}function O(f){if(!f)return null;const y=tt(f.geometry);return y?{...f.id!==void 0?{id:f.id}:{},type:"Feature",properties:{...f.properties??{}},geometry:y}:null}function oe(f){if(!f)return[];const y=(T,G)=>{if(!T?.type)return[];const le={...G??{}};return T.type==="MultiPoint"&&Array.isArray(T.coordinates)?T.coordinates.map(pe=>on({type:"Point",coordinates:pe})).map(pe=>({...pe,properties:le})):T.type==="MultiLineString"&&Array.isArray(T.coordinates)?T.coordinates.map(pe=>on({type:"LineString",coordinates:pe})).map(pe=>({...pe,properties:le})):T.type==="MultiPolygon"&&Array.isArray(T.coordinates)?T.coordinates.map(pe=>on({type:"Polygon",coordinates:pe})).map(pe=>({...pe,properties:le})):T.type==="GeometryCollection"&&Array.isArray(T.geometries)?T.geometries.flatMap(pe=>y(pe,le)):[{type:"Feature",properties:le,geometry:tt(T)}]},_=T=>{if(!T)return null;if(T.type==="Feature"){const G=O(T);return G?y(G.geometry,G.properties):null}return T.geom?.type&&Array.isArray(T.geom.coordinates)?y({type:T.geom.type,coordinates:T.geom.coordinates},T.properties??{}):T.type==="GeometryCollection"&&Array.isArray(T.geometries)?y(T,T.properties??{}):typeof T.type=="string"&&Array.isArray(T.coordinates)?y(tt(T),T.properties??{}):null};if(f.type==="FeatureCollection")return(f.features??[]).flatMap(_).filter(Boolean);if(Array.isArray(f))return f.flatMap(T=>T?.type==="FeatureCollection"?oe(T):[_(T)]).flat().filter(Boolean);const A=_(f);return A?Array.isArray(A)?A:[A]:[]}function ue(f){if(!f.length)return null;if(!a.value)return tt(f[0]?.geometry??null);const y=f.map(G=>tt(G?.geometry)).filter(Boolean);return y.every(G=>G?.type==="Point")?{type:"MultiPoint",coordinates:y.map(G=>G.coordinates)}:y.every(G=>G?.type==="LineString")?{type:"MultiLineString",coordinates:y.map(G=>G.coordinates)}:y.every(G=>G?.type==="Polygon")?{type:"MultiPolygon",coordinates:y.map(G=>G.coordinates)}:{type:"GeometryCollection",geometries:y}}function Ve(f){if(!f)return"__null__";try{return JSON.stringify(f)}catch{return"__invalid__"}}function Te(f,y){if(!Array.isArray(f)||!Array.isArray(y)||f.length<2||y.length<2)return!1;const _=1e-12;return Math.abs(Number(f[0])-Number(y[0]))<_&&Math.abs(Number(f[1])-Number(y[1]))<_}function Oe(f,y){if(!Array.isArray(f)||f.length<4)return null;const A=Te(f[0],f[f.length-1])?f.slice(0,-1):f.slice();return!Number.isInteger(y)||y<0||y>=A.length||A.length<=3||(A.splice(y,1),A.length<3)?null:[...A,[...A[0]]]}function De(f,y){if(!Array.isArray(f)||f.length<2||!Number.isInteger(y)||y<0||y>=f.length||f.length<=2)return null;const _=f.slice();return _.splice(y,1),_.length<2?null:_}function at(f,y){const _=tt(f);if(!_||!Array.isArray(y))return null;if(_.type==="LineString"){const[A]=y,T=De(_.coordinates,A);return T?(_.coordinates=T,_):null}if(_.type==="MultiLineString"){const[A,T]=y,G=_.coordinates?.[A],le=De(G,T);return le?(_.coordinates[A]=le,_):null}if(_.type==="Polygon"){const[A,T]=y,G=_.coordinates?.[A],le=Oe(G,T);return le?(_.coordinates[A]=le,_):null}if(_.type==="MultiPolygon"){const[A,T,G]=y,le=_.coordinates?.[A]?.[T],pe=Oe(le,G);return pe?(_.coordinates[A][T]=pe,_):null}return null}function kt(f){return f?f.split(".").map(y=>Number(y)).filter(y=>Number.isInteger(y)&&y>=0):[]}function st(f){return!ae||!f?null:typeof ae.get=="function"?ae.get(f)??null:ae.getAll?.()?.features?.find(_=>String(_?.id??"")===f)??null}function dt(f){const y=f?.properties?.id??f?.id;return y==null||y===""?null:String(y)}function it(f){if(!Q||!f)return null;const y=[[f.x-8,f.y-8],[f.x+8,f.y+8]],A=Q.queryRenderedFeatures(y).find(T=>{const G=String(T?.properties?.meta??"");return G&&G!=="feature"?!1:!!dt(T)});return dt(A)}function rn(f,y){if(!ae||!f||!y.length)return;const _=st(f);if(!_?.geometry)return;const A=at(_.geometry,y);if(!A)return;const T={..._,id:_.id??f,geometry:A};we=!0,se=!0;try{ae.delete(f),ae.add(T)}finally{se=!1,we=!1}Ft(),vt()}function p0(f){if(!Q||!ae||s.value||b.isRulerActive.value||u.value!=="edit")return;const y=f?.point;if(!y)return;const _=[[y.x-8,y.y-8],[y.x+8,y.y+8]],T=Q.queryRenderedFeatures(_).find(le=>le?.properties?.meta==="vertex"&&le?.properties?.parent&&le?.properties?.coord_path);if(!T)return;f?.originalEvent?.preventDefault?.(),f?.originalEvent?.stopPropagation?.();const G=kt(String(T.properties.coord_path));G.length&&rn(String(T.properties.parent),G)}function f0(f){const y=Kr(f);if(!y)return null;const[[_,A],[T,G]]=y;return{lat:(A+G)/2,lng:(_+T)/2}}function Ur(f){if(!Array.isArray(f)||f.length<3)return 0;const y=(A,T)=>{const G=A*2003750834e-2/180,le=Math.log(Math.tan((90+T)*Math.PI/360))/(Math.PI/180);return[G,le*2003750834e-2/180]};let _=0;for(let A=0;A<f.length-1;A+=1){const[T,G]=y(Number(f[A][0]),Number(f[A][1])),[le,pe]=y(Number(f[A+1][0]),Number(f[A+1][1]));_+=T*pe-le*G}return Math.abs(_/2)/1e6}function m0(f){if(!f?.type||!f?.coordinates)return null;if(f.type==="Polygon"){const y=f.coordinates?.[0];return Array.isArray(y)?Ur(y):null}return f.type==="MultiPolygon"?f.coordinates.reduce((y,_)=>{const A=_?.[0];return Array.isArray(A)?y+Ur(A):y},0):null}function bo(f){if(!f){p.value=null;return}const y=f0(f);if(!y){p.value=null;return}p.value={type:String(f.type??"Feature"),center:y,areaKm2:m0(f)}}function ko(f){if(!f){const A=Me[Me.length-1],T=tt(A?.geometry??null);z=T,bo(T);return}const y=Me.find(A=>String(A?.id??"")===String(f))??null,_=tt(y?.geometry??null);z=_,bo(_)}function xo(f){h.value=(f??[]).map((y,_)=>{const A=String(y?.id??`feature-${_+1}`),T=Hr(String(y?.geometry?.type??"Feature"));return{id:A,label:`${T} ${_+1}`}})}function Hr(f){switch(String(f)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(f||"Невідомо")}}function qr(f,y){if(!Array.isArray(f)||!Array.isArray(y)||f.length!==2||y.length!==2)return!1;const _=1e-9;return Math.abs(Number(f[0])-Number(y[0]))<_&&Math.abs(Number(f[1])-Number(y[1]))<_}function Kr(f){if(!f)return null;let y=1/0,_=1/0,A=-1/0,T=-1/0;const G=le=>{if(Array.isArray(le)){if(le.length>=2&&Number.isFinite(le[0])&&Number.isFinite(le[1])){const pe=Number(le[0]),Le=Number(le[1]);y=Math.min(y,pe),_=Math.min(_,Le),A=Math.max(A,pe),T=Math.max(T,Le);return}le.forEach(G)}};return G(f.coordinates),!Number.isFinite(y)||!Number.isFinite(_)?null:[[y,_],[A,T]]}function Wr(f){if(!Q||!f)return;const y=Kr(f);if(!y)return;const[[_,A],[T,G]]=y;if(_===T&&A===G){Q.easeTo({center:[_,A],zoom:Math.max(v.value,14)});return}Q.fitBounds(y,{padding:30,duration:250,maxZoom:18})}function wo(){if(!ae){d.value=0;return}const f=ae.getAll();d.value=f?.features?.length??0}function ln(){if(!ae)return null;const y=ae.getAll?.()?.features??[],_=G=>!!G&&y.some(le=>String(le?.id??"")===String(G??"")),A=ae.getSelectedIds?.();if(Array.isArray(A)&&A.length>0){const G=A[0];return G!=null?String(G):null}if(_(U))return String(U);if(!y.length)return null;const T=a.value?y[y.length-1]:y[0];return T?.id!==void 0&&T?.id!==null?String(T.id):null}function Ft(){if(!ae)return;const f=ae.getAll();if(d.value=f?.features?.length??0,!f?.features?.length){Me=[],h.value=[],z=null,U=null,p.value=null,se||(q="__null__",r("update:modelValue",null));return}const y=(f.features??[]).map(O).filter(Boolean);if(Me=y,xo(y),U=ln(),ko(U),!se){const _=ue(y);q=Ve(_),r("update:modelValue",_)}}function Ln(){if(!ae)return;(ae.getAll()?.features||[]).forEach(y=>ae.delete(y.id)),h.value=[],wo()}function In(f){if(!ae)return;const y=oe(f),_=a.value?y:y.slice(0,1);se=!0,Ln(),_.forEach(G=>{try{ae.add(G)}catch{}}),se=!1,Me=(ae.getAll?.()?.features??_).map(O).filter(Boolean),xo(Me),U=null;const T=tt(Me[Me.length-1]?.geometry??null);z=tt(T),wo(),bo(T),T&&(Wr(T),s.value||vt())}function h0(){ae&&(se=!0,Ln(),Me.forEach(f=>{try{ae.add(f)}catch{}}),se=!1,xo(Me),wo(),ko(U))}function jt(){if(ae){try{ae.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""}}function Rn(f){if(s.value||!ae)return;b.isRulerActive.value&&b.closeRuler(),ee=!0,jt(),u.value=f;const y=f==="marker"?"draw_point":f==="polyline"?"draw_line_string":f==="rectangle"?"draw_rectangle":"draw_polygon";a.value||(se=!0,Ln(),se=!1);try{ae.changeMode(y)}catch{u.value=""}finally{requestAnimationFrame(()=>{ee=!1})}}function vt(f){if(s.value||!ae||!ae.getAll()?.features?.length)return;const _=f||ln();if(_)try{ae.changeMode("direct_select",{featureId:_}),U=_,ko(U),u.value="edit"}catch{u.value=""}}function g0(f){s.value||!ae||!f||vt(f)}function y0(){if(!(s.value||!ae)){if(a.value){const f=ln();if(f)try{F=!0,ae.delete(f),F=!1,Ft();const y=ln();y?vt(y):jt();return}catch{F=!1}}jt(),Ln(),Me=[],h.value=[],U=null,q="__null__",p.value=null,r("update:modelValue",null)}}function b0(){s.value||!z||Wr(z)}function k0(f){if(!Q||!Ne)return;const y=[f[1],f[0]];ie||(ie=new Ne.Marker({color:"#2563eb"})),ie.setLngLat(y).addTo(Q),Q.easeTo({center:y,zoom:13,duration:250})}function x0(){s.value||D.value?.click()}function w0(){s.value||(X.value=!X.value)}function Gr(f){if(!X.value)return;const y=K.value;y&&!y.contains(f.target)&&(X.value=!1)}function _0(){X.value=!1,x0()}function C0(){s.value||(Ce.value=[],X.value=!1,re.value=!0)}function v0(){re.value=!1,Ce.value=[]}function E0(){if(s.value||!ae)return;const f=hc(ge.value.coordinates??"",ge.value.format||"decimal",ge.value.order||"lat-lon");if(!f.ok){Ce.value=f.errors,B0(f.errors);return}Ce.value=[],In({type:"Polygon",coordinates:[f.ring]}),Ft(),re.value=!1,f.wasClosedAutomatically&&he.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function B0(f){if(!f.length)return;const y=5;f.slice(0,y).forEach(_=>{const A=_.line>0?`Рядок ${_.line}`:"Загальна помилка";he.notify({type:"warning",title:"Імпорт координат",message:`${A} — ${_.message}`})}),f.length>y&&he.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${f.length-y}`})}function V0(f){if(s.value||!ae)return;X.value=!1;const y=f.target,_=y.files?.[0];if(!_)return;const A=new FileReader;A.onload=()=>{try{const T=JSON.parse(String(A.result));if(!oe(T).length){he.notify({type:"warning",title:"Імпорт файлу",message:"Файл не містить коректний GeoJSON-обʼєкт."});return}In(T),Ft()}catch{he.notify({type:"error",title:"Імпорт файлу",message:"Не вдалося прочитати файл. Перевірте формат GeoJSON/JSON."})}finally{y.value=""}},A.onerror=()=>{he.notify({type:"error",title:"Імпорт файлу",message:"Помилка читання файлу."}),y.value=""},A.readAsText(_)}function S0(){if(s.value||!ae)return;const f=ae.getAll(),y=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),_=URL.createObjectURL(y),A=document.createElement("a");A.href=_,A.download="data.geojson",A.click(),URL.revokeObjectURL(_)}return e.onMounted(async()=>{if(window.addEventListener("click",Gr,!0),!c.value)return;const f=await $e();Ne=f.maplibregl,Qe=f.MapboxDraw;const y=qe();y&&(Q=new Ne.Map({container:c.value,style:Se(y),center:[I.value[0],I.value[1]],zoom:v.value,attributionControl:!1}),x.value=Q,Q.addControl(new Ne.NavigationControl({showCompass:!0}),"bottom-right"),Q.on("load",()=>{if(!(!Qe||!Q)){if(ae=new Qe({displayControlsDefault:!1,modes:{...Qe.modes,draw_rectangle:ve()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:et}),Q.addControl(ae),Q.on("click",_=>{if(b.isRulerActive.value){const T=_?.lngLat;if(!T)return;m.value?.addPoint?.({lat:T.lat,lng:T.lng});return}if(!ae||s.value||u.value!=="edit")return;const A=it(_?.point);!A||A===U||requestAnimationFrame(()=>{!ae||s.value||vt(A)})}),Q.on("draw.create",()=>{if(ae&&!b.isRulerActive.value){if(!a.value){const _=ae.getAll();if(_.features.length>1){const A=_.features[_.features.length-1];se=!0,_.features.slice(0,-1).forEach(T=>ae.delete(T.id)),se=!1,A&&(se=!0,ae.add(A),se=!1)}}Ft(),vt()}}),Q.on("draw.update",_=>{if(H||b.isRulerActive.value)return;const A=Array.isArray(_?.features)?_.features:[],T=_?.action==="move"&&A.length>0&&A.every(G=>G?.geometry?.type==="Point");if(_?.action==="move"){if(T){Ft();return}if(H=!0,h0(),H=!1,u.value==="edit"){const G=ln(),le=G?st(G):ae?.getAll?.()?.features?.[0];if(le?.id)try{ae.changeMode("direct_select",{featureId:le.id}),U=String(le.id)}catch{u.value=""}}return}Ft()}),Q.on("draw.delete",()=>{we||F||b.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle"||(Ft(),ae?.getAll?.()?.features?.length||(U=null),u.value="",jt())}),Q.on("draw.selectionchange",_=>{if(!ae||H||b.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle")return;const A=_?.features?.[0]?.id!==void 0&&_?.features?.[0]?.id!==null?String(_.features[0].id):null;if(!s.value&&A){if(u.value==="edit"&&U===A)return;requestAnimationFrame(()=>{!ae||s.value||vt(A)});return}const T=ae.getSelectedIds?.(),G=Array.isArray(T)&&T.length>0?String(T[0]):null;if(!s.value&&G){if(u.value==="edit"&&U===G)return;requestAnimationFrame(()=>{!ae||s.value||vt(G)});return}try{ae.changeMode("simple_select",{featureIds:[]})}catch{}}),M.value!==void 0){const _=M.value;M.value=void 0,requestAnimationFrame(()=>{ae&&In(_)})}Rt(),ce.value.forEach(_=>{const A=J[_];A&&At(A)}),bt()}}),Q.on("contextmenu",p0),Q.on("zoomend",()=>{Q&&(v.value=Q.getZoom())}))}),e.onUnmounted(()=>{b.isRulerActive.value&&b.closeRuler(),window.removeEventListener("click",Gr,!0),Object.values(J).forEach(f=>{Q&&Nt(f)}),Ke(),ie?.remove&&ie.remove(),ie=null,Q?.remove&&Q.remove(),Q=null,ae=null,x.value=null}),e.watch(()=>n.modelValue,f=>{if(!ae){M.value=f;return}const y=ue((a.value?oe(f):oe(f).slice(0,1))||[]),_=Ve(y);if(q&&_===q){q=null;return}q=null,In(f)},{deep:!0}),e.watch(()=>E.value,f=>{const y=Array.isArray(f)?f:[],_=[],A=new Set;y.forEach((T,G)=>{if(!T)return;const le=gt(T,G);_.push(le),A.add(le);const pe={...T,id:le},Le=J[le],nt=Le?.visible??!!pe.visible;Le&&Q&&Nt(Le),J[le]={id:le,config:pe,visible:nt,sourceId:`vs-ov-src-${le}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(J).forEach(T=>{if(A.has(T))return;const G=J[T];G&&Q&&Nt(G),delete J[T]}),ce.value=_,Q&&(ce.value.forEach(T=>{const G=J[T];G&&At(G)}),bt())},{immediate:!0,deep:!0}),e.watch(()=>N.value,()=>{Q&&(Rt(),ce.value.forEach(f=>{const y=J[f];y&&At(y)}),bt())},{deep:!0}),e.watch(()=>$.value,async f=>{if(W.value=[],!f){Q&&(Rt(),ce.value.forEach(y=>{const _=J[y];_&&At(_)}),bt());return}try{const y=await fetch(`https://data.gki.com.ua/api-user/atu/${f}`);if(!y?.ok)return;const A=(await y.json())?.geometry?.coordinates;Array.isArray(A)&&A.length&&(W.value=A)}catch(y){console.error("Failed to fetch KATOTTG bounds",y)}finally{if(!Q)return;Rt(),ce.value.forEach(y=>{const _=J[y];_&&At(_)}),bt()}},{immediate:!0}),e.watch(()=>B.value,f=>{if(!Array.isArray(f)||f.length!==2)return;const y=[Number(f[0]),Number(f[1])];if(qr(I.value,y)||(I.value=[...y],!Q))return;const _=Q.getCenter?.();_&&qr([_.lng,_.lat],I.value)||Q.easeTo({center:[I.value[0],I.value[1]]})},{deep:!0}),e.watch(()=>S.value,f=>{typeof f=="number"&&(v.value=f,Q&&Q.setZoom(f))}),e.watch(s,f=>{f&&jt()}),e.watch(d,f=>{if(f>0){s.value||vt();return}ee||jt()}),e.watch(i,()=>{setTimeout(()=>{Q?.resize&&Q.resize()},50)}),(f,y)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!i.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:i.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:c,class:"w-full h-[calc(100%-28px)]"},null,512),Be.value.search||Be.value.import||Be.value.export?(e.openBlock(),e.createElementBlock("div",Ad,[Be.value.search?(e.openBlock(),e.createBlock(Tc,{key:0,onGoToCoordinates:k0})):e.createCommentVNode("",!0),Be.value.import||Be.value.export?(e.openBlock(),e.createElementBlock("div",Fd,[e.createElementVNode("div",Md,[Be.value.import?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:K,class:"relative"},[e.createElementVNode("button",{type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:w0,disabled:s.value},[y[8]||(y[8]=e.createTextVNode(" Імпорт ",-1)),e.createVNode(e.unref(P.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":X.value}])},null,8,["class"])],8,Dd),X.value?(e.openBlock(),e.createElementBlock("div",Td,[Be.value.import?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:_0}," З файлу ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"block w-full text-left px-3 py-2 hover:bg-gray-100 text-gray-900",onClick:C0}," З координат ")])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),Be.value.export?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"inline-flex items-center gap-2 text-sm font-medium border rounded-md px-3 py-2 bg-white text-blue-600 border-stone-200 hover:bg-blue-500 hover:text-white transition",onClick:S0,disabled:s.value||d.value===0}," Експорт ",8,Ld)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:D,type:"file",onChange:V0,accept:".json,.geojson",class:"hidden",disabled:s.value},null,40,Id)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(he.VsModal),{visible:re.value,"onUpdate:visible":y[1]||(y[1]=_=>re.value=_),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(rt,{schema:te,values:ge.value,"onUpdate:values":y[0]||(y[0]=_=>ge.value=_)},null,8,["values"]),e.createElementVNode("div",Rd,[e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md border border-gray-300 text-gray-700 text-sm hover:bg-gray-100",onClick:v0}," Скасувати "),e.createElementVNode("button",{type:"button",class:"px-3 py-2 rounded-md bg-blue-600 text-white text-sm hover:bg-blue-700 disabled:opacity-50 disabled:cursor-not-allowed",onClick:E0,disabled:s.value}," Побудувати ",8,Od)])]),_:1},8,["visible"]),e.createElementVNode("div",zd,[e.createElementVNode("div",Pd,[Be.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="marker"}]),title:"Point",onClick:y[2]||(y[2]=_=>Rn("marker")),disabled:s.value},[e.createVNode(e.unref(P.MapPin),{class:"h-4 w-4"})],10,jd)):e.createCommentVNode("",!0),Be.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polyline"}]),title:"Line",onClick:y[3]||(y[3]=_=>Rn("polyline")),disabled:s.value},[e.createVNode(ec)],10,Ud)):e.createCommentVNode("",!0),Be.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polygon"}]),title:"Polygon",onClick:y[4]||(y[4]=_=>Rn("polygon")),disabled:s.value},[e.createVNode(rc)],10,Hd)):e.createCommentVNode("",!0),Be.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="rectangle"}]),title:"Rectangle",onClick:y[5]||(y[5]=_=>Rn("rectangle")),disabled:s.value},[e.createVNode(ic)],10,qd)):e.createCommentVNode("",!0),Be.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(b).isRulerActive.value}]),title:"Ruler",onClick:g},[e.createVNode(e.unref(P.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:y[6]||(y[6]=_=>i.value=!i.value),title:"Full Screen"},[e.createVNode(e.unref(P.Maximize),{class:"h-4 w-4"})])])]),Be.value.ruler&&e.unref(b).isRulerActive.value?(e.openBlock(),e.createBlock(Sd,{key:1,ref_key:"rulerPanelRefEl",ref:m,onClose:y[7]||(y[7]=_=>e.unref(b).closeRuler()),onTabChange:e.unref(b).onRulerTabChange,onPointsChange:e.unref(b).onRulerPointsChange,onShapeClosedChange:e.unref(b).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),Be.value.ruler&&e.unref(b).isRulerActive.value&&e.unref(b).hasRulerPoints.value?(e.openBlock(),e.createBlock($d,{key:2,map:x.value,points:e.unref(b).rulerPoints.value,"is-shape-closed":e.unref(b).rulerShapeClosed.value,"label-mode":e.unref(b).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),Ae.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(Re.value)},[e.createElementVNode("div",Kd,[e.createElementVNode("dl",Wd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Ae.value,_=>(e.openBlock(),e.createElementBlock("div",{key:`${_.key}-${_.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",Gd,e.toDisplayString(_.key),1),e.createElementVNode("dd",Yd,e.toDisplayString(_.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",Xd,[e.createElementVNode("div",Zd,[e.createVNode(fc,{basemaps:e.unref(ne),onOnLayerChange:yo},null,8,["basemaps"]),ye.value.length?(e.openBlock(),e.createElementBlock("div",Jd,[y[9]||(y[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",Qd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ye.value,_=>(e.openBlock(),e.createElementBlock("label",{key:_.id,class:"flex items-center gap-2 cursor-pointer select-none"},[e.createElementVNode("input",{type:"checkbox",class:"rounded border-gray-300 text-blue-600 focus:ring-blue-500",checked:_.visible,disabled:s.value,onChange:A=>go(_.id)},null,40,eu),e.createElementVNode("span",tu,e.toDisplayString(_.config.title||_.config.name||_.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",nu,[h.value.length||p.value?(e.openBlock(),e.createElementBlock("div",ou,[e.createElementVNode("div",ru,[e.createElementVNode("div",lu,[y[10]||(y[10]=e.createTextVNode(" Тип: ",-1)),h.value.length<=1?(e.openBlock(),e.createElementBlock("span",au,e.toDisplayString(p.value?Hr(p.value.type):h.value[0]?.label||"—"),1)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(h.value,(_,A)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:_.id},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["font-bold underline-offset-2",_.id===e.unref(U)?"text-blue-700 underline":"text-gray-700 hover:text-blue-700 hover:underline"]),onClick:T=>g0(_.id),disabled:s.value},e.toDisplayString(_.label),11,su),A<h.value.length-1?(e.openBlock(),e.createElementBlock("span",iu,", ")):e.createCommentVNode("",!0)],64))),128))])]),e.createElementVNode("div",cu,[e.createElementVNode("div",du,[y[11]||(y[11]=e.createTextVNode(" Центр: ",-1)),p.value?(e.openBlock(),e.createElementBlock("b",uu,e.toDisplayString(p.value.center.lng.toFixed(5))+", "+e.toDisplayString(p.value.center.lat.toFixed(5)),1)):(e.openBlock(),e.createElementBlock("b",pu,"—"))]),p.value&&p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",fu,[y[12]||(y[12]=e.createTextVNode(" Площа: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",mu,y[13]||(y[13]=[e.createTextVNode("Площа: ",-1),e.createElementVNode("b",null,"—",-1)]))),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md mr-1 cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Zoom to feature",onClick:b0,disabled:s.value},[e.createVNode(e.unref(P.ZoomIn),{class:"h-3 w-3"})],8,hu),e.createElementVNode("button",{class:"tool bg-gray-100 py-1.5 px-2 rounded-lg text-md cursor-pointer hover:bg-blue-500 hover:text-white transition-all",title:"Delete feature",onClick:y0,disabled:s.value},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})],8,gu)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-33669cd5"]]),yu=["data-focus"],bu={class:"flex items-center"},ku={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},xu=["onClick","aria-label"],wu={key:0,class:"absolute text-gray-500 truncate pl-2"},_u={class:"flex-1 min-w-[2px]"},Cu=["placeholder"],vu={class:"flex items-center shrink-0"},Eu=["disabled"],qo=e.defineComponent({__name:"vs-input-tag",props:e.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t;ze(n.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),i=e.ref(!1),c=e.ref(""),d=e.useModel(o,"modelValue"),u=e.computed(()=>n.placeholder||"Add tag…"),p=e.computed(()=>d.value?.length===0&&c.value===""),h=e.computed(()=>!n.disabled&&d.value?.length>0),x=e.computed(()=>n.disabled),m=async()=>{x.value||await e.nextTick(()=>s.value?.focus())},b=Y=>{const L=Y.trim();L!==""&&(!d.value||!Array.isArray(d.value)?d.value=[L]:n.unique?d.value.includes(L)||(d.value=[...d.value,L]):d.value=[...d.value,L],c.value="")},g=()=>{const Y=c.value;Y.trim()!==""&&b(Y),c.value=""},C=Y=>{const L=d.value.slice();L.splice(Y,1),r("update:modelValue",L)},k=()=>{r("update:modelValue",[])},w=()=>{x.value||(i.value=!0)},V=()=>{i.value=!1,!x.value&&g()},R=Y=>{const{key:L}=Y;L==="Enter"?(Y.preventDefault(),g()):L==="Backspace"&&c.value===""&&d.value.length>0&&C(d.value.length-1)};return(Y,L)=>(e.openBlock(),e.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:l,onClick:L[1]||(L[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass]),role:"group","aria-label":"Tag input"},[e.createElementVNode("div",{class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",i.value?"border-blue-500 ring-1 ring-blue-500":"",x.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":i.value?"true":"false",onClick:m},[e.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:a},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(B,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",bu,[e.createElementVNode("div",ku,e.toDisplayString(B),1)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border hover:bg-[#ffbdad] hover:text-[#de350b]",onClick:e.withModifiers($=>C(S),["stop"]),"aria-label":`Remove ${B}`},[e.createVNode(e.unref(P.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,xu)]))),128)),p.value?(e.openBlock(),e.createElementBlock("div",wu,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",_u,[x.value?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:s,class:"pl-2 w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-label":"Add tag","onUpdate:modelValue":L[0]||(L[0]=B=>c.value=B),onFocus:w,onBlur:V,onKeydown:R,placeholder:d.value&&d.value.length?"":void 0},null,40,Cu)),[[e.vModelText,c.value]])])],512),e.createElementVNode("div",vu,[h.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-label":"Clear all tags",disabled:x.value,onClick:e.withModifiers(k,["stop"])},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,Eu)):e.createCommentVNode("",!0)])],10,yu)],2)],512))}}),Bu={class:"relative flex gap-1 bg-white w-full"},Vu=["disabled","placeholder"],Ko=xe(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.inject("values"),n=o,r=e.useModel(o,"modelValue");function l(s){const i={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return s.toLowerCase().split("").map(c=>i[c]||c).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[n.parent||""]?.toString(),i=l(s);r.value=i.toString()};return(s,i)=>(e.openBlock(),e.createElementBlock("div",Bu,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:s.disabled,placeholder:s.placeholder,"onUpdate:modelValue":i[0]||(i[0]=c=>r.value=c),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Vu),[[e.vModelText,r.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:a}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),Su={class:"relative flex gap-1 bg-white w-full"},$u=["disabled","placeholder"],Nu=["disabled"],Au={key:0},Fu={key:1},Wo=xe(e.defineComponent({__name:"vs-input-codegen",props:e.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(!1),l=e.computed(()=>t.init!==!1),a=e.computed(()=>!!t.table&&!!t.code),s=()=>{if(!a.value)return"";const d=encodeURIComponent(String(t.table)),u=encodeURIComponent(String(t.code));return`/api/code-gen/${d}/${u}`},i=async()=>{if(!a.value||r.value)return;const d=s();if(d){r.value=!0;try{const p=await(await fetch(d)).text();n.value=p}finally{r.value=!1}}},c=()=>{l.value&&(n.value||i())};return e.onMounted(()=>{c()}),e.watch(()=>[t.table,t.code,t.init],()=>{c()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",Su,[e.withDirectives(e.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":u[0]||(u[0]=p=>n.value=p),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,$u),[[e.vModelText,n.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:r.value||d.disabled||!a.value,onClick:i},[r.value?(e.openBlock(),e.createElementBlock("span",Fu,"...")):(e.openBlock(),e.createElementBlock("span",Au,"Gen"))],8,Nu)]))}}),[["__scopeId","data-v-6ee5237d"]]),Mu={class:"w-full"},Du={ref:"sortableContainer",class:"flex flex-col gap-1"},Tu=["onDragstart","onDrop"],Lu={class:"cursor-move",type:"button"},Iu={class:"w-1/3"},Ru={class:"w-2/3"},Ou=["onClick"],zu={key:0,class:"text-[14px] text-gray-700"},Pu={class:"mt-2 w-full flex items-center"},ju=["disabled"],Go=xe(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,r=e.inject("values"),l=o,a=t,s=l.addButtonText??"Додати",i=l.ignore??[],c=e.ref([]),d=e.ref(null);(()=>{const g=l.parent&&r?.value?.[l.parent]||l.modelValue||{};c.value=Object.entries(g).filter(([C])=>!i.includes(C)).map(([C,k])=>({id:n("key-value-"),key:C,value:k}))})();function p(g){d.value=g}function h(g){if(d.value===null||d.value===g)return;const C=c.value.splice(d.value,1)[0];c.value.splice(g,0,C),d.value=null}const x=e.computed(()=>c.value.some(g=>g.key&&!g.value||!g.key&&g.value)),m=()=>{c.value.push({id:n("key-value-"),key:"",value:""})},b=g=>{c.value=c.value.filter(C=>C.id!==g)};return e.watch(c,g=>{const C={};g.forEach(w=>{w.key&&w.value!==void 0&&(C[w.key]=w.value)});const k={};i.length&&i.forEach(w=>{k[w]=l.parent?r?.value?.[l.parent]?.[w]:void 0}),r?.value&&l.parent&&(r.value[l.parent]={...k,...C}),a("update:modelValue",C)},{deep:!0}),(g,C)=>(e.openBlock(),e.createElementBlock("div",Mu,[e.createElementVNode("div",Du,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(k,w)=>(e.openBlock(),e.createElementBlock("div",{key:k.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===w}]),draggable:"true",onDragstart:V=>p(w),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:V=>h(w)},[e.createElementVNode("button",Lu,[e.createVNode(e.unref(P.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",Iu,[e.createVNode(Ot,{modelValue:k.key,"onUpdate:modelValue":V=>k.key=V,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",Ru,[e.createVNode(Ot,{modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:V=>b(k.id),class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,Ou)],42,Tu))),128))],512),c.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",zu," Дані для відображення відсутні ")),e.createElementVNode("div",Pu,[e.createElementVNode("button",{type:"button",onClick:m,disabled:x.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(s)),1)],8,ju)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),Uu={class:"w-full"},Hu={ref:"sortableContainer",class:"flex flex-col gap-1"},qu=["onDragstart","onDrop"],Ku=["disabled"],Wu={class:"flex-1"},Gu=["onClick","disabled"],Yu={key:0,class:"text-[14px] text-gray-700"},Xu={class:"mt-2 w-full flex items-center"},Zu=["disabled"],Yo=xe(e.defineComponent({__name:"vs-input-text-array",props:e.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),i=e.computed(()=>t.addButtonText??"Додати");let c=!1;const d=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,u=g=>{const C=g??n.value??[];r.value=C.map((k,w)=>({id:r.value[w]?.id??d("text-array"),value:k??""}))};u(),e.watch(()=>n.value,g=>{if(c){c=!1;return}u(g||[])},{deep:!0}),e.watch(r,g=>{c=!0,n.value=g.map(C=>C.value).filter(C=>C!=null&&C!=="")},{deep:!0});const p=e.computed(()=>a.value||r.value.some(g=>!g.value));function h(){p.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function x(g){a.value||(r.value=r.value.filter(C=>C.id!==g))}function m(g){a.value||(l.value=g)}function b(g){if(a.value||l.value===null||l.value===g)return;const C=[...r.value],[k]=C.splice(l.value,1);C.splice(g,0,k),r.value=C,l.value=null}return(g,C)=>(e.openBlock(),e.createElementBlock("div",Uu,[e.createElementVNode("div",Hu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(k,w)=>(e.openBlock(),e.createElementBlock("div",{key:k.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":l.value===w}]),draggable:"true",onDragstart:V=>m(w),onDragover:C[0]||(C[0]=e.withModifiers(()=>{},["prevent"])),onDrop:V=>b(w)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(P.GripVertical),{class:"h-4 w-4"})],8,Ku),e.createElementVNode("div",Wu,[g.inputType==="text"?(e.openBlock(),e.createBlock(Ot,{key:0,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="tel"?(e.openBlock(),e.createBlock(Un,{key:1,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="email"?(e.openBlock(),e.createBlock(jn,{key:2,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),g.inputType==="mask"?(e.openBlock(),e.createBlock(cn,{key:3,modelValue:k.value,"onUpdate:modelValue":V=>k.value=V,mask:g.mask,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:V=>x(k.id),disabled:a.value,class:"shrink-0 w-[30px] text-gray-600 h-[30px] rounded-full flex items-center justify-center bg-gray-100 hover:bg-gray-200 disabled:opacity-50"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,Gu)],42,qu))),128))],512),r.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Yu," Дані для відображення відсутні ")),e.createElementVNode("div",Xu,[e.createElementVNode("button",{type:"button",onClick:h,disabled:p.value,class:"py-1.5 px-2 flex items-center gap-x-1 text-xs font-medium rounded-full border border-dashed border-gray-200 bg-white text-gray-800 hover:bg-gray-50 disabled:opacity-50 disabled:cursor-not-allowed"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(i.value),1)],8,Zu)])]))}}),[["__scopeId","data-v-2c229b1f"]]),Ju={class:"flex items-center gap-2 w-full"},Qu=["disabled"],ep=["disabled"],Xo=e.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=ze(n.style),l=t,a=e.computed({get:()=>n.modelValue||"#000000",set:i=>l("update:modelValue",i)}),s=e.computed(()=>!!n.disabled);return(i,c)=>(e.openBlock(),e.createElementBlock("div",Ju,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":c[0]||(c[0]=d=>a.value=d),disabled:s.value,ref:"color",class:e.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[i.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,Qu),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":c[1]||(c[1]=d=>a.value=d),disabled:s.value},null,8,ep),[[e.vModelText,a.value]])]))}}),tp={class:"flex items-center gap-2 w-full"},np=["min","max","step","disabled"],op=["value","min","max","step","disabled"],Zo=e.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=ze(n.style),l=t,a=u=>{const p=Number(u),h=Number(n.min),x=Number(n.max);return Number.isNaN(p)?h:Math.min(x,Math.max(h,p))},s=e.computed({get:()=>a(n.modelValue??n.min),set:u=>l("update:modelValue",a(u))}),i=u=>{const p=u.target,h=a(p.value);p.value=String(h),l("update:modelValue",h)},c=u=>{Number(n.min)>=0&&u.key==="-"&&u.preventDefault()},d=e.computed(()=>!!n.disabled);return(u,p)=>(e.openBlock(),e.createElementBlock("div",tp,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":p[0]||(p[0]=h=>s.value=h),min:u.min,max:u.max,step:u.step,disabled:d.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[u.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")])},null,10,np),[[e.vModelText,s.value]]),e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number",value:s.value,min:u.min,max:u.max,step:u.step,onInput:i,onKeydown:c,disabled:d.value},null,40,op)]))}}),rp=["placeholder","disabled","name"],lp=["type","value","onInput","placeholder","disabled"],ap=["onClick"],Jo=e.defineComponent({__name:"vs-input-array",props:e.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.ref(t.count),r=e.computed(()=>t.limit),{inputClass:l}=ze(t.style),a=e.useModel(o,"modelValue"),s=e.computed(()=>!!t.disabled),i=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const b=a.value?.length??0;b<n.value&&(a.value=[...a.value??[],...Array(n.value-b)])});const c=e.ref({}),d=e.ref({});function u(b,g){b&&(c.value[g]=b)}async function p(b,g){if(!b||t.inputType!=="mask")return;const{default:C}=await Promise.resolve().then(()=>so);d.value[g]&&d.value[g].destroy(),d.value[g]=C(b,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[g].on("accept",()=>{const k=[...a.value||[]];k[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=k}),d.value[g].on("complete",()=>{const k=[...a.value||[]];k[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=k}),a.value?.[g]&&(d.value[g].value=a.value[g])}function h(b,g){if(s.value)return;const C=b.target.value??null,k=[...a.value];k[g]=t.inputType==="text"?C:Number(C),a.value=k}function x(){n.value+=1;const b=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,b],t.inputType==="mask"&&setTimeout(()=>{const g=n.value-1;c.value[g]&&p(c.value[g],g)},0)}function m(b){if(n.value>1){d.value[b]&&(d.value[b].destroy(),delete d.value[b]),n.value-=1,a.value=a.value.filter((C,k)=>k!==b);const g={};Object.keys(d.value).forEach(C=>{const k=parseInt(C,10);k>b?g[k-1]=d.value[k]:k<b&&(g[k]=d.value[k])}),d.value=g}}return e.onMounted(()=>{if(t.inputType==="mask")for(let b=0;b<n.value;b+=1)c.value[b]&&p(c.value[b],b)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(b=>{b&&b.destroy()})}),e.watch(()=>t.mask,b=>{t.inputType==="mask"&&Object.values(d.value).forEach(g=>{g&&g.updateOptions({mask:b,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,b=>{t.inputType==="mask"&&b&&b.forEach((g,C)=>{d.value[C]&&d.value[C].value!==g&&(d.value[C].value=g||"")})},{deep:!0}),(b,g)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["grid gap-2",`grid-cols-${r.value}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,C=>(e.openBlock(),e.createElementBlock("div",{key:C,class:"flex items-center gap-2 w-full"},[b.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:k=>u(k,C-1),placeholder:b.placeholder,disabled:b.disabled,name:`${b.name}[${C-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":b.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,rp)):(e.openBlock(),e.createElementBlock("input",{key:1,type:b.inputType,value:a.value?.[C-1],onInput:k=>h(k,C-1),placeholder:i.value,disabled:s.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":b.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,lp)),!b.disabled&&C===n.value&&b.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(x,["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-green-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"})])):e.createCommentVNode("",!0),!b.disabled&&n.value>1&&b.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(k=>m(C-1),["stop"]),class:"cursor-pointer shrink-0 w-[38px] text-red-600 h-[38px] rounded-md flex items-center justify-center border border-stone-200 hover:bg-stone-100"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,ap)):e.createCommentVNode("",!0)]))),128))],2))}}),sp={class:"flex gap-1 w-full"},ip=["aria-expanded","data-focus"],cp=["placeholder","disabled","readonly"],dp={class:"max-h-full"},up=["onClick","disabled"],pp={key:0,class:"px-3 py-2 text-sm text-stone-500"},fp=["disabled"],mp={class:"flex flex-col gap-1"},hp=["onDragstart","onDrop"],gp=["disabled"],yp=["title"],bp=["disabled","onClick","aria-label"],kp={key:0,class:"text-xs text-stone-500"},wn=xe(e.defineComponent({__name:"vs-input-array-select",props:e.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},add:{},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t,l=e.useModel(o,"modelValue"),a=e.ref([]),s=e.ref(n.options??[]),i=e.ref({}),c=e.ref({}),d=e.ref({keyword:"",parent:null}),u=e.ref(""),p=e.ref(!1),h=e.ref(null),x=e.ref(null),m=e.ref(null),b=e.ref(null),g=e.ref(null),C=e.ref({});let k=!1,w=!1;const V=e.inject("values"),R=e.computed(()=>!!n.disabled),Y=e.computed(()=>n.placeholder??"Оберіть значення"),L=e.computed(()=>n.search!==!1),B=e.computed(()=>{const F=n.parent??n.parentValue;return F?String(F):""}),S=e.computed(()=>B.value?V?.value?.[B.value]??null:null),$=F=>F==null?"__null__":String(F),E=F=>{if(!F)return"";const H=F.label??F.text??F.name??F.ua??F.en;return H?String(H):F.id!==void 0&&F.id!==null?String(F.id):""},N=F=>{const H=$(F);return c.value[H]||(c.value[H]=`array-select-${H}-${Math.random().toString(36).slice(2,8)}`),c.value[H]},I=e.computed(()=>new Set(a.value.map(F=>$(F.id)))),v=e.computed(()=>{const F=I.value;let H=[...s.value];if(!n.data&&u.value.trim()){const ee=u.value.toLowerCase();H=H.filter(ie=>E(ie).toLowerCase().includes(ee))}return H.filter(ee=>!F.has($(ee.id)))}),M=()=>{if(!n.data)return"";const F=n.prefix??"api",H=n.api??`/${F}/suggest/${n.data}`;return`${n.host??""}${H}`},D=()=>{a.value.length&&(k=!0,a.value=a.value.map(F=>({...F,text:i.value[$(F.id)]??F.text})))},K=F=>{const H=$(F.id),ee=E(F);ee&&(i.value[H]=ee)},W=F=>{s.value=F?[...F]:[],F?.forEach(K),D()},X=F=>{if(!F.length)return;const H=new Map(s.value.map(ee=>[$(ee.id),ee]));F.forEach(ee=>{const ie=$(ee.id);H.set(ie,ee),K(ee)}),s.value=Array.from(H.values()),D()},re=async(F="")=>{if(!n.data)return[];const H=M();if(!H)return[];const ee=new URLSearchParams;ee.set("json","1"),F&&ee.set("key",F),n.start===1&&ee.set("start","1"),S.value!==null&&S.value!==void 0&&S.value!==""&&ee.set("parent",String(S.value));try{return(await(await fetch(`${H}?${ee.toString()}`)).json())?.data??[]}catch{return[]}},Ce=async F=>{if(!n.data||!F.length)return[];const H=M();if(!H)return[];const ee=Array.from(new Set(F.map(ve=>$(ve)))),ie=new URLSearchParams;ie.set("json","1"),ie.set("val",ee.join(",")),n.start===1&&ie.set("start","1"),S.value!==null&&S.value!==void 0&&S.value!==""&&ie.set("parent",String(S.value));try{const qe=(await(await fetch(`${H}?${ie.toString()}`)).json())?.data??[];return X(qe),qe}catch{return[]}},ge=async F=>{if(F==null||F==="")return null;const H=$(F),ee=s.value.find(ve=>$(ve.id)===H);if(ee)return ee;const[ie]=await Ce([F]);return ie??null},te=async(F="",{force:H=!1}={})=>{if(!n.data)return;const ee=S.value??null;if(!H&&d.value.keyword===F&&d.value.parent===ee&&s.value.length>0)return;d.value={keyword:F,parent:ee};const ve=await re(F);W(ve)},we=((F,H=200)=>{let ee;return(...ie)=>{ee&&clearTimeout(ee),ee=setTimeout(()=>F(...ie),H)}})(async F=>{n.data&&await te(F,{force:!0})},250),J=e.ref(null),ce=()=>{if(!m.value)return;const F=m.value.getBoundingClientRect(),H=window.innerHeight??document.documentElement.clientHeight,ee=window.innerWidth??document.documentElement.clientWidth,ie=8,ve=8,et=n.maxHeight??280,qe=H-F.bottom-ve-ie,gt=F.top-ve-ie,He=qe>=gt,Ke=Math.max(ee-ie*2,0);let{width:yt}=F;Ke>0&&yt>Ke&&(yt=Ke);let{left:lt}=F;lt+yt+ie>ee&&(lt=ee-yt-ie),lt=Math.max(lt,ie);const It=Math.min(et,Math.max(He?qe:gt,50));C.value={position:"fixed",left:`${lt}px`,width:`${yt}px`,maxHeight:`${It}px`,transform:He?"none":"translateY(-100%)",top:He?`${F.bottom+ve}px`:`${F.top-ve}px`}},ye=async(F="click")=>{R.value||p.value||(J.value=F,await te(u.value.trim()),p.value=!0,await e.nextTick(),ce(),g.value?.focus())},Ee=()=>{p.value=!1,J.value=null,e.nextTick(()=>{g.value?.blur()})},Ae=async F=>{if(F.stopPropagation(),!R.value){if(p.value){if(J.value==="focus"){J.value=null;return}Ee();return}await ye("click")}},Re=F=>{F.key==="Escape"&&Ee()},Fe=F=>{if(!p.value)return;const H=F.target;b.value?.contains(H)||Ee()},Be=F=>{const H=F.target;x.value?.contains(H)||b.value?.contains(H)||Ee()},j=F=>{if(F.key==="Escape"){F.preventDefault(),Ee();return}if(F.key==="Enter"){F.preventDefault();const H=v.value[0];H&&Z(H)}},Z=F=>{if(!F)return;const H=$(F.id);if(I.value.has(H))return;K(F);const ee={id:F.id,text:E(F)||String(F.id??""),key:N(F.id)};a.value=[...a.value,ee],ne(F),u.value="",e.nextTick(()=>{g.value?.focus()})},ne=F=>{const H=a.value.map(ee=>ee.id);r("value-selected",{name:n.name,value:H,option:F})},de=F=>{if(R.value)return;const H=a.value.filter(ee=>$(ee.id)!==$(F));a.value=H},{isOpenAdd:me,addData:$e,addSchema:Se,addForm:Ne,addTitle:Qe,addOption:Q,onAddValue:ae}=Mo({props:n,fetchOptionByValue:ge,optionsList:s,selectedOption:e.ref(null),modelValue:l,onCreated:async(F,H)=>{const ee=F??await ge(H),ie=ee?.id??H;I.value.has($(ie))||(ee&&K(ee),a.value=[...a.value,{id:ie,text:ee?E(ee):String(ie),key:N(ie)}],ne(ee??null))}}),Me=F=>{R.value||(h.value=F)},z=F=>{if(R.value||h.value===null||h.value===F)return;const H=[...a.value],[ee]=H.splice(h.value,1);H.splice(F,0,ee),h.value=null,a.value=H},q=async()=>{const H=(Array.isArray(l.value)?[...l.value]:[]).filter(ie=>ie!=null);if(n.data&&H.length){const ie=H.filter(ve=>!i.value[$(ve)]);ie.length&&await Ce(ie)}const ee=H.map(ie=>({id:ie,text:i.value[$(ie)]??String(ie),key:N(ie)}));k=!0,a.value=ee};e.watch(a,F=>{if(k){k=!1;return}const H=F.map(ee=>ee.id);w=!0,l.value=H,r("change",H)},{deep:!0}),e.watch(l,()=>{if(w){w=!1;return}q()},{deep:!0}),e.watch(u,F=>{!n.data||!p.value||we(F.trim())}),e.watch(R,F=>{F&&Ee()}),e.watch(()=>n.options,async F=>{n.data||(W(F??[]),await q())},{immediate:!0,deep:!0}),e.watch(()=>n.data,async F=>{F&&(await te(u.value.trim()),await q())},{immediate:!0});const U=e.ref(!1);return e.watch(S,async()=>{if(n.data){if(!U.value){U.value=!0;return}a.value=[],await te(u.value.trim()),await q()}}),e.onMounted(async()=>{document.addEventListener("click",Be,!0),window.addEventListener("keydown",Re),window.addEventListener("scroll",Fe,!0),await q()}),e.onUnmounted(()=>{document.removeEventListener("click",Be,!0),window.removeEventListener("keydown",Re),window.removeEventListener("scroll",Fe,!0)}),(F,H)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(he.VsModal),{visible:e.unref(me),"onUpdate:visible":H[1]||(H[1]=ee=>e.isRef(me)?me.value=ee:null),class:"z-[1000]",title:e.unref(Qe),buttonText:"Додати",onDone:e.unref(Q)},{default:e.withCtx(()=>[e.createVNode(rt,{schema:e.unref(Se),modelValue:e.unref($e),"onUpdate:modelValue":H[0]||(H[0]=ee=>e.isRef($e)?$e.value=ee:null),ref_key:"addForm",ref:Ne},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),e.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:x},[e.createElementVNode("div",sp,[e.createElementVNode("div",{class:"relative flex-1",onClick:H[4]||(H[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",p.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",R.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),role:"combobox","aria-expanded":p.value,"aria-haspopup":"listbox","data-focus":p.value?"true":"false",onClick:Ae},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":H[2]||(H[2]=ee=>u.value=ee),placeholder:Y.value,disabled:R.value,readonly:!L.value,onFocus:H[3]||(H[3]=()=>ye("focus")),onKeydown:j,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,cp),[[e.vModelText,u.value]]),e.createElementVNode("span",{class:e.normalizeClass(["text-stone-400 transition-transform duration-150",p.value?"rotate-180":""]),"aria-hidden":"true"},[e.createVNode(e.unref(P.ChevronDown),{class:"h-4 w-4"})],2)],10,ip),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[p.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:b,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(C.value)},[e.createElementVNode("div",dp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,ee=>(e.openBlock(),e.createElementBlock("button",{key:$(ee.id),type:"button",class:"w-full px-3 py-2 text-left text-sm text-stone-900 hover:bg-stone-100 disabled:opacity-50",onClick:e.withModifiers(ie=>Z(ee),["stop"]),disabled:R.value},e.toDisplayString(E(ee)),9,up))),128)),v.value.length===0?(e.openBlock(),e.createElementBlock("p",pp," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:H[5]||(H[5]=(...ee)=>e.unref(ae)&&e.unref(ae)(...ee)),class:"bg-white hover:bg-gray-100 text-sm text-gray-900 py-[10px] px-3 border border-stone-200 rounded-md h-[38px] flex items-center gap-2",disabled:R.value,type:"button"},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),H[8]||(H[8]=e.createElementVNode("span",null,"Додати",-1))],8,fp)):e.createCommentVNode("",!0)]),e.createElementVNode("div",mp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(ee,ie)=>(e.openBlock(),e.createElementBlock("div",{key:ee.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":h.value===ie}]),draggable:"true",onDragstart:ve=>Me(ie),onDragover:H[6]||(H[6]=e.withModifiers(()=>{},["prevent"])),onDrop:ve=>z(ie),onDragend:H[7]||(H[7]=ve=>h.value=null)},[e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-500 hover:text-stone-900",disabled:R.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(P.GripVertical),{class:"h-4 w-4"})],8,gp),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:ee.text},e.toDisplayString(ee.text),9,yp),e.createElementVNode("button",{type:"button",class:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full text-stone-400 hover:text-stone-900",disabled:R.value,onClick:e.withModifiers(ve=>de(ee.id),["stop"]),"aria-label":`Видалити ${ee.text}`},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})],8,bp)],42,hp))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",kp,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-da4b4da7"]]),xp={class:"flex items-center gap-2 w-full"},wp={class:"relative flex-1"},_p=["placeholder","disabled","onKeydown"],Cp=["disabled"],vp={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},Ep={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},Bp={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},Vp=["onClick"],Sp={key:0,class:"p-4 text-sm text-gray-500"},Qo=e.defineComponent({__name:"vs-input-address",props:e.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(o,{emit:t}){const n=/{{\s*([^}]+?)\s*}}/g,r=o,l=t,{inputClass:a}=ze(r.style),s=e.useModel(o,"modelValue"),i=e.computed({get:()=>s.value,set:L=>{s.value=L}}),c=e.ref(!1),d=e.ref([]),u=e.ref(!1),p=e.ref(null);e.watch(u,L=>{typeof document>"u"||(L?(p.value=document.body.style.overflow,document.body.style.overflow="hidden"):p.value!=null?(document.body.style.overflow=p.value,p.value=null):document.body.style.removeProperty("overflow"))}),e.onBeforeUnmount(()=>{typeof document>"u"||(p.value!=null?document.body.style.overflow=p.value:document.body.style.removeProperty("overflow"))});const h=e.computed(()=>r.placeholder??""),x=e.computed(()=>!!r.disabled),m=L=>{if(!L)return null;if(Array.isArray(L))return L;if(typeof L=="string"){const B=L.split(",").map(S=>S.trim()).filter(Boolean);return B.length!==4?null:B.map(Number)}return null},b=e.computed(()=>{const L=m(r.bbox);if(!L||L.length!==4)return null;const B=L.map(Number);return B.some(S=>Number.isNaN(S))?null:B}),g=e.computed(()=>{const L=b.value;if(!L)return"";const[B,S,$,E]=L;return`${B},${Math.max(S,E)},${$},${Math.min(S,E)}`});e.computed(()=>g.value?"1":"0");const C=e.inject("values");function k(){!x.value&&i.value.trim()&&w()}async function w(){const L=(i.value||"").trim();if(!L)return;let B=L;if(r.includes?.length&&C?.value){const $=r.includes.map(E=>C.value?.[E]).filter(Boolean);$.length&&(B=`${$.join(", ")}, ${L}`)}const S=Y(B);if(S){c.value=!0;try{const E=await(await fetch(S)).json();d.value=Array.isArray(E)?E:[],u.value=!0}catch($){console.error("Address search error:",$)}finally{c.value=!1}}}function V(){u.value=!u.value}function R(L){if(!L)return;u.value=!1;const B=parseFloat(L.lat),$={type:"Point",coordinates:[parseFloat(L.lon),B]};r.geom&&C?.value&&(C.value[r.geom]=$),l("update:geom",$)}function Y(L){if(!r.api)return"";const B={value:encodeURIComponent(L),bbox:b.value?b.value.join(","):""};return r.api.replace(n,(S,$)=>B[$.trim()]??"")}return(L,B)=>(e.openBlock(),e.createElementBlock("div",xp,[e.createElementVNode("div",wp,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":B[0]||(B[0]=S=>i.value=S),placeholder:h.value,disabled:x.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white border rounded-md placeholder:text-gray-400 focus:ring-2 focus:ring-blue-500",[e.unref(a),{"!border-red-600":r.error}]]),style:{border:"1px solid #CFD9E0"},onKeydown:e.withKeys(e.withModifiers(k,["prevent"]),["enter"])},null,42,_p),[[e.vModelText,i.value]]),d.value.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick:V,title:"Show search results"},[e.createVNode(e.unref(P.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:w,class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px]",disabled:c.value||!i.value?.trim()},[c.value?(e.openBlock(),e.createBlock(e.unref(P.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(P.Search),{key:0,class:"h-4 w-4"}))],8,Cp),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[u.value?(e.openBlock(),e.createElementBlock("div",vp,[e.createElementVNode("div",Ep,[e.createElementVNode("div",Bp,[B[2]||(B[2]=e.createElementVNode("span",null,"Результати пошуку",-1)),e.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:B[1]||(B[1]=S=>u.value=!1),title:"Close"},[e.createVNode(e.unref(P.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(S,$)=>(e.openBlock(),e.createElementBlock("li",{key:$,onClick:E=>R(S),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(S.display_name),9,Vp))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Sp," Не знайдено результатів "))])])):e.createCommentVNode("",!0)]))]))}}),$p={class:"vs-datalist space-y-3"},Np={class:"space-y-3"},Ap=["onClick","disabled"],Fp={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Mp=["disabled"],Dp=xe(e.defineComponent({__name:"vs-input-datalist",props:e.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>Array.isArray(n.value)?n.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(b=>({...b,disabled:t.disabled||b.disabled}))??[]),s=e.computed(()=>a.value.map(b=>m(b))),i=e.computed(()=>t.disabled?!1:t.maxItems?r.value.length<t.maxItems:!0),c=e.computed(()=>t.disabled||r.value.length<=(t.minItems||0));e.watch(()=>r.value.length,()=>{d(),u()},{immediate:!0}),e.watch(()=>t.schema,u,{immediate:!0,deep:!0});function d(){const b=r.value.length;l.value.length<b?l.value=[...l.value,...Array.from({length:b-l.value.length},()=>Gn())]:l.value.length>b&&l.value.splice(b)}function u(){if(!t.minItems||r.value.length>=t.minItems)return;const b=t.minItems-r.value.length,g=Array.from({length:b},p);n.value=[...r.value,...g]}function p(){const b={};return a.value.forEach(g=>{b[g.name]=g?.default??null}),b}function h(){i.value&&(n.value=[...r.value,p()],d())}function x(b){c.value||(n.value=r.value.filter((g,C)=>C!==b),d(),u())}function m(b){return{...b}}return(b,g)=>(e.openBlock(),e.createElementBlock("div",$p,[e.createElementVNode("div",Np,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(C,k)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[k],class:"flex items-center gap-3"},[e.createVNode(rt,{schema:s.value,layout:"inline",navigation:!1,values:r.value[k],"onUpdate:values":w=>r.value[k]=w,"form-id":l.value[k]},null,8,["schema","values","onUpdate:values","form-id"]),e.createElementVNode("button",{type:"button",class:"h-[38px] w-[38px] flex items-center justify-center text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",onClick:w=>x(k),disabled:c.value},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})],8,Ap)]))),128)),r.value.length===0?(e.openBlock(),e.createElementBlock("div",Fp,e.toDisplayString(t.emptyLabel),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:h,disabled:!i.value},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Mp)]))}}),[["__scopeId","data-v-260e3e66"]]),Tp={class:"vs-dataform space-y-4"},Lp=["draggable","onDragstart","onDragover","onDragenter","onDrop"],Ip={class:"flex items-center gap-2"},Rp=["onClick"],Op={class:"text-sm font-medium text-gray-700"},zp={class:"flex items-center gap-2"},Pp=["title","onClick","disabled"],jp=["title","onClick","disabled"],Up={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Hp=["disabled"],qp=xe(e.defineComponent({__name:"vs-input-dataform",props:e.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),i=e.ref(null),c=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),u=e.computed(()=>t.emptyLabel??"Ще немає груп"),p=e.computed(()=>t.schema?.map(te=>({...te,disabled:t.disabled||te.disabled}))??[]),h=e.computed(()=>p.value.map(te=>S(te))),x=e.computed(()=>t.view==="accordion"),m=e.computed(()=>!!(t.collapsible||x.value)),b=e.computed(()=>t.draggable!==!1),g=e.computed(()=>t.disabled?!1:t.maxGroups?n.value.length<t.maxGroups:!0),C=e.computed(()=>t.disabled||n.value.length<=(t.minGroups||0));e.watch(()=>n.value.length,()=>{k(),w(),V()},{immediate:!0}),e.watch(()=>t.schema,V,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{w()},{immediate:!0});function k(){const te=n.value.length;r.value.length<te?r.value=[...r.value,...Array.from({length:te-r.value.length},()=>Gn())]:r.value.length>te&&r.value.splice(te)}function w(){const te=n.value.length;x.value?te===0?a.value=-1:a.value>=te?a.value=te-1:a.value<0&&(a.value=0):l.value.length<te?l.value=[...l.value,...Array.from({length:te-l.value.length},()=>!1)]:l.value.length>te&&l.value.splice(te)}function V(){if(!t.minGroups||n.value.length>=t.minGroups)return;const te=t.minGroups-n.value.length,se=Array.from({length:te},R);n.value=[...n.value,...se],w()}function R(){const te={};return p.value.forEach(se=>{te[se.name]=se?.default??null}),te}function Y(){g.value&&(n.value=[...n.value,R()],k(),w())}function L(te){C.value||(n.value=n.value.filter((se,we)=>we!==te),k(),x.value?a.value>=n.value.length&&(a.value=n.value.length-1):l.value.splice(te,1),V())}function B(te){if(t.disabled)return;const se=JSON.parse(JSON.stringify(n.value[te]??{}));n.value=[...n.value.slice(0,te+1),se,...n.value.slice(te+1)],k(),x.value?a.value>te&&(a.value+=1):l.value.splice(te+1,0,l.value[te]??!1)}function S(te){return{...te}}function $(te){return x.value?a.value===-1&&te===0?!1:a.value!==te:!!l.value[te]}function E(te){if(m.value){if(x.value){a.value=te;return}l.value[te]=!l.value[te]}}function N(te,se){if(!b.value||t.disabled){se.preventDefault();return}s.value=te,i.value=te,c.value={groups:JSON.parse(JSON.stringify(n.value)),keys:[...r.value],states:[...l.value]},se.dataTransfer?.setData("text/plain",String(te)),se.dataTransfer?.setDragImage?.(se.currentTarget,0,0)}function I(te,se){!b.value||t.disabled||s.value!==null&&X(te,se)}function v(te,se){X(te,se)}function M(te){!b.value||t.disabled||ge()}function D(){c.value&&W(),s.value=null,i.value=null,c.value=null}function K(te,se){const we=[...n.value],[J]=we.splice(te,1);we.splice(se,0,J),n.value=we;const ce=[...r.value],[ye]=ce.splice(te,1);if(ce.splice(se,0,ye),r.value=ce,x.value)a.value===te&&(a.value=se);else{const Ee=[...l.value],[Ae]=Ee.splice(te,1);Ee.splice(se,0,Ae),l.value=Ee}}function W(){c.value&&(n.value=c.value.groups,r.value=c.value.keys,l.value=c.value.states,c.value=null,i.value=null)}function X(te,se){if(s.value===null)return;const we=re(te,se);i.value=we,Ce(we)}function re(te,se){if(!se?.currentTarget)return te;const we=se.currentTarget.getBoundingClientRect(),ce=se.clientY-we.top>we.height/2?te+1:te;return Math.max(0,Math.min(ce,n.value.length))}function Ce(te){const se=s.value;if(se===null)return;let we=te;if(we>n.value.length&&(we=n.value.length),we===se||we===se+1)return;const J=we>se?we-1:we;K(se,J),s.value=J,i.value=we>se?J+1:J}function ge(){c.value=null,s.value=null,i.value=null}return(te,se)=>(e.openBlock(),e.createElementBlock("div",Tp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(we,J)=>(e.openBlock(),e.createElementBlock("div",{key:r.value[J],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":$(J)?"pt-6 px-6":"p-6"]]),draggable:b.value&&!t.disabled,onDragstart:ce=>N(J,ce),onDragend:D,onDragover:e.withModifiers(ce=>I(J,ce),["prevent"]),onDragenter:e.withModifiers(ce=>v(J,ce),["prevent"]),onDrop:e.withModifiers(ce=>M(),["prevent"])},[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center justify-between gap-2 border-b border-gray-100 px-4 py-3",[t.view!=="accordion"?"-mx-6 -mt-6 px-6":"",t.view!=="accordion"&&!$(J)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",Ip,[b.value?(e.openBlock(),e.createBlock(e.unref(P.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:ce=>E(J)},[e.createVNode(e.unref(P.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",$(J)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,Rp)):e.createCommentVNode("",!0),e.createElementVNode("div",Op,e.toDisplayString(`${d.value} (${J+1})`),1)]),e.createElementVNode("div",zp,[e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.duplicateTitle,onClick:ce=>B(J),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(P.Copy),{class:"h-4 w-4"})],8,Pp),e.createElementVNode("button",{type:"button",class:"p-2 text-gray-400 hover:text-gray-600 hover:bg-gray-50 rounded-lg transition-all disabled:opacity-40",title:t.removeTitle,onClick:ce=>L(J),disabled:C.value,draggable:"false"},[e.createVNode(e.unref(P.Trash2),{class:"h-4 w-4"})],8,jp)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(rt,{class:"vs-dataform__form",schema:h.value,layout:"inline",navigation:!1,values:n.value[J],"onUpdate:values":ce=>n.value[J]=ce,"form-id":r.value[J],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!$(J)]])],42,Lp))),128)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",Up,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"flex items-center gap-2 text-gray-600 hover:text-gray-900 font-medium transition-colors text-sm",onClick:Y,disabled:!g.value},[e.createVNode(e.unref(P.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Hp)]))}}),[["__scopeId","data-v-cfbcfed8"]]),_n="__vs_form_monaco_loader__",Tt="__vs_form_monaco_script_loader__",Cn="__vs_form_monaco_editor_loader__",Yn=e.defineComponent({__name:"vs-input-monaco",props:e.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:t}){const n=o,r=e.useModel(o,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof n.height=="number"?`${n.height}px`:n.height||"280px");let s=null,i=null,c=!1;const d=()=>{if(i)return Promise.resolve(i);if(typeof window>"u")return Promise.resolve(null);const m=window;if(m.monaco?.editor?.create)return i=m.monaco,Promise.resolve(i);if(m[_n])return m[_n];const g=(async()=>{const C=V=>{if(Array.from(document.styleSheets||[]).some(L=>L?.href?.includes(V)))return;const Y=document.createElement("link");Y.rel="stylesheet",Y.href=V,document.head.appendChild(Y)},k=V=>{if(m[Tt]?.[V])return m[Tt][V];m[Tt]||={};const R=Array.from(document.scripts).find(Y=>Y.src===V);return R?(m[Tt][V]=new Promise((Y,L)=>{const B=R.readyState;if(R.dataset.loaded==="true"||B==="loaded"||B==="complete"){Y();return}R.addEventListener("load",()=>{R.dataset.loaded="true",Y()},{once:!0}),R.addEventListener("error",S=>L(S),{once:!0})}),m[Tt][V]):(m[Tt][V]=new Promise((Y,L)=>{const B=document.createElement("script");B.src=V,B.async=!0,B.onload=()=>{B.dataset.loaded="true",Y()},B.onerror=S=>L(S),document.body.appendChild(B)}),m[Tt][V])},w="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return C(`${w}/editor/editor.main.min.css`),await k(`${w}/loader.min.js`),m[Cn]||(m[Cn]=new Promise((V,R)=>{window.require.config({paths:{vs:w}}),window.require(["vs/editor/editor.main"],()=>{i=window.monaco,m.monaco=i,V(i)},Y=>R(Y))}).catch(V=>{throw delete m[Cn],V})),m[Cn]})().catch(C=>{throw delete m[_n],C});return m[_n]=g,g},u=()=>{!l.value||!i||(s&&(s.dispose(),s=null),s=i.editor.create(l.value,{value:r.value||"",language:n.syntax,theme:n.theme,automaticLayout:!0,minimap:{enabled:!!n.minimap},readOnly:!!n.disabled}),s.onDidChangeModelContent(()=>{c||(r.value=s.getValue())}))},p=()=>{s?.focus()},h=()=>s,x=()=>i;return e.watch(()=>r.value,m=>{if(!s)return;const b=s.getValue();m!==b&&(c=!0,s.setValue(m||""),c=!1)}),e.watch(()=>n.syntax,m=>{!s||!i||i.editor.setModelLanguage(s.getModel(),m||"xml")}),e.watch(()=>n.theme,m=>{i&&i.editor.setTheme(m||"vs-light")}),e.watch(()=>n.disabled,m=>{s&&s.updateOptions({readOnly:!!m})}),e.watch(()=>n.minimap,m=>{s&&s.updateOptions({minimap:{enabled:!!m}})}),e.onMounted(async()=>{try{const m=await d();if(!m||!m.editor)return;i=m,u()}catch(m){console.error("Failed to load Monaco editor",m)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:p,getEditor:h,getMonaco:x}),(m,b)=>(e.openBlock(),e.createElementBlock("div",{class:"w-full",style:e.normalizeStyle({height:a.value})},[e.createElementVNode("div",{ref_key:"editorContainer",ref:l,class:"w-full h-full overflow-hidden border border-[#CFD9E0] rounded"},null,512)],4))}}),er={VsInputText:Ot,VsInputRadio:Hn,VsInputInlineSelect:mn,"vs-input-text":Ot,"vs-input-password":gl,"vs-input-textarea":To,"vs-input-richtext":Lo,"vs-input-mask":cn,"vs-input-number":Co,"vs-input-radio":Hn,"vs-input-select":Wn,"vs-input-inline-select":mn,"inline-select":mn,"vs-input-switcher":zn,"vs-input-static":Pn,"vs-input-container":Fo,"vs-input-date":pa,"vs-input-checkbox":Bo,"vs-input-file":$o,"vs-input-file2":Kn,file2:Kn,File2:Kn,"vs-input-html":Pn,"vs-input-email":jn,"vs-input-tel":Un,"vs-input-datatable":Io,"vs-input-map":Ho,"vs-input-file-list":No,"vs-input-tags":qo,"vs-input-slug":Ko,"vs-input-codegen":Wo,"vs-input-key-value":Go,"vs-input-text[]":Yo,"vs-input-range":Zo,"vs-input-color":Xo,"vs-input-native-select":Wn,VsInputArraySelect:wn,"vs-input-array":Jo,"vs-input-array-select":wn,"array-select":wn,"vs-input-address":Qo,"vs-input-datalist":Dp,"vs-input-dataform":qp,"vs-input-monaco":Yn},Kp=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(o){const t=o,n=e.inject("values");async function r(){try{if(!t.api)return;const l=t.api.replace("{{value}}",t.value),a=await fetch(l);if(!a.ok){he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!n)return;for(const[i,c]of Object.entries(t.set))n.value[i]=s.result[c]}catch(l){console.error(t.error,l)}}return(l,a)=>(e.openBlock(),e.createElementBlock("button",{onClick:r,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},e.toDisplayString(l.button),1))}}),Wp={class:"flex flex-col gap-1 w-full"},Gp={class:"w-full"},Yp=["disabled"],Xp=["innerHTML"],Zp=2e3,Jp=10,tr=e.defineComponent({__name:"vs-compact-form-layout",props:e.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:e.mergeModels(["value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),l=t,a=e.computed(()=>ml[`${n.layout}`]),s=["label","placeholder","info","description","text","html"],i=e.ref(S()),c=e.computed(()=>Y(n.item,i.value)),d=e.computed(()=>er?.[`vs-input-${n.item.type}`]),u=e.inject("field-props"),p=e.computed(()=>{const E=e.unref(d);if(!E)return new Set;const N=E.props??E.__vccOpts?.props;if(!N)return new Set;const I=Array.isArray(N)?N:Object.keys(N);return new Set(I)}),x=[...["min","max","step"],"api","set","mask"],m=e.computed(()=>{const E={...c.value??{}},N=n.item?.name;N&&u?.value?.[N]&&Object.assign(E,u.value[N]);const I=p.value;let v;return I.size?v=Object.fromEntries(Object.entries(E).filter(([M])=>I.has(M))):v=E,x.forEach(M=>{const D=E[M];D!=null&&(v[M]=D)}),v}),b=E=>{const N=typeof E=="object"&&E!==null?E:{value:E};l("value-selected",{...N,name:N.name??n.item?.name})},g=/{{\s*([^}]+?)\s*}}/g,C=e.inject("values"),k=e.ref(!1),w=e.computed(()=>{const E=n.item?.api,N=n.item?.type?.toLowerCase();return typeof E=="string"&&E.trim().length>0&&(N==="text"||N==="mask")});function V(E,N){if(!(E==null||!N))return N.split(".").reduce((I,v)=>I?.[v.trim()],E)}async function R(){const E=String(r.value??"").trim();if(!E)return;const N=(n.item?.api??"").trim();if(!N)return;const I=N.replace(g,(v,M)=>M.trim()==="value"?encodeURIComponent(E):"");k.value=!0;try{let v=await fetch(I),M=0;for(;v.status===202&&M<Jp;)M+=1,await new Promise(re=>{setTimeout(re,Zp)}),v=await fetch(I);if(v.status===202){he.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!v.ok){he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const D=await v.json(),K=D?.result!==void 0?D.result:D,W=n.item?.set;if(!W||!C?.value)return;const X=n.item?.name;Object.entries(W).forEach(([re,Ce])=>{if(!re)return;let ge=Ce;X&&ge.startsWith(`${X}.`)&&(ge=ge.slice(X.length+1));const te=V(K,ge);C.value[re]=te??null})}catch(v){console.error("API lookup error:",v),he.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{k.value=!1}}e.onMounted(()=>{i.value=S(),window.addEventListener("storage",$)}),e.onUnmounted(()=>{window.removeEventListener("storage",$)});function Y(E,N){if(!E)return{};const I={...E};return s.forEach(v=>{const M=B(E,v,N);M!=null&&(I[v]=M)}),Array.isArray(E.options)&&(I.options=E.options.map(v=>L(v,N))),I}function L(E,N){if(!E)return E;const I={...E},v=B(E,"label",N),M=B(E,"text",N);return v!=null&&(I.label=v),M!=null?I.text=M:v!=null&&(I.text=v),I}function B(E,N,I){const v=`${N}:${I}`;if(E?.[v]!=null)return E[v];if(N==="label"&&E?.[I]!=null)return E[I];if(E?.[N]!=null)return E[N];if(N==="label"){if(E?.ua!=null)return E.ua;if(E?.en!=null)return E.en}if(N==="text"||N==="html"){if(E?.ua!=null)return E.ua;if(E?.en!=null)return E.en}return null}function S(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function $(){i.value=S()}return(E,N)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:c.value.ua,error:n.error||"",item:c.value,columns:n.columns,label:c.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${n.item.type}-component`])},[e.createElementVNode("div",Wp,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":w.value}])},[e.createElementVNode("div",Gp,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),e.mergeProps(m.value,{modelValue:r.value,"onUpdate:modelValue":N[0]||(N[0]=I=>r.value=I),onValueSelected:b}),null,16,["modelValue"]))]),w.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px] shrink-0",disabled:k.value||!r.value?.toString().trim(),onClick:R},[k.value?(e.openBlock(),e.createBlock(e.unref(P.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(P.Search),{key:0,class:"h-4 w-4"}))],8,Yp)):e.createCommentVNode("",!0)],2),c.value.description&&n.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:c.value.description},null,8,Xp)):e.createCommentVNode("",!0)]),c.value.behavior?.api&&c.value.behavior?.button?(e.openBlock(),e.createBlock(Kp,e.mergeProps({key:0},c.value.behavior,{value:r.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),Qp={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},ef={class:"vs-compact-form-navigation__rail mt-[6px]"},tf=["onClick"],nf=xe(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(o,{expose:t}){const n=o,r=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!n.enabled),i=e.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),c=e.computed(()=>{const E=n.width;if(E==null)return{};const N=typeof E=="number"?`${E}px`:`${E}`;return{width:N,minWidth:N}});let d=null,u=0,p=0,h=null,x=null,m=null;const b=()=>S(),g=()=>k();e.watch(()=>n.target,async E=>{if(Y(),!E){h=null,r.value=[],l.value="";return}h=E,s.value&&(await e.nextTick(),R(E),k())},{immediate:!0}),e.watch(()=>n.scrollContainer,E=>{if(!s.value){x=E??null;return}C(E??null),e.nextTick(()=>k())},{immediate:!0}),e.onMounted(()=>{n.scrollContainer||C(null),k()}),e.onBeforeUnmount(()=>{Y(),C(null,!0),h=null,typeof window<"u"&&(u&&window.cancelAnimationFrame(u),p&&window.cancelAnimationFrame(p))});function C(E,N=!1){if(m&&(m(),m=null),N){x=null;return}if(x=E??null,typeof window>"u")return;const I=E??window,v=window;I.addEventListener("scroll",b,{passive:!0}),v.addEventListener("resize",g),m=()=>{I.removeEventListener("scroll",b),v.removeEventListener("resize",g)}}function k(){if(!s.value||!h)return;u&&typeof window<"u"&&window.cancelAnimationFrame(u);const E=()=>{w(),u=0};typeof window>"u"?E():u=window.requestAnimationFrame(E)}function w(){if(!s.value||!h)return;const E=Array.from(h.querySelectorAll("h1, h2")),N=new Set,I=[];E.forEach((v,M)=>{const D=v.textContent?.trim()??"";if(!D)return;let K=(v.getAttribute("id")??"").trim();K||(K=V(D)||`heading-${M+1}`);let W=K,X=1;for(;N.has(W);)W=`${K}-${X+=1}`;v.id!==W&&Object.assign(v,{id:W}),N.add(W),I.push({id:W,text:D,level:v.tagName.toLowerCase()==="h1"?1:2})}),r.value=I,I.length||(l.value=""),B()}function V(E){return E.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function R(E){!E||!s.value||typeof MutationObserver>"u"||(Y(),d=new MutationObserver(()=>k()),d.observe(E,{childList:!0,subtree:!0}))}function Y(){d&&(d.disconnect(),d=null)}function L(E){const N=x;if(!N)return typeof window>"u"?E.offsetTop:E.getBoundingClientRect().top+window.scrollY;const I=E.getBoundingClientRect(),v=N.getBoundingClientRect();return I.top-v.top+N.scrollTop}function B(){if(!s.value||!r.value.length)return;const E=x,N=(E?E.scrollTop:null)||(typeof window<"u"?window.scrollY:0),I=(E?E.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),v=N+I;let M=null;for(let K=0;K<r.value.length;K+=1){const W=r.value[K],X=document.getElementById(W.id);if(X){const re=L(X);re+X.offsetHeight>N&&re<v&&(M=W.id)}}!M&&a.value&&(M=a.value),M&&(a.value=M);const D=E?E.scrollHeight-E.clientHeight:document.documentElement.scrollHeight-window.innerHeight;N+5>=D&&(M=r.value[r.value.length-1].id),M&&(l.value=M)}function S(){s.value&&(p&&window.cancelAnimationFrame(p),p=window.requestAnimationFrame(()=>{B(),p=0}))}function $(E){if(!s.value)return;const N=document.getElementById(E);if(!N)return;const I=x,v=Math.max(0,L(N));I?I.scrollTo({top:v,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:v,behavior:"smooth"})}return t({refresh:k}),(E,N)=>s.value&&r.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(i.value),style:e.normalizeStyle(c.value)},[e.createElementVNode("h2",Qp,e.toDisplayString(E.title),1),e.createElementVNode("div",ef,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,I=>(e.openBlock(),e.createElementBlock("div",{key:I.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",I.level===2?"vs-compact-form-navigation__item--nested":"",I.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:v=>$(I.id),class:e.normalizeClass(["vs-compact-form-navigation__button flex gap-x-3 py-[6px] pr-3 text-sm duration-200 hover:text-gray-800",I.level===2?"pl-[15px]":"pl-[18px]",I.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(I.text),1)],10,tf)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),pt={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:o=>`Мінімальна довжина — ${o} символів`,maxlength:o=>`Максимальна довжина — ${o} символів`,min:o=>`Значення має бути не менше ${o}`,max:o=>`Значення має бути не більше ${o}`},of=o=>typeof o=="string"?o.trim()?!1:pt.required:Array.isArray(o)?o.map(n=>typeof n=="string"?n.trim():n).filter(n=>n!=null&&n!=="").length?!1:pt.required:typeof o=="number"?Number?.isNaN(o)?pt?.required:!1:o?!1:pt.required,rf=o=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return o?t.test(o)?!1:pt.email:!1},lf=o=>{const t=/^\+[1-9]\d{1,14}$/;return o?t.test(o)?!1:pt.tel:!1},nr=o=>o==null?0:typeof o=="string"?o.trim().length:Array.isArray(o)?o.length:typeof o=="number"?o.toString().length:String(o).length,af=(o,t)=>{if(o==null)return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&nr(o)<n?t?.message||pt.minlength(n):!1},sf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&nr(o)>n?t?.message||pt.maxlength(n):!1},or=o=>{if(typeof o=="number")return o;if(typeof o=="string"){const t=o.trim().replace(",",".");return t?Number(t):Number.NaN}return Number(o)},cf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=or(o);return Number.isFinite(r)&&r<n?t?.message||pt.min(n):!1},df=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=or(o);return Number.isFinite(r)&&r>n?t?.message||pt.max(n):!1},uf=(o,t)=>{const n=t.pattern??t.regexp,r=typeof n=="string"?new RegExp(n):n;if(Array.isArray(o)){const l=o.filter(Boolean);return l.length===0||l.every(a=>r.test(a))?!1:t.message}return!r.test(o)&&o?t.message:!1},pf=(o,t)=>!1,ff=(o,t)=>{switch(typeof t=="string"?t:t.type){case"required":return of(o);case"email":return rf(o);case"tel":return lf(o);case"regexp":return uf(o,t);case"minlength":return af(o,t);case"maxlength":return sf(o,t);case"min":return cf(o,t);case"max":return df(o,t);case"custom":return pf();default:return!1}},mf={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file",inlineselect:"inline-select"};function rr(o){const t=o?.toLowerCase();return mf[t]||t}function Xn(o,t=!1){if(Array.isArray(o)){const r=[];return o.forEach(l=>{const a={...l};a.name=(l.name||l.id||l.key||"").toString(),a.type=rr(l.type),a.label=l.label||l.ua,a.rules=l.rules||l.validators,a.type==="email"&&!a.rules&&(a.rules=["email"]),l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=Xn(a.schema,a.disabled)),r.push(a)}),r}const n=[];return Object.entries(o).forEach(r=>{const l={name:r[0],...r[1],type:rr(r[1].type),label:r[1].label||r[1].ua,rules:r[1].rules||r[1].validators,disabled:r[1].disabled??t};l.type==="email"&&!l.rules&&(l.rules=["email"]),r[1].type?.includes("list")&&(l.multiple=!0),!l.api&&r[1].data&&(l.api=`/api/suggest/${r[1].data}`),Array.isArray(l.schema)&&(l.schema=Xn(l.schema,l.disabled)),n.push(l)}),n}function hf(o,t,n=!1){const r=e.computed(()=>Xn((Array.isArray(t),t),typeof n=="boolean"?n:n.value)),l=e.ref({});function a(d){const u=d?.conditions;if(!u)return!0;const p=Array.isArray(u)?u[0]:u,h=o?.value?.[p];return Ao(h,u)}const s=(d=r.value,u=!0)=>(d.forEach(p=>{const h=[],x=Number(p?.minlength),m=Number(p?.maxlength),b=Number(p?.min),g=Number(p?.max);!Number.isNaN(x)&&Number.isFinite(x)&&h.push({type:"minlength",value:x}),!Number.isNaN(m)&&Number.isFinite(m)&&h.push({type:"maxlength",value:m}),!Number.isNaN(b)&&Number.isFinite(b)&&h.push({type:"min",value:b}),!Number.isNaN(g)&&Number.isFinite(g)&&h.push({type:"max",value:g});const C=[...h,...p.rules||[]];if(C.length){if(!a(p)){delete l.value[p.name];return}let k=!1,w=null;C.forEach(V=>{const R=ff(o.value[p.name],V);R&&(k=!0,!w&&typeof R=="string"&&(w=R))}),k&&w?l.value[p.name]=w:delete l.value[p.name]}p.schema&&s(p.schema,!1)}),u&&Object.values(l.value).some(Boolean)?l.value:null),i=e.computed(()=>r.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{o.value={},l.value={}},visibleSchema:i}}const gf={class:"flex w-full h-full min-h-0 gap-6"},yf={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},rt=e.defineComponent({__name:"vs-compact-form",props:e.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:e.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(o,{expose:t,emit:n}){const r=n,l=o,a=e.useModel(o,"form"),s=e.useModel(o,"modelValue"),i=e.useModel(o,"values"),c=e.computed({get:()=>i.value??s.value,set:v=>{s.value=v,i.value=v}}),{errors:d,validate:u,reset:p,visibleSchema:h}=hf(c,l.schema,e.toRef(l,"disabled")),x=e.ref(null),m=e.ref(null),b=e.ref({}),g=e.computed(()=>l.navigation),C=e.computed(()=>l.navWidth),k=e.computed(()=>l.style?.columns),w=Object.freeze({container:12,label:3}),V=e.computed(()=>l.columns??k.value??w),R=e.computed(()=>l.columns!=null||k.value!=null),Y=e.computed(()=>R.value?"horizontal":l.layout),L=v=>v?.columns?"horizontal":Y.value,B=v=>v?.columns??V.value,S=()=>{!l.formId&&c.value&&delete c.value.id,r("update:modelValue",c.value),u(),r("handle-submit",c.value)},$=v=>{r("value-selected",v)};t({validate:u,reset:p,errors:d}),e.onMounted(()=>{a.value={value:c.value,errors:d.value,reset:p,validate:u,formId:l.formId}});function E(v,M){if(v===M)return!0;if(typeof v!="object"||typeof M!="object"||!v||!M)return!1;const D=Object.keys(v),K=Object.keys(M);return D.length!==K.length?!1:D.every(W=>v[W]===M[W])}function N(v){return Array.isArray(v)?[...v]:v&&typeof v=="object"?{...v}:v}function I(v){Array.isArray(v)&&v.forEach(M=>{if(!M)return;const D=M.name,K=M.default!==void 0;D&&K&&c.value[D]===void 0&&(c.value[D]=N(M.default)),Array.isArray(M.schema)&&I(M.schema)})}return e.watch(h,v=>{I(v)},{immediate:!0,deep:!0}),e.provide("form",a),e.provide("values",c),e.provide("field-props",b),(v,M)=>(e.openBlock(),e.createElementBlock("div",gf,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:m},[e.createElementVNode("form",{ref_key:"formRef",ref:x,onSubmit:e.withModifiers(S,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",Y.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(h),(D,K)=>(e.openBlock(),e.createElementBlock("div",{key:D.name,class:e.normalizeClass(L(D)==="horizontal"?"col-span-12":`col-span-${D.col||12}`)},[e.createVNode(tr,{style:e.normalizeStyle(v.style),item:D,layout:L(D),columns:B(D),"model-value":c.value[D.name],"onUpdate:modelValue":W=>{if(D.name==="id"&&!v.formId)return;const X=c.value[D.name];E(X,W)||(c.value[D.name]=W)},error:e.unref(d)[D.name],onValueSelected:$},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),L(D)==="settings"&&K+1!==e.unref(h).length?(e.openBlock(),e.createElementBlock("div",yf)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode(nf,{target:x.value,"scroll-container":m.value,enabled:g.value,width:C.value},null,8,["target","scroll-container","enabled","width"])]))}}),bf={class:"relative"},kf={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},xf={class:"m-[10px] fixed top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 min-h-0 h-fit max-h-[80vh] overflow-hidden opacity-1 flex flex-col bg-white dark:bg-[#1A1A1A] border dark:border-[#454545] pointer-events-auto shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-xl lg:w-7/12 w-11/12"},wf={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},_f={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Cf={class:"p-4 mim-h-0 h-full overflow-auto"},lr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(o,{emit:t}){const n=o,r=t,l=e.ref(n.schema),a=e.ref(n.defaultValue?JSON.parse(JSON.stringify(n.defaultValue)):{}),s=e.ref({}),i=e.ref(n.token||""),c=e.ref(n.token||""),d=e.ref(n.mode),u=()=>{const g=n.method?.trim().toUpperCase();return g==="GET"||g==="POST"||g==="PUT"?g:d.value==="add"?"POST":"PUT"},p=()=>{he.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},h=g=>{const C={};g.id!==void 0&&g.id!==null&&(C.id=g.id,c.value=g.id.toString()),g.obj&&typeof g.obj=="object"&&Object.assign(C,g.obj),Object.keys(C).length&&(a.value={...a.value,...C})},x=async g=>{if(console.log(g),g.ok){await g.json().catch(()=>({})),p(),r("save",a.value);return}const C=await g.json().catch(()=>({})),k=C.message||C.error;if(g.status===400){he.notify({type:"warning",title:"Помилка валідації",message:k||"Некоректні дані (400)"});return}if(g.status===500){he.notify({type:"error",title:"Серверна помилка",message:k||"Виникла помилка на сервері (500)"});return}he.notify({type:"error",title:"Помилка",message:`Статус: ${g.status}`})};async function m(){const g=s.value.validate();if(g){he.notify({type:"warning",title:"Помилка валідації",message:Object.entries(g).map(([k,w])=>`${k}: ${w}`).join(`
5
5
  `)});return}d.value==="add"&&a.value&&delete a.value.id;const C=n.api?.trim();if(C){const k=u();try{const w=await fetch(C,{method:k,headers:k==="GET"?void 0:{"Content-Type":"application/json"},body:k==="GET"?void 0:JSON.stringify(a.value)});await x(w)}catch(w){he.notify({type:"error",title:"Помилка з’єднання",message:w.message||"Не вдалося виконати запит"})}return}if(i.value)try{const k=await fetch(`/api/table/${i.value}`,{method:d.value==="add"?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.value)});await x(k)}catch(k){he.notify({type:"error",title:"Помилка з’єднання",message:k.message||"Не вдалося виконати запит"})}else r("edit",a.value),b()}function b(){r("close")}return e.onMounted(async()=>{try{if(n.form&&!n.schema){const g=await fetch(`/api/template/form/${n.form}`);if(!g.ok){he.notify({type:g.status>=400&&g.status<500?"warning":"error",title:"Error",message:`Error code: ${g.status}`});return}const C=await g.json();l.value=C.schema,C.id&&(c.value=C.id),C.token&&(i.value=C.token,c.value||(c.value=C.token))}else if(n.token&&!n.defaultValue){i.value=n.token;const g=await fetch(`/api/form/${i.value}`);if(!g.ok){he.notify({type:g.status>=400&&g.status<500?"warning":"error",title:"Error",message:`Error code: ${g.status}`});return}const C=await g.json();l.value=C.schema,C.data?a.value=C.data:d.value="add",h({id:C.id,obj:C.obj})}}catch(g){he.notify({type:"error",title:"Error",message:g.message||"Unexpected error"}),console.error(g)}}),(g,C)=>(e.openBlock(),e.createElementBlock("div",bf,[e.createElementVNode("div",kf,[e.createElementVNode("div",xf,[e.createElementVNode("div",wf,[e.createElementVNode("h3",_f,e.toDisplayString(d.value==="add"?"Додати":"Змінити"),1),e.createElementVNode("button",{onClick:b,type:"button",class:"size-8 inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent bg-gray-100 text-gray-800 hover:bg-gray-200 focus:outline-none focus:bg-gray-200 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:hover:bg-neutral-600 dark:text-neutral-400 dark:focus:bg-neutral-600"},[C[2]||(C[2]=e.createElementVNode("span",{class:"sr-only"},"Close",-1)),e.createVNode(e.unref(P.X),{class:"h-4 w-4 flex-shrink-0"})])]),e.createElementVNode("div",Cf,[l.value?(e.openBlock(),e.createBlock(rt,{key:0,schema:l.value,values:a.value,"onUpdate:values":C[0]||(C[0]=k=>a.value=k),form:s.value,"onUpdate:form":C[1]||(C[1]=k=>s.value=k),formId:c.value},null,8,["schema","values","form","formId"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"vs-form__head mr-5 mb-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},[e.createElementVNode("button",{type:"button",onClick:b,class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:m,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])])])]))}}),vf=1440*60*1e3,Ef=["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"],Bf=["січ","лют","бер","квіт","трав","черв","лип","серп","вер","жовт","лист","груд"],Vf=["нд","пн","вт","ср","чт","пт","сб"];function Pe(o){return o instanceof Date&&!Number.isNaN(o.getTime())}const zt=o=>new Date(o.getTime());function Lt(o){const t=zt(o);return t.setHours(0,0,0,0),t}function qt(o){const t=zt(o);return t.setHours(23,59,59,999),t}function Zn(o){return Lt(new Date(o.getFullYear(),o.getMonth(),1))}function Jn(o){return qt(new Date(o.getFullYear(),o.getMonth()+1,0))}function Qn(o,t){const n=new Date(o),r=n.getDate();n.setDate(1),n.setMonth(n.getMonth()+t);const l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return n.setDate(Math.min(r,l)),n}function Sf(o,t){return Qn(o,-1)}function vn(o,t){const n=new Date(o);return n.setFullYear(n.getFullYear()+t),n}function ar(o,t){return vn(o,-t)}function sr(o){return Lt(new Date(o.getFullYear(),0,1))}function ir(o){return qt(new Date(o.getFullYear(),11,31))}function $f(o){const t=Math.floor(o.getFullYear()/10)*10;return Lt(new Date(t,0,1))}function Nf(o){const t=Math.floor(o.getFullYear()/10)*10+9;return qt(new Date(t,11,31))}const ct=o=>o.getFullYear(),En=o=>Math.floor(o.getFullYear()/10)*10;function Af(o){const t=[];let n=Lt(o.start);const r=Lt(o.end);for(;n<=r;)t.push(zt(n)),n=new Date(n.getTime()+vf);return t}function Ff(o){const t=[];let n=Zn(o.start);const r=Jn(o.end);for(;n<=r;)t.push(zt(n)),n=Qn(n,1);return t}function Mf(o){const t=[];let n=sr(o.start);const r=ir(o.end);for(;n<=r;)t.push(zt(n)),n=vn(n,1);return t}function eo(o,t=1){const n=Lt(o),r=(n.getDay()-t+7)%7;return n.setDate(n.getDate()-r),n}function Df(o,t=1){const n=eo(o,t);return n.setDate(n.getDate()+6),qt(n)}function Tf(o,t,n=0){const r=eo(o,n),l=(t-n+7)%7;return r.setDate(r.getDate()+l),r}const Bn=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth()&&o.getDate()===t.getDate(),to=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth(),cr=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear(),dr=(o,t)=>!!o&&!!t&&Bn(o,t)&&o.getHours()===t.getHours(),Lf=(o,t)=>!!o&&!!t&&dr(o,t)&&o.getMinutes()===t.getMinutes();function If(o,t){const n=o.getTime();return n>=t.start.getTime()&&n<=t.end.getTime()}const Kt=(o,t)=>!!o&&!!t&&o.getTime()<t.getTime(),Wt=(o,t)=>!!o&&!!t&&o.getTime()>t.getTime();function Rf(o){const t=o.filter(n=>Pe(n));if(t.length)return t.reduce((n,r)=>n.getTime()>=r.getTime()?n:r)}function Of(o){const t=o.filter(n=>Pe(n));if(t.length)return t.reduce((n,r)=>n.getTime()<=r.getTime()?n:r)}function ur(o,t){const n=zt(o);return typeof t.year=="number"&&n.setFullYear(t.year),typeof t.month=="number"&&n.setMonth(t.month),typeof t.date=="number"&&n.setDate(t.date),typeof t.hours=="number"&&n.setHours(t.hours),typeof t.minutes=="number"&&n.setMinutes(t.minutes),typeof t.seconds=="number"&&n.setSeconds(t.seconds),typeof t.milliseconds=="number"&&n.setMilliseconds(t.milliseconds),n}const Vn=(o,t=2)=>String(o).padStart(t,"0");function pr(o,t){return t==="wide"?Ef[o]:Bf[o]}function zf(o){return Vf[o]}const Pf=[{token:"LLLL",format:o=>pr(o.getMonth(),"wide")},{token:"LLL",format:o=>pr(o.getMonth(),"abbreviated")},{token:"EE",format:o=>zf(o.getDay())},{token:"yyyy",format:o=>String(o.getFullYear())},{token:"MM",format:o=>Vn(o.getMonth()+1)},{token:"dd",format:o=>Vn(o.getDate())},{token:"HH",format:o=>Vn(o.getHours())},{token:"mm",format:o=>Vn(o.getMinutes())}];function Sn(o,t){if(!Pe(o))return"";let n="",r=0;for(;r<t.length;){const l=Pf.find(a=>t.startsWith(a.token,r));l?(n+=l.format(o),r+=l.token.length):(n+=t[r],r+=1)}return n}const jf={"yyyy-MM-dd":/^(\d{4})-(\d{2})-(\d{2})$/,"dd.MM.yyyy":/^(\d{2})\.(\d{2})\.(\d{4})$/,"dd.MM.yyyy HH:mm":/^(\d{2})\.(\d{2})\.(\d{4}) (\d{2}):(\d{2})$/,"HH:mm":/^(\d{2}):(\d{2})$/,"MM.yyyy":/^(\d{2})\.(\d{4})$/,yyyy:/^(\d{4})$/};function fr(o,t){const n=jf[t];if(!n){const l=new Date(o);return Pe(l)?l:null}const r=o.match(n);if(!r)return null;switch(t){case"yyyy-MM-dd":{const[,l,a,s]=r,i=new Date(Number(l),Number(a)-1,Number(s));return Pe(i)?i:null}case"dd.MM.yyyy":{const[,l,a,s]=r,i=new Date(Number(s),Number(a)-1,Number(l));return Pe(i)?i:null}case"dd.MM.yyyy HH:mm":{const[,l,a,s,i,c]=r,d=new Date(Number(s),Number(a)-1,Number(l),Number(i),Number(c));return Pe(d)?d:null}case"HH:mm":{const[,l,a]=r,s=new Date;return s.setHours(Number(l),Number(a),0,0),s}case"MM.yyyy":{const[,l,a]=r;return new Date(Number(a),Number(l)-1,1)}case"yyyy":{const[,l]=r;return new Date(Number(l),0,1)}default:return null}}const Uf=["year","month","day","time","custom"],Hf=e.defineComponent({components:{ChevronLeft:P.ChevronLeft,ChevronRight:P.ChevronRight},emits:{elementClick:o=>Pe(o),left:()=>!0,right:()=>!0,heading:()=>!0},props:{headingClickable:{type:Boolean,default:!1},leftDisabled:{type:Boolean,default:!1},rightDisabled:{type:Boolean,default:!1},columnCount:{type:Number,default:7},items:{type:Array,default:()=>[]},viewMode:{type:String,required:!0,validate:o=>typeof o=="string"&&Uf.includes(o)}}}),qf={class:"v3dp__heading"},Kf=["disabled"],Wf=["disabled"],Gf={class:"v3dp__body"},Yf={class:"v3dp__subheading"},Xf={class:"v3dp__elements"},Zf=["disabled","onClick"];function Jf(o,t,n,r,l,a){const s=e.resolveComponent("ChevronLeft"),i=e.resolveComponent("ChevronRight");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["v3dp__popout",`v3dp__popout-${o.viewMode}`]),style:e.normalizeStyle({"--popout-column-definition":`repeat(${o.columnCount}, 1fr)`}),onMousedown:t[3]||(t[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",qf,[e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__left",disabled:o.leftDisabled,onClick:t[0]||(t[0]=e.withModifiers(c=>o.$emit("left"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-left",{},()=>[e.createVNode(s,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,Kf),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.headingClickable?"button":"span"),{class:"v3dp__heading__center",onClick:t[1]||(t[1]=e.withModifiers(c=>o.$emit("heading"),["stop","prevent"]))},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"heading",{},void 0,!0)]),_:3})),e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__right",disabled:o.rightDisabled,onClick:t[2]||(t[2]=e.withModifiers(c=>o.$emit("right"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-right",{},()=>[e.createVNode(i,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,Wf)]),e.createElementVNode("div",Gf,["subheading"in o.$slots?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",Yf,[e.renderSlot(o.$slots,"subheading",{},void 0,!0)]),t[4]||(t[4]=e.createElementVNode("hr",{class:"v3dp__divider"},null,-1))],64)):e.createCommentVNode("",!0),e.createElementVNode("div",Xf,[e.renderSlot(o.$slots,"body",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,c=>(e.openBlock(),e.createElementBlock("button",{key:c.key,disabled:c.disabled,class:e.normalizeClass([{selected:c.selected,current:c.current},`v3dp__element__button__${o.viewMode}`]),onClick:e.withModifiers(d=>o.$emit("elementClick",c.value),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(c.display),1)],10,Zf))),128))],!0)])])],38)}const $n=xe(Hf,[["render",Jf],["__scopeId","data-v-9e083852"]]),Qf=e.defineComponent({components:{PickerPopup:$n},emits:{"update:pageDate":o=>Pe(o),select:o=>Pe(o)},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>$f(o.pageDate)),r=e.computed(()=>Nf(o.pageDate)),l=(p,h,x)=>!h&&!x?!0:!(h&&ct(p)<ct(h)||x&&ct(p)>ct(x)),a=e.computed(()=>Mf({start:n.value,end:r.value}).map(p=>({value:p,key:String(ct(p)),display:ct(p),selected:!!o.selected&&ct(p)===ct(o.selected),disabled:!l(p,o.lowerLimit,o.upperLimit)}))),s=e.computed(()=>{const p=ct(n.value),h=ct(r.value);return`${p} - ${h}`}),i=e.computed(()=>o.lowerLimit&&(En(o.lowerLimit)===En(o.pageDate)||Kt(o.pageDate,o.lowerLimit))),c=e.computed(()=>o.upperLimit&&(En(o.upperLimit)===En(o.pageDate)||Wt(o.pageDate,o.upperLimit)));return{years:a,heading:s,leftDisabled:i,rightDisabled:c,previousPage:()=>t("update:pageDate",ar(o.pageDate,10)),nextPage:()=>t("update:pageDate",vn(o.pageDate,10))}}});function em(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{columnCount:3,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.years,viewMode:"year",onLeft:o.previousPage,onRight:o.nextPage,onElementClick:t[0]||(t[0]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const tm=xe(Qf,[["render",em]]),nm=e.defineComponent({components:{PickerPopup:$n},emits:{"update:pageDate":o=>Pe(o),select:o=>Pe(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"LLL"},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>sr(o.pageDate)),r=e.computed(()=>ir(o.pageDate)),l=e.computed(()=>h=>Sn(h,o.format)),a=(h,x,m)=>!x&&!m?!0:!(x&&Kt(h,Zn(x))||m&&Wt(h,Jn(m))),s=e.computed(()=>Ff({start:n.value,end:r.value}).map(h=>({value:h,display:l.value(h),key:l.value(h),selected:!!o.selected&&to(o.selected,h),disabled:!a(h,o.lowerLimit,o.upperLimit)}))),i=e.computed(()=>ct(n.value)),c=e.computed(()=>o.lowerLimit&&(cr(o.lowerLimit,o.pageDate)||Kt(o.pageDate,o.lowerLimit))),d=e.computed(()=>o.upperLimit&&(cr(o.upperLimit,o.pageDate)||Wt(o.pageDate,o.upperLimit)));return{months:s,heading:i,leftDisabled:c,rightDisabled:d,previousPage:()=>t("update:pageDate",ar(o.pageDate,1)),nextPage:()=>t("update:pageDate",vn(o.pageDate,1))}}});function om(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:3,items:o.months,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,viewMode:"month",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=i=>o.$emit("back")),onElementClick:t[1]||(t[1]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["items","leftDisabled","rightDisabled","onLeft","onRight"])}const rm=xe(nm,[["render",om]]),lm=e.defineComponent({components:{PickerPopup:$n},emits:{"update:pageDate":o=>Pe(o),select:o=>Pe(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"dd"},headingFormat:{type:String,required:!1,default:"LLLL yyyy"},weekdayFormat:{type:String,required:!1,default:"EE"},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>typeof o=="number"&&Number.isInteger(o)&&o>=0&&o<=6},customWeekdays:{type:Array,required:!1},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1}},setup(o,{emit:t}){const n=e.computed(()=>g=>C=>Sn(C,g)),r=e.computed(()=>Zn(o.pageDate)),l=e.computed(()=>Jn(o.pageDate)),a=e.computed(()=>({start:r.value,end:l.value})),s=e.computed(()=>({start:eo(r.value,o.weekStartsOn),end:Df(l.value,o.weekStartsOn)})),i=e.computed(()=>o.customWeekdays?.length===7?o.customWeekdays:null),c=e.computed(()=>{const g=o.weekStartsOn,C=i.value;if(C)return Array.from({length:7}).map((w,V)=>C[(g+V)%7]);const k=n.value(o.weekdayFormat);return Array.from(Array(7)).map((w,V)=>(g+V)%7).map(w=>Tf(new Date,w,o.weekStartsOn)).map(k)}),d=(g,C,k,w)=>w?.dates?.some(V=>Bn(g,V))||w?.predicate?.(g)?!1:!C&&!k?!0:!(C&&Kt(g,Lt(C))||k&&Wt(g,qt(k))),u=e.computed(()=>{const g=new Date,C=n.value(o.format);return Af(s.value).map(k=>({value:k,display:C(k),selected:!!o.selected&&Bn(o.selected,k),current:Bn(g,k),disabled:!o.allowOutsideInterval&&!If(k,a.value)||!d(k,o.lowerLimit,o.upperLimit,o.disabledDates),key:n.value("yyyy-MM-dd")(k)}))}),p=e.computed(()=>n.value(o.headingFormat)(o.pageDate)),h=e.computed(()=>o.lowerLimit&&(to(o.lowerLimit,o.pageDate)||Kt(o.pageDate,o.lowerLimit))),x=e.computed(()=>o.upperLimit&&(to(o.upperLimit,o.pageDate)||Wt(o.pageDate,o.upperLimit)));return{weekDays:c,days:u,heading:p,leftDisabled:h,rightDisabled:x,previousPage:()=>t("update:pageDate",Sf(o.pageDate)),nextPage:()=>t("update:pageDate",Qn(o.pageDate,1))}}});function am(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.days,viewMode:"day",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=i=>o.$emit("back")),onElementClick:t[1]||(t[1]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),subheading:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.weekDays,(i,c)=>(e.openBlock(),e.createElementBlock("span",{key:i,class:e.normalizeClass(`v3dp__subheading__weekday__${c}`)},e.toDisplayString(i),3))),128))]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const sm=xe(lm,[["render",am]]);function mr(o,t){const n=o.getBoundingClientRect(),r={height:o.clientHeight,width:o.clientWidth},l=t.getBoundingClientRect();if(!(l.top>=n.top&&l.bottom<=n.top+r.height)){const s=l.top-n.top,i=l.bottom-n.bottom;Math.abs(s)<Math.abs(i)?o.scrollTop+=s:o.scrollTop+=i}}const im=e.defineComponent({components:{PickerPopup:$n},emits:{select:o=>Pe(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},visible:{type:Boolean,required:!0},disabledTime:{type:Object,required:!1}},setup(o,{emit:t}){const n=e.ref(null),r=e.ref(null),l=e.computed(()=>o.pageDate??o.selected),a=e.ref(l.value.getHours()),s=e.ref(l.value.getMinutes());e.watch(()=>o.selected,x=>{let m=0,b=0;x&&(m=x.getHours(),b=x.getMinutes()),a.value=m,s.value=b});const i=e.computed(()=>[...Array(24).keys()].map(x=>({value:x,date:ur(new Date(l.value.getTime()),{hours:x,minutes:s.value,seconds:0}),selected:a.value===x,ref:e.ref(null)}))),c=e.computed(()=>[...Array(60).keys()].map(x=>({value:x,date:ur(new Date(l.value.getTime()),{hours:a.value,minutes:x,seconds:0}),selected:s.value===x,ref:e.ref(null)}))),d=x=>{s.value=x.value,t("select",x.date)},u=()=>{const x=i.value.find(b=>b.ref.value?.classList?.contains("selected")??!1),m=c.value.find(b=>b.ref.value?.classList?.contains("selected")??!1);x&&m&&(mr(n.value,x.ref.value),mr(r.value,m.ref.value))};return e.watch(()=>o.visible,x=>{x&&e.nextTick(u)}),{hoursListRef:n,minutesListRef:r,hours:a,minutes:s,hoursList:i,minutesList:c,padStartZero:x=>`0${x}`.substr(-2),selectMinutes:d,isEnabled:x=>!(o.disabledTime?.dates?.some(m=>dr(x,m)&&Lf(x,m))||o.disabledTime?.predicate?.(x)),scroll:u}}}),cm={ref:"hoursListRef",class:"v3dp__column"},dm=["disabled","onClick"],um={ref:"minutesListRef",class:"v3dp__column"},pm=["disabled","onClick"];function fm(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:2,leftDisabled:!0,rightDisabled:!0,viewMode:"time",onHeading:t[0]||(t[0]=i=>o.$emit("back"))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.padStartZero(o.hours))+":"+e.toDisplayString(o.padStartZero(o.minutes)),1)]),body:e.withCtx(()=>[e.createElementVNode("div",cm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.hoursList,i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,ref_for:!0,ref:i.ref,class:e.normalizeClass([{selected:i.selected},"v3dp__element_button__hour"]),disabled:!o.isEnabled(i.date),onClick:e.withModifiers(c=>o.hours=i.value,["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(o.padStartZero(i.value)),1)],10,dm))),128))],512),e.createElementVNode("div",um,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.minutesList,i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,ref_for:!0,ref:i.ref,class:e.normalizeClass([{selected:i.selected},"v3dp__element_button__minute"]),disabled:!o.isEnabled(i.date),onClick:e.withModifiers(c=>o.selectMinutes(i),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(o.padStartZero(i.value)),1)],10,pm))),128))],512)]),_:1})}const mm=xe(im,[["render",fm],["__scopeId","data-v-610b89e1"]]),Nn=["time","day","month","year"],hm=(o,t,n=void 0)=>{let r=n||new Date;const l=Rf([o,r]);l&&(r=l);const a=Of([t,r]);return a&&(r=a),r},gm=e.defineComponent({components:{YearPicker:tm,MonthPicker:rm,DayPicker:sm,TimePicker:mm},inheritAttrs:!1,props:{placeholder:{type:String,default:""},modelValue:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1},disabledTime:{type:Object,required:!1},upperLimit:{type:Date,required:!1},lowerLimit:{type:Date,required:!1},startingView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Nn.includes(o)},startingViewDate:{type:Date,required:!1,default:()=>new Date},dayPickerHeadingFormat:{type:String,required:!1,default:"LLLL yyyy"},monthListFormat:{type:String,required:!1,default:"LLL"},weekdayFormat:{type:String,required:!1,default:"EE"},dayFormat:{type:String,required:!1,default:"dd"},inputFormat:{type:String,required:!1,default:"yyyy-MM-dd"},weekDayNames:{type:Array,required:!1},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>[0,1,2,3,4,5,6].includes(o)},disabled:{type:Boolean,required:!1,default:!1},clearable:{type:Boolean,required:!1,default:!1},typeable:{type:Boolean,required:!1,default:!1},minimumView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Nn.includes(o)}},emits:{"update:modelValue":o=>o==null||Pe(o),decadePageChanged:o=>!0,yearPageChanged:o=>!0,monthPageChanged:o=>!0,opened:()=>!0,closed:()=>!0},setup(o,{emit:t,attrs:n}){const r=e.ref("none"),l=e.ref(o.startingViewDate),a=e.ref(null),s=e.ref(!1),i=e.ref(""),c=M=>{const D=M.replace(/[a-zA-Z]/g,"0");return/0/.test(D)?D:""},d=e.computed(()=>c(o.inputFormat));let u=null,p=null;const h=()=>{u?.destroy(),u=null},x=async()=>{if(!p){const{default:M}=await Promise.resolve().then(()=>so);p=M}return p},m=()=>{u&&u.value!==i.value&&(u.value=i.value??"")},b=async()=>{if(h(),!a.value||!d.value)return;u=(await x())(a.value,{mask:d.value,lazy:!0,overwrite:!0}),m()};e.watchEffect(()=>{if(!i.value)return;const M=fr(i.value,o.inputFormat);M&&(l.value=M)}),e.watchEffect(()=>{i.value=o.modelValue&&Pe(o.modelValue)?Sn(o.modelValue,o.inputFormat):""}),e.onMounted(()=>{d.value&&e.nextTick(()=>{b()})}),e.onBeforeUnmount(()=>{h()}),e.watch(d,M=>{M?e.nextTick(()=>{b()}):h()}),e.watch(i,()=>{m()});const g=(M="none")=>{o.disabled||(M!=="none"&&r.value==="none"&&(l.value=o.modelValue||hm(o.lowerLimit,o.upperLimit,l.value)),r.value=M,t(M!=="none"?"opened":"closed"))};e.watchEffect(()=>{o.disabled&&(r.value="none")});const C=(M,D)=>{l.value=D,M==="year"?t("decadePageChanged",D):M==="month"?t("yearPageChanged",D):M==="day"&&t("monthPageChanged",D)},k=M=>{l.value=M,o.minimumView==="year"?(g("none"),t("update:modelValue",M)):r.value="month"},w=M=>{l.value=M,o.minimumView==="month"?(g("none"),t("update:modelValue",M)):r.value="day"},V=M=>{l.value=M,o.minimumView==="day"?(g("none"),t("update:modelValue",M)):r.value="time"},R=M=>{g("none"),t("update:modelValue",M)},Y=()=>{o.clearable&&(g("none"),t("update:modelValue",null),l.value=o.startingViewDate)},L=()=>s.value=!0,B=()=>g(E.value),S=()=>{s.value=!1,g()},$=M=>{const D=M.keyCode?M.keyCode:M.which;if([27,13].includes(D)&&a.value.blur(),o.typeable){const W=fr(a.value.value,o.inputFormat);W&&i.value===Sn(W,o.inputFormat)&&(i.value=a.value.value,t("update:modelValue",W))}},E=e.computed(()=>{const M=Nn.indexOf(o.startingView),D=Nn.indexOf(o.minimumView);return M<D?o.minimumView:o.startingView}),N=M=>Object.fromEntries(Object.entries(M??{}).filter(([D,K])=>D.startsWith("--"))),I=e.computed(()=>o.weekDayNames?.length===7?o.weekDayNames:void 0);return{blur:S,focus:B,click:L,input:i,inputRef:a,pageDate:l,renderView:g,updatePageDate:C,selectYear:k,selectMonth:w,selectDay:V,selectTime:R,keyUp:$,normalizedWeekdayNames:I,viewShown:r,goBackFromTimepicker:()=>o.startingView==="time"&&o.minimumView==="time"?null:r.value="day",clearModelValue:Y,initialView:E,log:M=>console.log(M),variables:N}}}),ym={class:"v3dp__input_wrapper"},bm=["readonly","placeholder","disabled","tabindex"],km={class:"v3dp__clearable"};function xm(o,t,n,r,l,a){const s=e.resolveComponent("year-picker"),i=e.resolveComponent("month-picker"),c=e.resolveComponent("day-picker"),d=e.resolveComponent("time-picker");return e.openBlock(),e.createElementBlock("div",{class:"v3dp__datepicker",style:e.normalizeStyle(o.variables(o.$attrs.style))},[e.createElementVNode("div",ym,[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"text",ref:"inputRef",readonly:!o.typeable,"onUpdate:modelValue":t[0]||(t[0]=u=>o.input=u)},o.$attrs,{placeholder:o.placeholder,disabled:o.disabled,tabindex:o.disabled?-1:0,onKeyup:t[1]||(t[1]=(...u)=>o.keyUp&&o.keyUp(...u)),onBlur:t[2]||(t[2]=(...u)=>o.blur&&o.blur(...u)),onFocus:t[3]||(t[3]=(...u)=>o.focus&&o.focus(...u)),onClick:t[4]||(t[4]=(...u)=>o.click&&o.click(...u))}),null,16,bm),[[e.vModelText,o.input]]),e.withDirectives(e.createElementVNode("div",km,[e.renderSlot(o.$slots,"clear",{onClear:o.clearModelValue},()=>[e.createElementVNode("i",{onClick:t[5]||(t[5]=u=>o.clearModelValue())},"x")])],512),[[e.vShow,o.clearable&&o.modelValue]])]),e.withDirectives(e.createVNode(s,{pageDate:o.pageDate,"onUpdate:pageDate":t[6]||(t[6]=u=>o.updatePageDate("year",u)),selected:o.modelValue,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,onSelect:o.selectYear},null,8,["pageDate","selected","lowerLimit","upperLimit","onSelect"]),[[e.vShow,o.viewShown==="year"]]),e.withDirectives(e.createVNode(i,{pageDate:o.pageDate,"onUpdate:pageDate":t[7]||(t[7]=u=>o.updatePageDate("month",u)),selected:o.modelValue,onSelect:o.selectMonth,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,format:o.monthListFormat,onBack:t[8]||(t[8]=u=>o.viewShown="year")},null,8,["pageDate","selected","onSelect","lowerLimit","upperLimit","format"]),[[e.vShow,o.viewShown==="month"]]),e.withDirectives(e.createVNode(c,{pageDate:o.pageDate,"onUpdate:pageDate":t[9]||(t[9]=u=>o.updatePageDate("day",u)),selected:o.modelValue,weekStartsOn:o.weekStartsOn,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,headingFormat:o.dayPickerHeadingFormat,disabledDates:o.disabledDates,weekdayFormat:o.weekdayFormat,"allow-outside-interval":o.allowOutsideInterval,format:o.dayFormat,"custom-weekdays":o.normalizedWeekdayNames,onSelect:o.selectDay,onBack:t[10]||(t[10]=u=>o.viewShown="month")},null,8,["pageDate","selected","weekStartsOn","lowerLimit","upperLimit","headingFormat","disabledDates","weekdayFormat","allow-outside-interval","format","custom-weekdays","onSelect"]),[[e.vShow,o.viewShown==="day"]]),e.withDirectives(e.createVNode(d,{pageDate:o.pageDate,visible:o.viewShown==="time",selected:o.modelValue,disabledTime:o.disabledTime,onSelect:o.selectTime,onBack:o.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"]),[[e.vShow,o.viewShown==="time"]])],4)}const wm=xe(gm,[["render",xm]]),_m=xe(e.defineComponent({__name:"vs-input-date2",props:{clearable:{type:Boolean,default:!0},now:{type:Boolean},editable:{type:Boolean,default:!0},time:{type:Boolean},isInfinity:{type:Boolean},mode:{default:"date"},weekStart:{},dayNames:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,{inputClass:l}=ze(n.style),a=e.computed(()=>n.mode?n.mode:n.time?"datetime":"date"),s={date:"дд.мм.рррр",datetime:"дд.мм.рррр гг:хх",month:"мм.рррр",week:"рррр-тиждень",time:"гг:хх",year:"рррр"},i=e.computed(()=>n.placeholder||s[a.value]||""),c=e.computed(()=>["py-1.5 px-3 block w-full placeholder:text-[#767f8f] bg-white",l.value,n.customClass,{"!border-red-600":n.error}]),d=e.computed(()=>!n.modelValue&&n.now?new Date:null),u=e.computed({get:()=>w(n.modelValue??d.value,a.value)||void 0,set:D=>r("update:modelValue",V(D,a.value))}),p=["Пн","Вт","Ср","Чт","Пт","Сб","Нд"],h=e.computed(()=>{if(n.dayNames?.length)return n.dayNames.length===7?n.dayNames:p}),x=e.computed(()=>{const D=n.weekStart,K=typeof D=="string"?Number(D):D;return K===void 0||Number.isNaN(K)?1:Math.min(6,Math.max(0,K))}),m=e.computed(()=>{switch(a.value){case"time":return{startingView:"time",minimumView:"time"};case"month":return{startingView:"month",minimumView:"month"};case"year":return{startingView:"year",minimumView:"year"};case"datetime":return{startingView:"day",minimumView:"time"};default:return{startingView:"day",minimumView:"day"}}}),b={date:"dd.MM.yyyy",datetime:"dd.MM.yyyy HH:mm",month:"MM.yyyy",time:"HH:mm",week:"dd.MM.yyyy",year:"yyyy"},g=e.computed(()=>b[a.value]||"dd.MM.yyyy"),C=e.computed(()=>({"--vdp-selected-bg-color":n.style?.primaryColor||"#2563eb","--vdp-hover-bg-color":n.style?.primaryColor||"#2563eb","--vdp-selected-color":"#ffffff","--vdp-hover-color":"#ffffff","--vdp-border-radius":n.style?.size==="sm"?"6px":"8px","--vdp-elem-font-size":n.style?.size==="sm"?"0.75em":"0.85em"})),k=e.ref(!1);e.watch(()=>n.modelValue,D=>{D?k.value=!0:n.now||(k.value=!1)},{immediate:!0}),e.watchEffect(()=>{n.now&&!n.modelValue&&!k.value&&(r("update:modelValue",V(new Date,a.value)),k.value=!0)});function w(D,K){if(!D)return null;if(D instanceof Date&&!Number.isNaN(D.getTime()))return D;if(typeof D!="string")return null;switch(K){case"datetime":return B(D);case"time":return E(D);case"month":return S(D);case"year":return $(D);case"week":return N(D);case"date":default:return L(D)}}function V(D,K){if(!D)return null;const W=D instanceof Date?D:w(D,K);if(!W)return null;switch(K){case"datetime":return`${R(W)}T${Y(W)}`;case"time":return Y(W);case"month":return`${W.getFullYear()}-${M(W.getMonth()+1)}`;case"year":return`${W.getFullYear()}`;case"week":{const{year:X,week:re}=I(W);return`${X}-W${M(re)}`}case"date":default:return R(W)}}function R(D){return`${D.getFullYear()}-${M(D.getMonth()+1)}-${M(D.getDate())}`}function Y(D){return`${M(D.getHours())}:${M(D.getMinutes())}`}function L(D){const K=D.split("-");if(K.length<3)return null;const[W,X,re]=K.map(Number);return!W||!X||!re?null:new Date(W,X-1,re)}function B(D){const K=D.includes("T")?D:D.replace(" ","T"),W=new Date(K);return Number.isNaN(W.getTime())?null:W}function S(D){const[K,W]=D.split("-").map(Number);return!K||Number.isNaN(W)?null:new Date(K,(W||1)-1,1)}function $(D){const K=Number(D);return K?new Date(K,0,1):null}function E(D){const K=D.match(/^(\d{1,2}):(\d{2})$/);if(!K)return null;const[,W,X]=K,re=new Date;return re.setHours(Number(W),Number(X),0,0),re}function N(D){const K=D.match(/^(\d{4})-W(\d{2})$/);if(!K)return null;const[,W,X]=K,re=Number(X);return v(Number(W),re)}function I(D){const K=new Date(Date.UTC(D.getFullYear(),D.getMonth(),D.getDate())),W=K.getUTCDay()||7;K.setUTCDate(K.getUTCDate()+4-W);const X=new Date(Date.UTC(K.getUTCFullYear(),0,1)),re=Math.ceil(((K.getTime()-X.getTime())/864e5+1)/7);return{year:K.getUTCFullYear(),week:re}}function v(D,K){if(!D||!K)return null;const W=new Date(D,0,1+(K-1)*7),X=W.getDay(),re=W;return X<=4?re.setDate(W.getDate()-W.getDay()+1):re.setDate(W.getDate()+8-W.getDay()),re}function M(D){return String(D).padStart(2,"0")}return(D,K)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-date-picker",n.customClass]),style:e.normalizeStyle(C.value)},[e.createVNode(wm,{modelValue:u.value,"onUpdate:modelValue":K[0]||(K[0]=W=>u.value=W),placeholder:i.value,disabled:n.disabled,clearable:n.clearable,typeable:n.editable,"week-day-names":h.value,"week-starts-on":x.value,"starting-view":m.value.startingView,"minimum-view":m.value.minimumView,"input-format":g.value,name:n.name,class:e.normalizeClass(c.value)},null,8,["modelValue","placeholder","disabled","clearable","typeable","week-day-names","week-starts-on","starting-view","minimum-view","input-format","name","class"])],6))}}),[["__scopeId","data-v-a65a2ac3"]]),Cm={form:{richtext:{paragraph:"Paragraph",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",createTable:"Create Table",addColumn:"Add Column",addRow:"Add Row",deleteColumn:"Delete Column",deleteRow:"Delete Row",deleteTable:"Delete Table",mergeCells:"Merge Cells",splitCells:"Split Cells",linkTitle:"Enter Link",link:"Link",linkUrl:"Enter URL",editLink:"Edit Link",openLink:"Open Link",removeLink:"Remove Link",openInNewTab:"Open in New Tab",editor:"Editor",html:"HTML",markdown:"Markdown",create:"Create",update:"Update",cancel:"Cancel"}}},vm={form:{richtext:{paragraph:"Звичайний текст",heading1:"Заголовок 1",heading2:"Заголовок 2",heading3:"Заголовок 3",heading4:"Заголовок 4",heading5:"Заголовок 5",heading6:"Заголовок 6",createTable:"Створити таблицю",addColumn:"Додати колонку",addRow:"Додати рядок",deleteColumn:"Видалити колонку",deleteRow:"Видалити рядок",deleteTable:"Видалити таблицю",mergeCells:"Об'єднати комірки",splitCells:"Розділити комірки",linkTitle:"Додати посилання",link:"Посилання",linkUrl:"Введіть URL",editLink:"Редагувати посилання",openLink:"Відкрити посилання",removeLink:"Видалити посилання",openInNewTab:"Відкривати в новій вкладці",editor:"Редактор",html:"HTML",markdown:"Markdown",create:"Створити",update:"Оновити",cancel:"Скасувати"}}},hr=Cm.form.richtext,gr=vm.form.richtext,no={en:{form:{richtext:hr}},uk:{form:{richtext:gr}}},yr=(o={mode:"edit",schema:null})=>new Promise(t=>{const{close:n}=he.modal({title:o.mode==="add"?"Додати":"Редагувати",template:"",visible:!0,size:"medium",closeClickBack:!0,content:lr,contentProps:{...o,onClose:()=>{t(null),n()},onSave:r=>{t(r),n()}}})});rt.install=function(t){t.component("VForm",rt),Object.assign(t.config.globalProperties,{$form:yr}),t.provide("form",yr),window.v3plugin||(window.v3plugin={})};function Bt(o){return typeof o=="string"||o instanceof String}function br(o){var t;return typeof o=="object"&&o!=null&&(o==null||(t=o.constructor)==null?void 0:t.name)==="Object"}function kr(o,t){return Array.isArray(t)?kr(o,(n,r)=>t.includes(r)):Object.entries(o).reduce((n,r)=>{let[l,a]=r;return t(a,l)&&(n[l]=a),n},{})}const fe={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function xr(o){switch(o){case fe.LEFT:return fe.FORCE_LEFT;case fe.RIGHT:return fe.FORCE_RIGHT;default:return o}}function oo(o){return o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function An(o,t){if(t===o)return!0;const n=Array.isArray(t),r=Array.isArray(o);let l;if(n&&r){if(t.length!=o.length)return!1;for(l=0;l<t.length;l++)if(!An(t[l],o[l]))return!1;return!0}if(n!=r)return!1;if(t&&o&&typeof t=="object"&&typeof o=="object"){const a=t instanceof Date,s=o instanceof Date;if(a&&s)return t.getTime()==o.getTime();if(a!=s)return!1;const i=t instanceof RegExp,c=o instanceof RegExp;if(i&&c)return t.toString()==o.toString();if(i!=c)return!1;const d=Object.keys(t);for(l=0;l<d.length;l++)if(!Object.prototype.hasOwnProperty.call(o,d[l]))return!1;for(l=0;l<d.length;l++)if(!An(o[d[l]],t[d[l]]))return!1;return!0}else if(t&&o&&typeof t=="function"&&typeof o=="function")return t.toString()===o.toString();return!1}class Em{constructor(t){for(Object.assign(this,t);this.value.slice(0,this.startChangePos)!==this.oldValue.slice(0,this.startChangePos);)--this.oldSelection.start;if(this.insertedCount)for(;this.value.slice(this.cursorPos)!==this.oldValue.slice(this.oldSelection.end);)this.value.length-this.cursorPos<this.oldValue.length-this.oldSelection.end?++this.oldSelection.end:++this.cursorPos}get startChangePos(){return Math.min(this.cursorPos,this.oldSelection.start)}get insertedCount(){return this.cursorPos-this.startChangePos}get inserted(){return this.value.substr(this.startChangePos,this.insertedCount)}get removedCount(){return Math.max(this.oldSelection.end-this.startChangePos||this.oldValue.length-this.value.length,0)}get removed(){return this.oldValue.substr(this.startChangePos,this.removedCount)}get head(){return this.value.substring(0,this.startChangePos)}get tail(){return this.value.substring(this.startChangePos+this.insertedCount)}get removeDirection(){return!this.removedCount||this.insertedCount?fe.NONE:(this.oldSelection.end===this.cursorPos||this.oldSelection.start===this.cursorPos)&&this.oldSelection.end===this.oldSelection.start?fe.RIGHT:fe.LEFT}}function ke(o,t){return new ke.InputMask(o,t)}function wr(o){if(o==null)throw new Error("mask property should be defined");return o instanceof RegExp?ke.MaskedRegExp:Bt(o)?ke.MaskedPattern:o===Date?ke.MaskedDate:o===Number?ke.MaskedNumber:Array.isArray(o)||o===Array?ke.MaskedDynamic:ke.Masked&&o.prototype instanceof ke.Masked?o:ke.Masked&&o instanceof ke.Masked?o.constructor:o instanceof Function?ke.MaskedFunction:(console.warn("Mask not found for mask",o),ke.Masked)}function Pt(o){if(!o)throw new Error("Options in not defined");if(ke.Masked){if(o.prototype instanceof ke.Masked)return{mask:o};const{mask:t=void 0,...n}=o instanceof ke.Masked?{mask:o}:br(o)&&o.mask instanceof ke.Masked?o:{};if(t){const r=t.mask;return{...kr(t,(l,a)=>!a.startsWith("_")),mask:t.constructor,_mask:r,...n}}}return br(o)?{...o}:{mask:o}}function ft(o){if(ke.Masked&&o instanceof ke.Masked)return o;const t=Pt(o),n=wr(t.mask);if(!n)throw new Error("Masked class is not found for provided mask "+t.mask+", appropriate module needs to be imported manually before creating mask.");return t.mask===n&&delete t.mask,t._mask&&(t.mask=t._mask,delete t._mask),new n(t)}ke.createMask=ft;class Fn{get selectionStart(){let t;try{t=this._unsafeSelectionStart}catch{}return t??this.value.length}get selectionEnd(){let t;try{t=this._unsafeSelectionEnd}catch{}return t??this.value.length}select(t,n){if(!(t==null||n==null||t===this.selectionStart&&n===this.selectionEnd))try{this._unsafeSelect(t,n)}catch{}}get isActive(){return!1}}ke.MaskElement=Fn;const _r=90,Bm=89;class Gt extends Fn{constructor(t){super(),this.input=t,this._onKeydown=this._onKeydown.bind(this),this._onInput=this._onInput.bind(this),this._onBeforeinput=this._onBeforeinput.bind(this),this._onCompositionEnd=this._onCompositionEnd.bind(this)}get rootElement(){var t,n,r;return(t=(n=(r=this.input).getRootNode)==null?void 0:n.call(r))!=null?t:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(t){this.input.addEventListener("keydown",this._onKeydown),this.input.addEventListener("input",this._onInput),this.input.addEventListener("beforeinput",this._onBeforeinput),this.input.addEventListener("compositionend",this._onCompositionEnd),this.input.addEventListener("drop",t.drop),this.input.addEventListener("click",t.click),this.input.addEventListener("focus",t.focus),this.input.addEventListener("blur",t.commit),this._handlers=t}_onKeydown(t){if(this._handlers.redo&&(t.keyCode===_r&&t.shiftKey&&(t.metaKey||t.ctrlKey)||t.keyCode===Bm&&t.ctrlKey))return t.preventDefault(),this._handlers.redo(t);if(this._handlers.undo&&t.keyCode===_r&&(t.metaKey||t.ctrlKey))return t.preventDefault(),this._handlers.undo(t);t.isComposing||this._handlers.selectionChange(t)}_onBeforeinput(t){if(t.inputType==="historyUndo"&&this._handlers.undo)return t.preventDefault(),this._handlers.undo(t);if(t.inputType==="historyRedo"&&this._handlers.redo)return t.preventDefault(),this._handlers.redo(t)}_onCompositionEnd(t){this._handlers.input(t)}_onInput(t){t.isComposing||this._handlers.input(t)}unbindEvents(){this.input.removeEventListener("keydown",this._onKeydown),this.input.removeEventListener("input",this._onInput),this.input.removeEventListener("beforeinput",this._onBeforeinput),this.input.removeEventListener("compositionend",this._onCompositionEnd),this.input.removeEventListener("drop",this._handlers.drop),this.input.removeEventListener("click",this._handlers.click),this.input.removeEventListener("focus",this._handlers.focus),this.input.removeEventListener("blur",this._handlers.commit),this._handlers={}}}ke.HTMLMaskElement=Gt;class Cr extends Gt{constructor(t){super(t),this.input=t}get _unsafeSelectionStart(){return this.input.selectionStart!=null?this.input.selectionStart:this.value.length}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,n){this.input.setSelectionRange(t,n)}get value(){return this.input.value}set value(t){this.input.value=t}}ke.HTMLMaskElement=Gt;class ro extends Gt{get _unsafeSelectionStart(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||r==null||r<l?r:l}get _unsafeSelectionEnd(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||r==null||r>l?r:l}_unsafeSelect(t,n){if(!this.rootElement.createRange)return;const r=this.rootElement.createRange();r.setStart(this.input.firstChild||this.input,t),r.setEnd(this.input.lastChild||this.input,n);const l=this.rootElement,a=l.getSelection&&l.getSelection();a&&(a.removeAllRanges(),a.addRange(r))}get value(){return this.input.textContent||""}set value(t){this.input.textContent=t}}ke.HTMLContenteditableMaskElement=ro;class Mn{constructor(){this.states=[],this.currentIndex=0}get currentState(){return this.states[this.currentIndex]}get isEmpty(){return this.states.length===0}push(t){this.currentIndex<this.states.length-1&&(this.states.length=this.currentIndex+1),this.states.push(t),this.states.length>Mn.MAX_LENGTH&&this.states.shift(),this.currentIndex=this.states.length-1}go(t){return this.currentIndex=Math.min(Math.max(this.currentIndex+t,0),this.states.length-1),this.currentState}undo(){return this.go(-1)}redo(){return this.go(1)}clear(){this.states.length=0,this.currentIndex=0}}Mn.MAX_LENGTH=100;class vr{constructor(t,n){this.el=t instanceof Fn?t:t.isContentEditable&&t.tagName!=="INPUT"&&t.tagName!=="TEXTAREA"?new ro(t):new Cr(t),this.masked=ft(n),this._listeners={},this._value="",this._unmaskedValue="",this._rawInputValue="",this.history=new Mn,this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this._onUndo=this._onUndo.bind(this),this._onRedo=this._onRedo.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}maskEquals(t){var n;return t==null||((n=this.masked)==null?void 0:n.maskEquals(t))}get mask(){return this.masked.mask}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof ke.Masked)&&this.masked.constructor===wr(t)){this.masked.updateOptions({mask:t});return}const n=t instanceof ke.Masked?t:ft({mask:t});n.unmaskedValue=this.masked.unmaskedValue,this.masked=n}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl("auto"))}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl("auto"))}get rawInputValue(){return this._rawInputValue}set rawInputValue(t){this.rawInputValue!==t&&(this.masked.rawInputValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl("auto"))}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange,undo:this._onUndo,redo:this._onRedo})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t,n){const r=this._listeners[t];r&&r.forEach(l=>l(n))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){!this.el||!this.el.isActive||(this.el.select(t,t),this._saveSelection())}_saveSelection(){this.displayValue!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value,this._unmaskedValue=this.masked.unmaskedValue,this._rawInputValue=this.masked.rawInputValue}updateControl(t){const n=this.masked.unmaskedValue,r=this.masked.value,l=this.masked.rawInputValue,a=this.displayValue,s=this.unmaskedValue!==n||this.value!==r||this._rawInputValue!==l;this._unmaskedValue=n,this._value=r,this._rawInputValue=l,this.el.value!==a&&(this.el.value=a),t==="auto"?this.alignCursor():t!=null&&(this.cursorPos=t),s&&this._fireChangeEvents(),!this._historyChanging&&(s||this.history.isEmpty)&&this.history.push({unmaskedValue:n,selection:{start:this.selectionStart,end:this.cursorPos}})}updateOptions(t){const{mask:n,...r}=t,l=!this.maskEquals(n),a=this.masked.optionsIsChanged(r);l&&(this.mask=n),a&&this.masked.updateOptions(r),(l||a)&&this.updateControl()}updateCursor(t){t!=null&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())},10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,fe.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,n){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(n),this}off(t,n){if(!this._listeners[t])return this;if(!n)return delete this._listeners[t],this;const r=this._listeners[t].indexOf(n);return r>=0&&this._listeners[t].splice(r,1),this}_onInput(t){this._inputEvent=t,this._abortUpdateCursor();const n=new Em({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),r=this.masked.rawInputValue,l=this.masked.splice(n.startChangePos,n.removed.length,n.inserted,n.removeDirection,{input:!0,raw:!0}).offset,a=r===this.masked.rawInputValue?n.removeDirection:fe.NONE;let s=this.masked.nearestInputPos(n.startChangePos+l,a);a!==fe.NONE&&(s=this.masked.nearestInputPos(s,fe.NONE)),this.updateControl(s),delete this._inputEvent}_onChange(){this.displayValue!==this.el.value&&this.updateValue(),this.masked.doCommit(),this.updateControl(),this._saveSelection()}_onDrop(t){t.preventDefault(),t.stopPropagation()}_onFocus(t){this.alignCursorFriendly()}_onClick(t){this.alignCursorFriendly()}_onUndo(){this._applyHistoryState(this.history.undo())}_onRedo(){this._applyHistoryState(this.history.redo())}_applyHistoryState(t){t&&(this._historyChanging=!0,this.unmaskedValue=t.unmaskedValue,this.el.select(t.selection.start,t.selection.end),this._saveSelection(),this._historyChanging=!1)}destroy(){this._unbindEvents(),this._listeners.length=0,delete this.el}}ke.InputMask=vr;class _e{static normalize(t){return Array.isArray(t)?t:[t,new _e]}constructor(t){Object.assign(this,{inserted:"",rawInserted:"",tailShift:0,skip:!1},t)}aggregate(t){return this.inserted+=t.inserted,this.rawInserted+=t.rawInserted,this.tailShift+=t.tailShift,this.skip=this.skip||t.skip,this}get offset(){return this.tailShift+this.inserted.length}get consumed(){return!!this.rawInserted||this.skip}equals(t){return this.inserted===t.inserted&&this.tailShift===t.tailShift&&this.rawInserted===t.rawInserted&&this.skip===t.skip}}ke.ChangeDetails=_e;class mt{constructor(t,n,r){t===void 0&&(t=""),n===void 0&&(n=0),this.value=t,this.from=n,this.stop=r}toString(){return this.value}extend(t){this.value+=String(t)}appendTo(t){return t.append(this.toString(),{tail:!0}).aggregate(t._appendPlaceholder())}get state(){return{value:this.value,from:this.from,stop:this.stop}}set state(t){Object.assign(this,t)}unshift(t){if(!this.value.length||t!=null&&this.from>=t)return"";const n=this.value[0];return this.value=this.value.slice(1),n}shift(){if(!this.value.length)return"";const t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}class je{constructor(t){this._value="",this._update({...je.DEFAULTS,...t}),this._initialized=!0}updateOptions(t){this.optionsIsChanged(t)&&this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value}reset(){this._value=""}get value(){return this._value}set value(t){this.resolve(t,{input:!0})}resolve(t,n){n===void 0&&(n={input:!0}),this.reset(),this.append(t,n,""),this.doCommit()}get unmaskedValue(){return this.value}set unmaskedValue(t){this.resolve(t,{})}get typedValue(){return this.parse?this.parse(this.value,this):this.unmaskedValue}set typedValue(t){this.format?this.value=this.format(t,this):this.unmaskedValue=String(t)}get rawInputValue(){return this.extractInput(0,this.displayValue.length,{raw:!0})}set rawInputValue(t){this.resolve(t,{raw:!0})}get displayValue(){return this.value}get isComplete(){return!0}get isFilled(){return this.isComplete}nearestInputPos(t,n){return t}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),Math.min(this.displayValue.length,n-t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this.displayValue.slice(t,n)}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new mt(this.extractInput(t,n),t)}appendTail(t){return Bt(t)&&(t=new mt(String(t))),t.appendTo(this)}_appendCharRaw(t,n){return t?(this._value+=t,new _e({inserted:t,rawInserted:t})):new _e}_appendChar(t,n,r){n===void 0&&(n={});const l=this.state;let a;if([t,a]=this.doPrepareChar(t,n),t&&(a=a.aggregate(this._appendCharRaw(t,n)),!a.rawInserted&&this.autofix==="pad")){const s=this.state;this.state=l;let i=this.pad(n);const c=this._appendCharRaw(t,n);i=i.aggregate(c),c.rawInserted||i.equals(a)?a=i:this.state=s}if(a.inserted){let s,i=this.doValidate(n)!==!1;if(i&&r!=null){const c=this.state;if(this.overwrite===!0){s=r.state;for(let u=0;u<a.rawInserted.length;++u)r.unshift(this.displayValue.length-a.tailShift)}let d=this.appendTail(r);if(i=d.rawInserted.length===r.toString().length,!(i&&d.inserted)&&this.overwrite==="shift"){this.state=c,s=r.state;for(let u=0;u<a.rawInserted.length;++u)r.shift();d=this.appendTail(r),i=d.rawInserted.length===r.toString().length}i&&d.inserted&&(this.state=c)}i||(a=new _e,this.state=l,r&&s&&(r.state=s))}return a}_appendPlaceholder(){return new _e}_appendEager(){return new _e}append(t,n,r){if(!Bt(t))throw new Error("value should be string");const l=Bt(r)?new mt(String(r)):r;n!=null&&n.tail&&(n._beforeTailState=this.state);let a;[t,a]=this.doPrepare(t,n);for(let s=0;s<t.length;++s){const i=this._appendChar(t[s],n,l);if(!i.rawInserted&&!this.doSkipInvalid(t[s],n,l))break;a.aggregate(i)}return(this.eager===!0||this.eager==="append")&&n!=null&&n.input&&t&&a.aggregate(this._appendEager()),l!=null&&(a.tailShift+=this.appendTail(l).tailShift),a}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this._value=this.displayValue.slice(0,t)+this.displayValue.slice(n),new _e}withValueRefresh(t){if(this._refreshing||!this._initialized)return t();this._refreshing=!0;const n=this.rawInputValue,r=this.value,l=t();return this.rawInputValue=n,this.value&&this.value!==r&&r.indexOf(this.value)===0&&(this.append(r.slice(this.displayValue.length),{},""),this.doCommit()),delete this._refreshing,l}runIsolated(t){if(this._isolated||!this._initialized)return t(this);this._isolated=!0;const n=this.state,r=t(this);return this.state=n,delete this._isolated,r}doSkipInvalid(t,n,r){return!!this.skipInvalid}doPrepare(t,n){return n===void 0&&(n={}),_e.normalize(this.prepare?this.prepare(t,this,n):t)}doPrepareChar(t,n){return n===void 0&&(n={}),_e.normalize(this.prepareChar?this.prepareChar(t,this,n):t)}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}splice(t,n,r,l,a){r===void 0&&(r=""),l===void 0&&(l=fe.NONE),a===void 0&&(a={input:!0});const s=t+n,i=this.extractTail(s),c=this.eager===!0||this.eager==="remove";let d;c&&(l=xr(l),d=this.extractInput(0,s,{raw:!0}));let u=t;const p=new _e;if(l!==fe.NONE&&(u=this.nearestInputPos(t,n>1&&t!==0&&!c?fe.NONE:l),p.tailShift=u-t),p.aggregate(this.remove(u)),c&&l!==fe.NONE&&d===this.rawInputValue)if(l===fe.FORCE_LEFT){let h;for(;d===this.rawInputValue&&(h=this.displayValue.length);)p.aggregate(new _e({tailShift:-1})).aggregate(this.remove(h-1))}else l===fe.FORCE_RIGHT&&i.unshift();return p.aggregate(this.append(r,a,i))}maskEquals(t){return this.mask===t}optionsIsChanged(t){return!An(this,t)}typedValueEquals(t){const n=this.typedValue;return t===n||je.EMPTY_VALUES.includes(t)&&je.EMPTY_VALUES.includes(n)||(this.format?this.format(t,this)===this.format(this.typedValue,this):!1)}pad(t){return new _e}}je.DEFAULTS={skipInvalid:!0},je.EMPTY_VALUES=[void 0,null,""],ke.Masked=je;class Vt{constructor(t,n){t===void 0&&(t=[]),n===void 0&&(n=0),this.chunks=t,this.from=n}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=Bt(t)?new mt(String(t)):t;const n=this.chunks[this.chunks.length-1],r=n&&(n.stop===t.stop||t.stop==null)&&t.from===n.from+n.toString().length;if(t instanceof mt)r?n.extend(t.toString()):this.chunks.push(t);else if(t instanceof Vt){if(t.stop==null){let l;for(;t.chunks.length&&t.chunks[0].stop==null;)l=t.chunks.shift(),l.from+=t.from,this.extend(l)}t.toString()&&(t.stop=t.blockIndex,this.chunks.push(t))}}appendTo(t){if(!(t instanceof ke.MaskedPattern))return new mt(this.toString()).appendTo(t);const n=new _e;for(let r=0;r<this.chunks.length;++r){const l=this.chunks[r],a=t._mapPosToBlock(t.displayValue.length),s=l.stop;let i;if(s!=null&&(!a||a.index<=s)&&((l instanceof Vt||t._stops.indexOf(s)>=0)&&n.aggregate(t._appendPlaceholder(s)),i=l instanceof Vt&&t._blocks[s]),i){const c=i.appendTail(l);n.aggregate(c);const d=l.toString().slice(c.rawInserted.length);d&&n.aggregate(t.append(d,{tail:!0}))}else n.aggregate(t.append(l.toString(),{tail:!0}))}return n}get state(){return{chunks:this.chunks.map(t=>t.state),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(t){const{chunks:n,...r}=t;Object.assign(this,r),this.chunks=n.map(l=>{const a="chunks"in l?new Vt:new mt;return a.state=l,a})}unshift(t){if(!this.chunks.length||t!=null&&this.from>=t)return"";const n=t!=null?t-this.from:t;let r=0;for(;r<this.chunks.length;){const l=this.chunks[r],a=l.unshift(n);if(l.toString()){if(!a)break;++r}else this.chunks.splice(r,1);if(a)return a}return""}shift(){if(!this.chunks.length)return"";let t=this.chunks.length-1;for(;0<=t;){const n=this.chunks[t],r=n.shift();if(n.toString()){if(!r)break;--t}else this.chunks.splice(t,1);if(r)return r}return""}}class Vm{constructor(t,n){this.masked=t,this._log=[];const{offset:r,index:l}=t._mapPosToBlock(n)||(n<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0});this.offset=r,this.index=l,this.ok=!1}get block(){return this.masked._blocks[this.index]}get pos(){return this.masked._blockStartPos(this.index)+this.offset}get state(){return{index:this.index,offset:this.offset,ok:this.ok}}set state(t){Object.assign(this,t)}pushState(){this._log.push(this.state)}popState(){const t=this._log.pop();return t&&(this.state=t),t}bindBlock(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.displayValue.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=((n=this.block)==null?void 0:n.displayValue.length)||0){var n;if(t())return this.ok=!0}return this.ok=!1}_pushRight(t){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(t())return this.ok=!0;return this.ok=!1}pushLeftBeforeFilled(){return this._pushLeft(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,fe.FORCE_LEFT),this.offset!==0))return!0})}pushLeftBeforeInput(){return this._pushLeft(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,fe.LEFT),!0})}pushLeftBeforeRequired(){return this._pushLeft(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,fe.LEFT),!0})}pushRightBeforeFilled(){return this._pushRight(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,fe.FORCE_RIGHT),this.offset!==this.block.value.length))return!0})}pushRightBeforeInput(){return this._pushRight(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,fe.NONE),!0})}pushRightBeforeRequired(){return this._pushRight(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,fe.NONE),!0})}}class lo{constructor(t){Object.assign(this,t),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}get rawInputValue(){return this._isRawInput?this.value:""}get displayValue(){return this.value}reset(){this._isRawInput=!1,this._value=""}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(n),this._value||(this._isRawInput=!1),new _e}nearestInputPos(t,n){n===void 0&&(n=fe.NONE);const r=0,l=this._value.length;switch(n){case fe.LEFT:case fe.FORCE_LEFT:return r;case fe.NONE:case fe.RIGHT:case fe.FORCE_RIGHT:default:return l}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._isRawInput?n-t:0}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),r===void 0&&(r={}),r.raw&&this._isRawInput&&this._value.slice(t,n)||""}get isComplete(){return!0}get isFilled(){return!!this._value}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new _e;const r=this.eager===!0||this.eager==="append",a=this.char===t&&(this.isUnmasking||n.input||n.raw)&&(!n.raw||!r)&&!n.tail,s=new _e({inserted:this.char,rawInserted:a?this.char:""});return this._value=this.char,this._isRawInput=a&&(n.raw||n.input),s}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new _e;return this.isFilled||(this._value=t.inserted=this.char),t}extractTail(){return new mt("")}appendTail(t){return Bt(t)&&(t=new mt(String(t))),t.appendTo(this)}append(t,n,r){const l=this._appendChar(t[0],n);return r!=null&&(l.tailShift+=this.appendTail(r).tailShift),l}doCommit(){}get state(){return{_value:this._value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value,this._isRawInput=!!t._rawInputValue}pad(t){return this._appendPlaceholder()}}class Yt{constructor(t){const{parent:n,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:i,...c}=t;this.masked=ft(c),Object.assign(this,{parent:n,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:i})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),t===0&&n>=1?(this.isFilled=!1,this.masked.remove(t,n)):new _e}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get rawInputValue(){return this.masked.rawInputValue}get displayValue(){return this.masked.value&&this.displayChar||this.value}get isComplete(){return!!this.masked.value||this.isOptional}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new _e;const r=this.masked.state;let l=this.masked._appendChar(t,this.currentMaskFlags(n));return l.inserted&&this.doValidate(n)===!1&&(l=new _e,this.masked.state=r),!l.inserted&&!this.isOptional&&!this.lazy&&!n.input&&(l.inserted=this.placeholderChar),l.skip=!l.inserted&&!this.isOptional,this.isFilled=!!l.inserted,l}append(t,n,r){return this.masked.append(t,this.currentMaskFlags(n),r)}_appendPlaceholder(){return this.isFilled||this.isOptional?new _e:(this.isFilled=!0,new _e({inserted:this.placeholderChar}))}_appendEager(){return new _e}extractTail(t,n){return this.masked.extractTail(t,n)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.masked.extractInput(t,n,r)}nearestInputPos(t,n){n===void 0&&(n=fe.NONE);const r=0,l=this.value.length,a=Math.min(Math.max(t,r),l);switch(n){case fe.LEFT:case fe.FORCE_LEFT:return this.isComplete?a:r;case fe.RIGHT:case fe.FORCE_RIGHT:return this.isComplete?a:l;case fe.NONE:default:return a}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.value.slice(t,n).length}doValidate(t){return this.masked.doValidate(this.currentMaskFlags(t))&&(!this.parent||this.parent.doValidate(this.currentMaskFlags(t)))}doCommit(){this.masked.doCommit()}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue,masked:this.masked.state,isFilled:this.isFilled}}set state(t){this.masked.state=t.masked,this.isFilled=t.isFilled}currentMaskFlags(t){var n;return{...t,_beforeTailState:(t==null||(n=t._beforeTailState)==null?void 0:n.masked)||t?._beforeTailState}}pad(t){return new _e}}Yt.DEFAULT_DEFINITIONS={0:/\d/,a:/[\u0041-\u005A\u0061-\u007A\u00AA\u00B5\u00BA\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA697\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA793\uA7A0-\uA7AA\uA7F8-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA80-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/,"*":/./};class Er extends je{updateOptions(t){super.updateOptions(t)}_update(t){const n=t.mask;n&&(t.validate=r=>r.search(n)>=0),super._update(t)}}ke.MaskedRegExp=Er;class Ue extends je{constructor(t){super({...Ue.DEFAULTS,...t,definitions:Object.assign({},Yt.DEFAULT_DEFINITIONS,t?.definitions)})}updateOptions(t){super.updateOptions(t)}_update(t){t.definitions=Object.assign({},this.definitions,t.definitions),super._update(t),this._rebuildMask()}_rebuildMask(){const t=this.definitions;this._blocks=[],this.exposeBlock=void 0,this._stops=[],this._maskedBlocks={};const n=this.mask;if(!n||!t)return;let r=!1,l=!1;for(let a=0;a<n.length;++a){if(this.blocks){const d=n.slice(a),u=Object.keys(this.blocks).filter(h=>d.indexOf(h)===0);u.sort((h,x)=>x.length-h.length);const p=u[0];if(p){const{expose:h,repeat:x,...m}=Pt(this.blocks[p]),b={lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,autofix:this.autofix,...m,repeat:x,parent:this},g=x!=null?new ke.RepeatBlock(b):ft(b);g&&(this._blocks.push(g),h&&(this.exposeBlock=g),this._maskedBlocks[p]||(this._maskedBlocks[p]=[]),this._maskedBlocks[p].push(this._blocks.length-1)),a+=p.length-1;continue}}let s=n[a],i=s in t;if(s===Ue.STOP_CHAR){this._stops.push(this._blocks.length);continue}if(s==="{"||s==="}"){r=!r;continue}if(s==="["||s==="]"){l=!l;continue}if(s===Ue.ESCAPE_CHAR){if(++a,s=n[a],!s)break;i=!1}const c=i?new Yt({isOptional:l,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...Pt(t[s]),parent:this}):new lo({char:s,eager:this.eager,isUnmasking:r});this._blocks.push(c)}}get state(){return{...super.state,_blocks:this._blocks.map(t=>t.state)}}set state(t){if(!t){this.reset();return}const{_blocks:n,...r}=t;this._blocks.forEach((l,a)=>l.state=n[a]),super.state=r}reset(){super.reset(),this._blocks.forEach(t=>t.reset())}get isComplete(){return this.exposeBlock?this.exposeBlock.isComplete:this._blocks.every(t=>t.isComplete)}get isFilled(){return this._blocks.every(t=>t.isFilled)}get isFixed(){return this._blocks.every(t=>t.isFixed)}get isOptional(){return this._blocks.every(t=>t.isOptional)}doCommit(){this._blocks.forEach(t=>t.doCommit()),super.doCommit()}get unmaskedValue(){return this.exposeBlock?this.exposeBlock.unmaskedValue:this._blocks.reduce((t,n)=>t+=n.unmaskedValue,"")}set unmaskedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.unmaskedValue=t,this.appendTail(n),this.doCommit()}else super.unmaskedValue=t}get value(){return this.exposeBlock?this.exposeBlock.value:this._blocks.reduce((t,n)=>t+=n.value,"")}set value(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.value=t,this.appendTail(n),this.doCommit()}else super.value=t}get typedValue(){return this.exposeBlock?this.exposeBlock.typedValue:super.typedValue}set typedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.typedValue=t,this.appendTail(n),this.doCommit()}else super.typedValue=t}get displayValue(){return this._blocks.reduce((t,n)=>t+=n.displayValue,"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const n=new _e;let r=(t=this._mapPosToBlock(this.displayValue.length))==null?void 0:t.index;if(r==null)return n;this._blocks[r].isFilled&&++r;for(let l=r;l<this._blocks.length;++l){const a=this._blocks[l]._appendEager();if(!a.inserted)break;n.aggregate(a)}return n}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._mapPosToBlock(this.displayValue.length),l=new _e;if(!r)return l;for(let s=r.index,i;i=this._blocks[s];++s){var a;const c=i._appendChar(t,{...n,_beforeTailState:(a=n._beforeTailState)==null||(a=a._blocks)==null?void 0:a[s]});if(l.aggregate(c),c.consumed)break}return l}extractTail(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=new Vt;return t===n||this._forEachBlocksInRange(t,n,(l,a,s,i)=>{const c=l.extractTail(s,i);c.stop=this._findStopBefore(a),c.from=this._blockStartPos(a),c instanceof Vt&&(c.blockIndex=a),r.extend(c)}),r}extractInput(t,n,r){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),r===void 0&&(r={}),t===n)return"";let l="";return this._forEachBlocksInRange(t,n,(a,s,i,c)=>{l+=a.extractInput(i,c,r)}),l}_findStopBefore(t){let n;for(let r=0;r<this._stops.length;++r){const l=this._stops[r];if(l<=t)n=l;else break}return n}_appendPlaceholder(t){const n=new _e;if(this.lazy&&t==null)return n;const r=this._mapPosToBlock(this.displayValue.length);if(!r)return n;const l=r.index,a=t??this._blocks.length;return this._blocks.slice(l,a).forEach(s=>{if(!s.lazy||t!=null){var i;n.aggregate(s._appendPlaceholder((i=s._blocks)==null?void 0:i.length))}}),n}_mapPosToBlock(t){let n="";for(let r=0;r<this._blocks.length;++r){const l=this._blocks[r],a=n.length;if(n+=l.displayValue,t<=n.length)return{index:r,offset:t-a}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce((n,r)=>n+=r.displayValue.length,0)}_forEachBlocksInRange(t,n,r){n===void 0&&(n=this.displayValue.length);const l=this._mapPosToBlock(t);if(l){const a=this._mapPosToBlock(n),s=a&&l.index===a.index,i=l.offset,c=a&&s?a.offset:this._blocks[l.index].displayValue.length;if(r(this._blocks[l.index],l.index,i,c),a&&!s){for(let d=l.index+1;d<a.index;++d)r(this._blocks[d],d,0,this._blocks[d].displayValue.length);r(this._blocks[a.index],a.index,0,a.offset)}}}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._forEachBlocksInRange(t,n,(l,a,s,i)=>{r.aggregate(l.remove(s,i))}),r}nearestInputPos(t,n){if(n===void 0&&(n=fe.NONE),!this._blocks.length)return 0;const r=new Vm(this,t);if(n===fe.NONE)return r.pushRightBeforeInput()||(r.popState(),r.pushLeftBeforeInput())?r.pos:this.displayValue.length;if(n===fe.LEFT||n===fe.FORCE_LEFT){if(n===fe.LEFT){if(r.pushRightBeforeFilled(),r.ok&&r.pos===t)return t;r.popState()}if(r.pushLeftBeforeInput(),r.pushLeftBeforeRequired(),r.pushLeftBeforeFilled(),n===fe.LEFT){if(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.ok&&r.pos<=t||(r.popState(),r.ok&&r.pos<=t))return r.pos;r.popState()}return r.ok?r.pos:n===fe.FORCE_LEFT?0:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:0)}return n===fe.RIGHT||n===fe.FORCE_RIGHT?(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.pushRightBeforeFilled()?r.pos:n===fe.FORCE_RIGHT?this.displayValue.length:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:this.nearestInputPos(t,fe.LEFT))):t}totalInputPositions(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);let r=0;return this._forEachBlocksInRange(t,n,(l,a,s,i)=>{r+=l.totalInputPositions(s,i)}),r}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const n=this._maskedBlocks[t];return n?n.map(r=>this._blocks[r]):[]}pad(t){const n=new _e;return this._forEachBlocksInRange(0,this.displayValue.length,r=>n.aggregate(r.pad(t))),n}}Ue.DEFAULTS={...je.DEFAULTS,lazy:!0,placeholderChar:"_"},Ue.STOP_CHAR="`",Ue.ESCAPE_CHAR="\\",Ue.InputDefinition=Yt,Ue.FixedDefinition=lo,ke.MaskedPattern=Ue;class Xt extends Ue{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:n=this.to||0,from:r=this.from||0,maxLength:l=this.maxLength||0,autofix:a=this.autofix,...s}=t;this.to=n,this.from=r,this.maxLength=Math.max(String(n).length,l),this.autofix=a;const i=String(this.from).padStart(this.maxLength,"0"),c=String(this.to).padStart(this.maxLength,"0");let d=0;for(;d<c.length&&c[d]===i[d];)++d;s.mask=c.slice(0,d).replace(/0/g,"\\0")+"0".repeat(this.maxLength-d),super._update(s)}get isComplete(){return super.isComplete&&!!this.value}boundaries(t){let n="",r="";const[,l,a]=t.match(/^(\D*)(\d*)(\D*)/)||[];return a&&(n="0".repeat(l.length)+a,r="9".repeat(l.length)+a),n=n.padEnd(this.maxLength,"0"),r=r.padEnd(this.maxLength,"9"),[n,r]}doPrepareChar(t,n){n===void 0&&(n={});let r;return[t,r]=super.doPrepareChar(t.replace(/\D/g,""),n),t||(r.skip=!this.isComplete),[t,r]}_appendCharRaw(t,n){if(n===void 0&&(n={}),!this.autofix||this.value.length+1>this.maxLength)return super._appendCharRaw(t,n);const r=String(this.from).padStart(this.maxLength,"0"),l=String(this.to).padStart(this.maxLength,"0"),[a,s]=this.boundaries(this.value+t);return Number(s)<this.from?super._appendCharRaw(r[this.value.length],n):Number(a)>this.to?!n.tail&&this.autofix==="pad"&&this.value.length+1<this.maxLength?super._appendCharRaw(r[this.value.length],n).aggregate(this._appendCharRaw(t,n)):super._appendCharRaw(l[this.value.length],n):super._appendCharRaw(t,n)}doValidate(t){const n=this.value;if(n.search(/[^0]/)===-1&&n.length<=this._matchFrom)return!0;const[l,a]=this.boundaries(n);return this.from<=Number(a)&&Number(l)<=this.to&&super.doValidate(t)}pad(t){const n=new _e;if(this.value.length===this.maxLength)return n;const r=this.value,l=this.maxLength-this.value.length;if(l){this.reset();for(let a=0;a<l;++a)n.aggregate(super._appendCharRaw("0",t));r.split("").forEach(a=>this._appendCharRaw(a))}return n}}ke.MaskedRange=Xt;const Sm="d{.}`m{.}`Y";class ht extends Ue{static extractPatternOptions(t){const{mask:n,pattern:r,...l}=t;return{...l,mask:Bt(n)?n:r}}constructor(t){super(ht.extractPatternOptions({...ht.DEFAULTS,...t}))}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:n,pattern:r,blocks:l,...a}={...ht.DEFAULTS,...t},s=Object.assign({},ht.GET_DEFAULT_BLOCKS());t.min&&(s.Y.from=t.min.getFullYear()),t.max&&(s.Y.to=t.max.getFullYear()),t.min&&t.max&&s.Y.from===s.Y.to&&(s.m.from=t.min.getMonth()+1,s.m.to=t.max.getMonth()+1,s.m.from===s.m.to&&(s.d.from=t.min.getDate(),s.d.to=t.max.getDate())),Object.assign(s,this.blocks,l),super._update({...a,mask:Bt(n)?n:r,blocks:s})}doValidate(t){const n=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&n!=null&&(this.min==null||this.min<=n)&&(this.max==null||n<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}optionsIsChanged(t){return super.optionsIsChanged(ht.extractPatternOptions(t))}}ht.GET_DEFAULT_BLOCKS=()=>({d:{mask:Xt,from:1,to:31,maxLength:2},m:{mask:Xt,from:1,to:12,maxLength:2},Y:{mask:Xt,from:1900,to:9999}}),ht.DEFAULTS={...Ue.DEFAULTS,mask:Date,pattern:Sm,format:(o,t)=>{if(!o)return"";const n=String(o.getDate()).padStart(2,"0"),r=String(o.getMonth()+1).padStart(2,"0"),l=o.getFullYear();return[n,r,l].join(".")},parse:(o,t)=>{const[n,r,l]=o.split(".").map(Number);return new Date(l,r-1,n)}},ke.MaskedDate=ht;class Zt extends je{constructor(t){super({...Zt.DEFAULTS,...t}),this.currentMask=void 0}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),"mask"in t&&(this.exposeMask=void 0,this.compiledMasks=Array.isArray(t.mask)?t.mask.map(n=>{const{expose:r,...l}=Pt(n),a=ft({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...l});return r&&(this.exposeMask=a),a}):[])}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._applyDispatch(t,n);return this.currentMask&&r.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(n))),r}_applyDispatch(t,n,r){t===void 0&&(t=""),n===void 0&&(n={}),r===void 0&&(r="");const l=n.tail&&n._beforeTailState!=null?n._beforeTailState._value:this.value,a=this.rawInputValue,s=n.tail&&n._beforeTailState!=null?n._beforeTailState._rawInputValue:a,i=a.slice(s.length),c=this.currentMask,d=new _e,u=c?.state;return this.currentMask=this.doDispatch(t,{...n},r),this.currentMask&&(this.currentMask!==c?(this.currentMask.reset(),s&&(this.currentMask.append(s,{raw:!0}),d.tailShift=this.currentMask.value.length-l.length),i&&(d.tailShift+=this.currentMask.append(i,{raw:!0,tail:!0}).tailShift)):u&&(this.currentMask.state=u)),d}_appendPlaceholder(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}appendTail(t){const n=new _e;return t&&n.aggregate(this._applyDispatch("",{},t)),n.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var n,r;return{...t,_beforeTailState:((n=t._beforeTailState)==null?void 0:n.currentMaskRef)===this.currentMask&&((r=t._beforeTailState)==null?void 0:r.currentMask)||t._beforeTailState}}doDispatch(t,n,r){return n===void 0&&(n={}),r===void 0&&(r=""),this.dispatch(t,this,n,r)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,n){n===void 0&&(n={});let[r,l]=super.doPrepare(t,n);if(this.currentMask){let a;[r,a]=super.doPrepare(r,this.currentMaskFlags(n)),l=l.aggregate(a)}return[r,l]}doPrepareChar(t,n){n===void 0&&(n={});let[r,l]=super.doPrepareChar(t,n);if(this.currentMask){let a;[r,a]=super.doPrepareChar(r,this.currentMaskFlags(n)),l=l.aggregate(a)}return[r,l]}reset(){var t;(t=this.currentMask)==null||t.reset(),this.compiledMasks.forEach(n=>n.reset())}get value(){return this.exposeMask?this.exposeMask.value:this.currentMask?this.currentMask.value:""}set value(t){this.exposeMask?(this.exposeMask.value=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.value=t}get unmaskedValue(){return this.exposeMask?this.exposeMask.unmaskedValue:this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){this.exposeMask?(this.exposeMask.unmaskedValue=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.unmaskedValue=t}get typedValue(){return this.exposeMask?this.exposeMask.typedValue:this.currentMask?this.currentMask.typedValue:""}set typedValue(t){if(this.exposeMask){this.exposeMask.typedValue=t,this.currentMask=this.exposeMask,this._applyDispatch();return}let n=String(t);this.currentMask&&(this.currentMask.typedValue=t,n=this.currentMask.unmaskedValue),this.unmaskedValue=n}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var t;return!!((t=this.currentMask)!=null&&t.isComplete)}get isFilled(){var t;return!!((t=this.currentMask)!=null&&t.isFilled)}remove(t,n){const r=new _e;return this.currentMask&&r.aggregate(this.currentMask.remove(t,n)).aggregate(this._applyDispatch()),r}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map(n=>n.state),currentMaskRef:this.currentMask,currentMask:(t=this.currentMask)==null?void 0:t.state}}set state(t){const{compiledMasks:n,currentMaskRef:r,currentMask:l,...a}=t;n&&this.compiledMasks.forEach((s,i)=>s.state=n[i]),r!=null&&(this.currentMask=r,this.currentMask.state=l),super.state=a}extractInput(t,n,r){return this.currentMask?this.currentMask.extractInput(t,n,r):""}extractTail(t,n){return this.currentMask?this.currentMask.extractTail(t,n):super.extractTail(t,n)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,n){return this.currentMask?this.currentMask.nearestInputPos(t,n):super.nearestInputPos(t,n)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(t){this._overwrite=t}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(t){this._eager=t}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(t){this._skipInvalid=t}get autofix(){return this.currentMask?this.currentMask.autofix:this._autofix}set autofix(t){this._autofix=t}maskEquals(t){return Array.isArray(t)?this.compiledMasks.every((n,r)=>{if(!t[r])return;const{mask:l,...a}=t[r];return An(n,a)&&n.maskEquals(l)}):super.maskEquals(t)}typedValueEquals(t){var n;return!!((n=this.currentMask)!=null&&n.typedValueEquals(t))}}Zt.DEFAULTS={...je.DEFAULTS,dispatch:(o,t,n,r)=>{if(!t.compiledMasks.length)return;const l=t.rawInputValue,a=t.compiledMasks.map((s,i)=>{const c=t.currentMask===s,d=c?s.displayValue.length:s.nearestInputPos(s.displayValue.length,fe.FORCE_LEFT);return s.rawInputValue!==l?(s.reset(),s.append(l,{raw:!0})):c||s.remove(d),s.append(o,t.currentMaskFlags(n)),s.appendTail(r),{index:i,weight:s.rawInputValue.length,totalInputPositions:s.totalInputPositions(0,Math.max(d,s.nearestInputPos(s.displayValue.length,fe.FORCE_LEFT)))}});return a.sort((s,i)=>i.weight-s.weight||i.totalInputPositions-s.totalInputPositions),t.compiledMasks[a[0].index]}},ke.MaskedDynamic=Zt;class Jt extends Ue{constructor(t){super({...Jt.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){const{enum:n,...r}=t;if(n){const l=n.map(i=>i.length),a=Math.min(...l),s=Math.max(...l)-a;r.mask="*".repeat(a),s&&(r.mask+="["+"*".repeat(s)+"]"),this.enum=n}super._update(r)}_appendCharRaw(t,n){n===void 0&&(n={});const r=Math.min(this.nearestInputPos(0,fe.FORCE_RIGHT),this.value.length),l=this.enum.filter(a=>this.matchValue(a,this.unmaskedValue+t,r));if(l.length){l.length===1&&this._forEachBlocksInRange(0,this.value.length,(s,i)=>{const c=l[0][i];i>=this.value.length||c===s.value||(s.reset(),s._appendChar(c,n))});const a=super._appendCharRaw(l[0][this.value.length],n);return l.length===1&&l[0].slice(this.unmaskedValue.length).split("").forEach(s=>a.aggregate(super._appendCharRaw(s))),a}return new _e({skip:!this.isComplete})}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new mt("",t)}remove(t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),t===n)return new _e;const r=Math.min(super.nearestInputPos(0,fe.FORCE_RIGHT),this.value.length);let l;for(l=t;l>=0&&!(this.enum.filter(i=>this.matchValue(i,this.value.slice(r,l),r)).length>1);--l);const a=super.remove(l,n);return a.tailShift+=l-t,a}get isComplete(){return this.enum.indexOf(this.value)>=0}}Jt.DEFAULTS={...Ue.DEFAULTS,matchValue:(o,t,n)=>o.indexOf(t,n)===n},ke.MaskedEnum=Jt;class Br extends je{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}ke.MaskedFunction=Br;var Vr;class We extends je{constructor(t){super({...We.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){const t="^"+(this.allowNegative?"[+|\\-]?":""),n="\\d*",r=(this.scale?"("+oo(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+n+r),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(oo).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(oo(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const n=t.split(this.radix);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),n.join(this.radix)}doPrepareChar(t,n){n===void 0&&(n={});const[r,l]=super.doPrepareChar(this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(n.input&&n.raw||!n.input&&!n.raw)?t.replace(this._mapToRadixRegExp,this.radix):t),n);return t&&!r&&(l.skip=!0),r&&!this.allowPositive&&!this.value&&r!=="-"&&l.aggregate(this._appendChar("-")),[r,l]}_separatorsCount(t,n){n===void 0&&(n=!1);let r=0;for(let l=0;l<t;++l)this._value.indexOf(this.thousandsSeparator,l)===l&&(++r,n&&(t+=this.thousandsSeparator.length));return r}_separatorsCountFromSlice(t){return t===void 0&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n),this._removeThousandsSeparators(super.extractInput(t,n,r))}_appendCharRaw(t,n){n===void 0&&(n={});const r=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,l=this._separatorsCountFromSlice(r);this._value=this._removeThousandsSeparators(this.value);const a=this._value;this._value+=t;const s=this.number;let i=!isNaN(s),c=!1;if(i){let h;this.min!=null&&this.min<0&&this.number<this.min&&(h=this.min),this.max!=null&&this.max>0&&this.number>this.max&&(h=this.max),h!=null&&(this.autofix?(this._value=this.format(h,this).replace(We.UNMASKED_RADIX,this.radix),c||(c=a===this._value&&!n.tail)):i=!1),i&&(i=!!this._value.match(this._numberRegExp))}let d;i?d=new _e({inserted:this._value.slice(a.length),rawInserted:c?"":t,skip:c}):(this._value=a,d=new _e),this._value=this._insertThousandsSeparators(this._value);const u=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,p=this._separatorsCountFromSlice(u);return d.tailShift+=(p-l)*this.thousandsSeparator.length,d}_findSeparatorAround(t){if(this.thousandsSeparator){const n=t-this.thousandsSeparator.length+1,r=this.value.indexOf(this.thousandsSeparator,n);if(r<=t)return r}return-1}_adjustRangeWithSeparators(t,n){const r=this._findSeparatorAround(t);r>=0&&(t=r);const l=this._findSeparatorAround(n);return l>=0&&(n=l+this.thousandsSeparator.length),[t,n]}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n);const r=this.value.slice(0,t),l=this.value.slice(n),a=this._separatorsCount(r.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(r+l));const s=this._separatorsCountFromSlice(r);return new _e({tailShift:(s-a)*this.thousandsSeparator.length})}nearestInputPos(t,n){if(!this.thousandsSeparator)return t;switch(n){case fe.NONE:case fe.LEFT:case fe.FORCE_LEFT:{const r=this._findSeparatorAround(t-1);if(r>=0){const l=r+this.thousandsSeparator.length;if(t<l||this.value.length<=l||n===fe.FORCE_LEFT)return r}break}case fe.RIGHT:case fe.FORCE_RIGHT:{const r=this._findSeparatorAround(t);if(r>=0)return r+this.thousandsSeparator.length}}return t}doCommit(){if(this.value){const t=this.number;let n=t;this.min!=null&&(n=Math.max(n,this.min)),this.max!=null&&(n=Math.min(n,this.max)),n!==t&&(this.unmaskedValue=this.format(n,this));let r=this.value;this.normalizeZeros&&(r=this._normalizeZeros(r)),this.padFractionalZeros&&this.scale>0&&(r=this._padFractionalZeros(r)),this._value=r}super.doCommit()}_normalizeZeros(t){const n=this._removeThousandsSeparators(t).split(this.radix);return n[0]=n[0].replace(/^(\D*)(0*)(\d*)/,(r,l,a,s)=>l+s),t.length&&!/\d$/.test(n[0])&&(n[0]=n[0]+"0"),n.length>1&&(n[1]=n[1].replace(/0*$/,""),n[1].length||(n.length=1)),this._insertThousandsSeparators(n.join(this.radix))}_padFractionalZeros(t){if(!t)return t;const n=t.split(this.radix);return n.length<2&&n.push(""),n[1]=n[1].padEnd(this.scale,"0"),n.join(this.radix)}doSkipInvalid(t,n,r){n===void 0&&(n={});const l=this.scale===0&&t!==this.thousandsSeparator&&(t===this.radix||t===We.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,n,r)&&!l}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,We.UNMASKED_RADIX)}set unmaskedValue(t){super.unmaskedValue=t}get typedValue(){return this.parse(this.unmaskedValue,this)}set typedValue(t){this.rawInputValue=this.format(t,this).replace(We.UNMASKED_RADIX,this.radix)}get number(){return this.typedValue}set number(t){this.typedValue=t}get allowNegative(){return this.min!=null&&this.min<0||this.max!=null&&this.max<0}get allowPositive(){return this.min!=null&&this.min>0||this.max!=null&&this.max>0}typedValueEquals(t){return(super.typedValueEquals(t)||We.EMPTY_VALUES.includes(t)&&We.EMPTY_VALUES.includes(this.typedValue))&&!(t===0&&this.value==="")}}Vr=We,We.UNMASKED_RADIX=".",We.EMPTY_VALUES=[...je.EMPTY_VALUES,0],We.DEFAULTS={...je.DEFAULTS,mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[Vr.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:o=>o.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},ke.MaskedNumber=We;const Dn={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function ao(o,t,n){t===void 0&&(t=Dn.MASKED),n===void 0&&(n=Dn.MASKED);const r=ft(o);return l=>r.runIsolated(a=>(a[t]=l,a[n]))}function Sr(o,t,n,r){return ao(t,n,r)(o)}ke.PIPE_TYPE=Dn,ke.createPipe=ao,ke.pipe=Sr;class $r extends Ue{get repeatFrom(){var t;return(t=Array.isArray(this.repeat)?this.repeat[0]:this.repeat===1/0?0:this.repeat)!=null?t:0}get repeatTo(){var t;return(t=Array.isArray(this.repeat)?this.repeat[1]:this.repeat)!=null?t:1/0}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){var n,r,l;const{repeat:a,...s}=Pt(t);this._blockOpts=Object.assign({},this._blockOpts,s);const i=ft(this._blockOpts);this.repeat=(n=(r=a??i.repeat)!=null?r:this.repeat)!=null?n:1/0,super._update({mask:"m".repeat(Math.max(this.repeatTo===1/0&&((l=this._blocks)==null?void 0:l.length)||0,this.repeatFrom)),blocks:{m:i},eager:i.eager,overwrite:i.overwrite,skipInvalid:i.skipInvalid,lazy:i.lazy,placeholderChar:i.placeholderChar,displayChar:i.displayChar})}_allocateBlock(t){if(t<this._blocks.length)return this._blocks[t];if(this.repeatTo===1/0||this._blocks.length<this.repeatTo)return this._blocks.push(ft(this._blockOpts)),this.mask+="m",this._blocks[this._blocks.length-1]}_appendCharRaw(t,n){n===void 0&&(n={});const r=new _e;for(let c=(l=(a=this._mapPosToBlock(this.displayValue.length))==null?void 0:a.index)!=null?l:Math.max(this._blocks.length-1,0),d,u;d=(s=this._blocks[c])!=null?s:u=!u&&this._allocateBlock(c);++c){var l,a,s,i;const p=d._appendChar(t,{...n,_beforeTailState:(i=n._beforeTailState)==null||(i=i._blocks)==null?void 0:i[c]});if(p.skip&&u){this._blocks.pop(),this.mask=this.mask.slice(1);break}if(r.aggregate(p),p.consumed)break}return r}_trimEmptyTail(t,n){var r,l;t===void 0&&(t=0);const a=Math.max(((r=this._mapPosToBlock(t))==null?void 0:r.index)||0,this.repeatFrom,0);let s;n!=null&&(s=(l=this._mapPosToBlock(n))==null?void 0:l.index),s==null&&(s=this._blocks.length-1);let i=0;for(let c=s;a<=c&&!this._blocks[c].unmaskedValue;--c,++i);i&&(this._blocks.splice(s-i+1,i),this.mask=this.mask.slice(i))}reset(){super.reset(),this._trimEmptyTail()}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._trimEmptyTail(t,n),r}totalInputPositions(t,n){return t===void 0&&(t=0),n==null&&this.repeatTo===1/0?1/0:super.totalInputPositions(t,n)}get state(){return super.state}set state(t){this._blocks.length=t._blocks.length,this.mask=this.mask.slice(0,this._blocks.length),super.state=t}}ke.RepeatBlock=$r;try{globalThis.IMask=ke}catch{}const so=Object.freeze(Object.defineProperty({__proto__:null,ChangeDetails:_e,ChunksTailDetails:Vt,DIRECTION:fe,HTMLContenteditableMaskElement:ro,HTMLInputMaskElement:Cr,HTMLMaskElement:Gt,InputMask:vr,MaskElement:Fn,Masked:je,MaskedDate:ht,MaskedDynamic:Zt,MaskedEnum:Jt,MaskedFunction:Br,MaskedNumber:We,MaskedPattern:Ue,MaskedRange:Xt,MaskedRegExp:Er,PIPE_TYPE:Dn,PatternFixedDefinition:lo,PatternInputDefinition:Yt,RepeatBlock:$r,createMask:ft,createPipe:ao,default:ke,forceDirection:xr,normalizeOpts:Pt,pipe:Sr},Symbol.toStringTag,{value:"Module"})),$m=async o=>{try{const t=new FormData;return t.append("unique","true"),t.append("file",o),(await(await fetch("/file/upload/uploads?id=&form=&table=",{method:"POST",body:t})).json())?.result}catch(t){console.error(t)}},Nm=async(o,t,n)=>{const r=t.clipboardData?.items;if(r){const l=t.clipboardData?.getData("text/html"),a=t.clipboardData?.getData("text/plain");if(l){const{state:s,dispatch:i}=o,{tr:c}=s,d=n.fromSchema(o.state.schema),u=new DOMParser().parseFromString(l,"text/html").body,p=d.parse(u),h=c.replaceSelectionWith(p);return i(h),t.preventDefault(),!0}if(a){const{state:s,dispatch:i}=o,{tr:c}=s,d=c.insertText(a,s.selection.from,s.selection.to);return i(d),t.preventDefault(),!0}for(let s=0;s<r.length;s++){const i=r[s];if(i.type.startsWith("image/")){const c=i.getAsFile();if(c){const d=await $m(c),{schema:u}=o.state,p=u.nodes.image.create({src:d?.file_path}),h=o.state.tr.replaceSelectionWith(p);return o.dispatch(h),t.preventDefault(),!0}}}}return!1},Am="https://esm.sh",Ye="3.7.2",Nr="3.7.2",Fm=`?deps=@tiptap/core@${Ye},@tiptap/pm@${Nr}`,Xe=o=>`${Am}/${o}${Fm}`,Ze={core:Xe(`@tiptap/core@${Ye}`),starterKit:Xe(`@tiptap/starter-kit@${Ye}`),textStyle:Xe(`@tiptap/extension-text-style@${Ye}`),table:Xe(`@tiptap/extension-table@${Ye}`),highlight:Xe(`@tiptap/extension-highlight@${Ye}`),subscript:Xe(`@tiptap/extension-subscript@${Ye}`),superscript:Xe(`@tiptap/extension-superscript@${Ye}`),link:Xe(`@tiptap/extension-link@${Ye}`),image:Xe(`@tiptap/extension-image@${Ye}`),textAlign:Xe(`@tiptap/extension-text-align@${Ye}`),heading:Xe(`@tiptap/extension-heading@${Ye}`),paragraph:Xe(`@tiptap/extension-paragraph@${Ye}`),pmModel:Xe(`@tiptap/pm@${Nr}/model`)},Qt="__vs_form_tiptap_loader__",Je=o=>import(o),Ie=(o,t)=>o?.[t]||o?.default?.[t]||o?.default?.default?.[t]||o?.default||o,Ar={1:"font-weight:700; font-size:30px;",2:"font-weight:700; font-size:26px;",3:"font-weight:700; font-size:22px;",4:"font-weight:700; font-size:18px;",5:"font-weight:500; font-size:16px;",6:"font-weight:400; font-size:14px;"},Mm=o=>o.extend({addOptions(){return{...this.parent?.(),levels:[1,2,3,4,5,6]}}}).extend({addAttributes(){return{...this.parent?.(),level:{default:1,renderHTML:t=>{const n=t.level||1;return{class:`heading-level-${n}`,style:Ar[n]||Ar[1]}}}}}}),Dm=o=>o.configure({HTMLAttributes:{style:"min-height: 1rem;"}}),Tm=(o,t,n,r,l)=>{const a=t.extend({renderHTML({HTMLAttributes:s}){return["div",{style:"overflow-x: auto;"},["table",s,0]]},parseHTML(){return[{tag:"div.table-wrapper table",priority:100},{tag:"table"}]}});return o.extend({addExtensions(){return[a.configure({HTMLAttributes:{class:"editor-content"},resizable:!0}),n,r,l]}})},Lm=o=>o.extend({addAttributes(){return{...this.parent?.(),fontFamily:{default:null,parseHTML:t=>t.style.fontFamily?.replace(/['"]/g,""),renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}},fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}},color:{default:null,parseHTML:t=>t.style.color?.replace(/['"]/g,""),renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}},backgroundColor:{default:null,parseHTML:t=>t.style.backgroundColor?.replace(/['"]/g,""),renderHTML:t=>!t.backgroundColor||t.backgroundColor==="transparent"?{}:{style:`background-color: ${t.backgroundColor}`}}}},addCommands(){return{setFontFamily:t=>({chain:n})=>n().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run(),setFontSize:t=>({chain:n})=>n().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run(),setColor:t=>({chain:n})=>n().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run(),setBackgroundColor:t=>({chain:n})=>n().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Im=o=>o.create({name:"iframe",group:"block",inline:!1,atom:!0,selectable:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"280"},frameborder:{default:"0"},allow:{default:null},allowfullscreen:{default:null},referrerpolicy:{default:null},loading:{default:null},class:{default:null},title:{default:null},style:{default:null}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",t]}});async function Rm(){if(typeof window>"u")return null;const o=window;return o[Qt]||(o[Qt]=Promise.all([Je(Ze.core),Je(Ze.starterKit),Je(Ze.textStyle),Je(Ze.table),Je(Ze.highlight),Je(Ze.subscript),Je(Ze.superscript),Je(Ze.link),Je(Ze.image),Je(Ze.textAlign),Je(Ze.heading),Je(Ze.paragraph),Je(Ze.pmModel)]).then(([t,n,r,l,a,s,i,c,d,u,p,h,x])=>{const m=Ie(t,"Editor"),b=Ie(t,"Node"),g=Ie(t,"Extension"),C=Ie(n,"StarterKit"),k=Ie(r,"TextStyle"),w=Ie(l,"TableKit"),V=Ie(l,"Table"),R=Ie(l,"TableRow"),Y=Ie(l,"TableCell"),L=Ie(l,"TableHeader"),B=Ie(a,"Highlight"),S=Ie(s,"Subscript"),$=Ie(i,"Superscript"),E=Ie(c,"Link"),N=Ie(d,"Image"),I=Ie(u,"TextAlign"),v=Ie(p,"Heading"),M=Ie(h,"Paragraph"),D=Ie(x,"DOMParser");if(!m||!b||!C||!k||!w||!V||!R||!Y||!L||!B||!S||!$||!E||!N||!I||!v||!M||!D)throw new Error("Failed to resolve one or more Tiptap modules");return{Editor:m,Extension:g,ProseMirrorDOMParser:D,StarterKit:C,ExtendedTextStyle:Lm(k),Highlight:B,Subscript:S,Superscript:$,Link:E,Image:N,TextAlign:I,CustomHeading:Mm(v),CustomParagraph:Dm(M),CustomTableKit:Tm(w,V,R,Y,L),Iframe:Im(b)}}).catch(t=>{throw delete o[Qt],t})),o[Qt]}function Om(o){let t=!1;const n=e.shallowRef(null),r=e.ref(!1),l=e.ref(""),a=async(d,u="")=>{if(!d)return null;r.value=!0,l.value="";try{const p=await Rm();if(!p)return null;const h=new p.Editor({element:d,content:u,extensions:[p.StarterKit.configure({history:{depth:100,newGroupDelay:500},code:{HTMLAttributes:{class:"editor-code"}},codeBlock:{HTMLAttributes:{class:"editor-codeblock"}},paragraph:!1,heading:!1,link:!1}),p.Superscript,p.Subscript,p.ExtendedTextStyle,p.CustomParagraph,p.CustomHeading,p.Highlight,p.Image.configure({inline:!0,allowBase64:!0,HTMLAttributes:{class:"editor-image"}}),p.TextAlign.configure({types:["heading","paragraph"]}),p.Link.configure({HTMLAttributes:{class:"editor-link"},openOnClick:!1,autolink:!0}),p.CustomTableKit,p.Iframe],editorProps:{handlePaste:(x,m)=>Nm(x,m,p.ProseMirrorDOMParser),handleKeyDown:(x,m)=>{if(m.key==="Tab"){const b=x.state,{$anchor:g}=b.selection;let C=!1;for(let k=g.depth;k>0;k--){const w=g.node(k);if(w&&(w.type.name==="bulletList"||w.type.name==="orderedList")){C=!0;break}}return C?!1:(m.preventDefault(),!0)}return!1}}});return n.value=e.markRaw(h),h}catch(p){return l.value="Failed to load rich text editor dependencies.",console.error("Failed to initialize rich text editor",p),null}finally{r.value=!1}},s=e.computed(()=>n.value||null);return e.watch(n,d=>{d&&n.value.on("update",u=>{if(!t){t=!0;const p=u.editor.getHTML();o.modelValue,setTimeout(()=>{t=!1},10)}})}),{editor:n,editorInstance:s,focusEditor:()=>{n.value&&!n.value.isFocused&&n.value.commands.focus()},createEditor:a,destroyEditor:()=>{n.value&&(n.value.destroy(),n.value=null)},isLoading:r,loadError:l}}function zm(o,t,n,{toEditorContent:r,toSourceContent:l}={}){const a=e.ref(!1),s=e.ref(""),i=e.ref(null);return{isHtmlMode:a,htmlContent:s,htmlTextarea:i,toggleHtmlMode:async u=>{if(a.value=u,u)o.value&&(s.value=l?await l(o.value.getHTML(),t):o.value.getHTML()),e.nextTick(()=>{i.value&&i.value.focus?.()});else if(o.value){const p=r?await r(s.value,t):s.value;o.value.commands.setContent(p,!0),e.nextTick(()=>{o.value?.commands?.focus?.()})}},onHtmlInput:u=>{s.value=u,n&&n("update:modelValue",u)}}}function Pm(){const o=e.ref(!1);return{isFullscreen:o,toggleFullscreen:()=>{o.value=!o.value}}}const St=o=>o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),en=o=>{let t=St(o||"");return t=t.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,r,l,a)=>{const s=a?` title="${St(a)}"`:"";return`<img src="${St(l)}" alt="${St(r)}"${s}>`}),t=t.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,r,l,a)=>{const s=a?` title="${St(a)}"`:"";return`<a href="${St(l)}"${s} target="_blank" rel="noopener noreferrer">${r}</a>`}),t=t.replace(/`([^`]+)`/g,"<code>$1</code>"),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t=t.replace(/__([^_]+)__/g,"<strong>$1</strong>"),t=t.replace(/~~([^~]+)~~/g,"<del>$1</del>"),t=t.replace(/\*([^*\n]+)\*/g,"<em>$1</em>"),t=t.replace(/_([^_\n]+)_/g,"<em>$1</em>"),t},tn=o=>/^\s*\d+\.\s+/.test(o),io=o=>/^\s*[-*+]\s+/.test(o),Fr=o=>/^\s*[-*+]\s+\[[ xX]\]\s+/.test(o),co=o=>/^\s*>\s?/.test(o),uo=o=>/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(o),Mr=o=>o.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>en(t.trim())),jm=(o,t)=>{const n=o[t],r=o[t+1];if(!n||!r||!n.includes("|")||!uo(r))return null;const l=Mr(n),a=[];let s=t+2;for(;s<o.length&&o[s].includes("|")&&o[s].trim()!=="";){const d=Mr(o[s]);a.push(`<tr>${d.map(u=>`<td>${u}</td>`).join("")}</tr>`),s+=1}const i=`<thead><tr>${l.map(d=>`<th>${d}</th>`).join("")}</tr></thead>`,c=a.length?`<tbody>${a.join("")}</tbody>`:"";return{html:`<table>${i}${c}</table>`,nextIndex:s}},Um=(o,t)=>{const n=tn(o[t]),r=n?"ol":"ul",l=[];let a=t;for(;a<o.length;){const s=o[a];if(s.trim()===""||!(n?tn(s):(io(s)||Fr(s))&&!tn(s)))break;const c=s.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);if(c){const d=c[1].toLowerCase()==="x";l.push(`<li><input type="checkbox" disabled${d?" checked":""}> ${en(c[2])}</li>`)}else{const d=s.replace(/^\s*(?:[-*+]|\d+\.)\s+/,"");l.push(`<li>${en(d)}</li>`)}a+=1}return{html:`<${r}>${l.join("")}</${r}>`,nextIndex:a}},Hm=(o,t)=>{const r=o[t].replace(/^```/,"").trim(),l=[];let a=t+1;for(;a<o.length&&!o[a].startsWith("```");)l.push(o[a]),a+=1;return{html:`<pre><code${r?` class="language-${St(r)}"`:""}>${St(l.join(`
6
6
  `))}</code></pre>`,nextIndex:a<o.length?a+1:a}},qm=(o,t)=>{const n=[];let r=t;for(;r<o.length;){const l=o[r];if(l.trim()===""||l.startsWith("```")||/^#{1,6}\s+/.test(l)||/^---+$/.test(l.trim())||/^\*\*\*+$/.test(l.trim())||co(l)||tn(l)||io(l)||r+1<o.length&&l.includes("|")&&uo(o[r+1]))break;n.push(l.trim()),r+=1}return{html:`<p>${en(n.join(" "))}</p>`,nextIndex:r}},Dr=o=>{const n=(o||"").replace(/\r\n/g,`
7
7
  `).split(`