@opengis/form 0.0.170 → 0.0.171
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
(function(we,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):(we=typeof globalThis<"u"?globalThis:we||self,e(we.FormBuilder={},we.Vue,we.OpenGISCore,we.lucide))})(this,(function(we,e,ye,q){"use strict";const $o=e.defineComponent({__name:"vs-info-tooltip",props:{text:{}},setup(n){const t=n,o=e.ref(!1),r=e.ref({top:"0px",left:"0px"});function l(s){if(!t.text)return;const c=s.currentTarget.getBoundingClientRect();r.value={top:`${c.bottom+4}px`,left:`${Math.min(c.left,window.innerWidth-230)}px`},o.value=!0}function a(){o.value=!1}return(s,c)=>(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(q.Info),{class:"h-4 w-4 text-gray-400 cursor-help"})])],32),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[o.value&&n.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(n.text),5)):e.createCommentVNode("",!0)]))],64))}}),Kn={form:{autofillFrom:"Filled from",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"}}},Wn={form:{autofillFrom:"Підставлено з",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:"Скасувати"}}},tl={class:"w-full relative"},nl={key:0,class:"text-[14px] font-medium text-gray-900 mb-2 flex items-center gap-1"},ol={class:"opacity-100"},rl={key:0,class:"text-red-500 text-[14px]"},ll={key:2,class:"text-[11px] text-slate-500 font-normal"},al={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},sl=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(n){const t=n,o=e.computed(()=>typeof t.item?.label=="string"&&t.item.label?t.item.label:t.item?.ua||t.label||t.ua),r=e.computed(()=>!!o.value),l=e.computed(()=>!!t.item?.rules?.includes("required")),a=e.computed(()=>t.item?.info||""),s=e.inject("schema-by-name"),c={en:Kn?.form?.autofillFrom,uk:Wn?.form?.autofillFrom},i=e.computed(()=>{const d=t.item?.__autoMeta;if(!d||d?.source!=="parent-auto"||!d?.parentField)return"";const u=String(t.item?.__locale||"uk"),p=String(d.parentField),f=s?.value?.[p],y=f?.[`label:${u}`]||(u!=="uk"?f?.[u]:void 0)||f?.label||f?.ua||f?.en||p;return`${c[u]||c.uk}: ${y}`});return(d,u)=>(e.openBlock(),e.createElementBlock("div",tl,[r.value?(e.openBlock(),e.createElementBlock("div",nl,[e.createElementVNode("span",ol,e.toDisplayString(o.value),1),l.value?(e.openBlock(),e.createElementBlock("span",rl,"*")):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock($o,{key:1,text:a.value},null,8,["text"])):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",ll," ("+e.toDisplayString(i.value)+") ",1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(d.$slots,"default",e.mergeProps(d.$attrs,{class:{"opacity-60":n.item.disabled}})),n.error?(e.openBlock(),e.createElementBlock("span",al,e.toDisplayString(n.error),1)):e.createCommentVNode("",!0)]))}}),il={class:"w-full relative flex flex-row items-center gap-2"},cl={key:0,class:"text-red-500 text-[14px]"},dl={key:2,class:"text-[11px] text-slate-500 font-normal"},ul={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},pl=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(n){const t=n,o=e.computed(()=>t.item?.label||t.label||t.ua),r=e.computed(()=>t.item?.info||""),l=e.inject("schema-by-name"),a={en:Kn?.form?.autofillFrom,uk:Wn?.form?.autofillFrom},s=e.computed(()=>{const f=t.item?.__autoMeta;if(!f||f?.source!=="parent-auto"||!f?.parentField)return"";const y=String(t.item?.__locale||"uk"),h=String(f.parentField),k=l?.value?.[h],g=k?.[`label:${y}`]||(y!=="uk"?k?.[y]:void 0)||k?.label||k?.ua||k?.en||h;return`${a[y]||a.uk}: ${g}`}),c=e.computed(()=>t.columns??{container:12,label:3}),i=e.computed(()=>{const{container:f,label:y}=c.value;return!f||f<=0?0:Math.min(Math.max(y??0,0),f)/f}),d=e.computed(()=>t.item?.type==="html"||i.value<=0?!1:!!o.value),u=e.computed(()=>{if(!d.value)return{};const f=`${i.value*100}%`;return{flexBasis:f,maxWidth:f}}),p=e.computed(()=>{const{container:f,label:y}=c.value;if(!f||f<=0)return{};if(t.item?.type==="html")return{flexBasis:"100%",maxWidth:"100%"};if(!d.value)return{flexBasis:"100%",maxWidth:"100%"};const h=Math.max(f-Math.max(y??0,0),0)/f;if(!h)return{};const k=`${h*100}%`;return{flexBasis:k,maxWidth:k}});return(f,y)=>(e.openBlock(),e.createElementBlock("div",il,[d.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(u.value)},[e.createTextVNode(e.toDisplayString(o.value)+" ",1),n.item?.rules?.includes("required")&&o.value?(e.openBlock(),e.createElementBlock("span",cl,"*")):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createBlock($o,{key:1,text:r.value},null,8,["text"])):e.createCommentVNode("",!0),s.value?(e.openBlock(),e.createElementBlock("span",dl," ("+e.toDisplayString(s.value)+") ",1)):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"flex-1 min-w-0",style:e.normalizeStyle(p.value)},[e.renderSlot(f.$slots,"default",e.normalizeProps(e.guardReactiveProps(f.$attrs)))],4),n.error?(e.openBlock(),e.createElementBlock("span",ul,e.toDisplayString(n.error),1)):e.createCommentVNode("",!0)]))}}),ml={class:"w-full relative"},fl={key:0,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},hl=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(n){return(t,o)=>(e.openBlock(),e.createElementBlock("div",ml,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(t.$attrs))),n.error?(e.openBlock(),e.createElementBlock("span",fl,e.toDisplayString(n.error),1)):e.createCommentVNode("",!0)]))}}),gl={class:"flex-1 min-w-0"},yl={key:0,class:"text-sm font-medium text-slate-700 dark:text-slate-200 flex items-center gap-1"},bl={class:"truncate"},kl={key:0,class:"text-red-500 text-[14px]"},xl=["innerHTML"],wl={key:0,class:"mt-1 text-xs text-red-500"},Cl={default:sl,horizontal:pl,inline:hl,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(n){const t=n,o=e.ref("uk");e.computed(()=>(t.item??{})?.[o.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 c=typeof localStorage<"u"?localStorage.getItem("locale"):null;o.value=c||"uk"};return e.onMounted(()=>{try{typeof localStorage<"u"&&localStorage.locale&&(o.value=localStorage.locale)}catch{}window.addEventListener("storage",s)}),e.onUnmounted(()=>{window.removeEventListener("storage",s)}),(c,i)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-full relative",{"opacity-60":n.item?.disabled}])},[e.createElementVNode("div",{class:e.normalizeClass(["gap-2 md:flex-row md:items-center md:justify-between",[["switcher","native-select"].includes(n.item.type)?"flex flex-col":""]])},[e.createElementVNode("div",gl,[n.ua||n.label?(e.openBlock(),e.createElementBlock("p",yl,[e.createElementVNode("span",bl,e.toDisplayString(n.item[o.value]||n.ua||n.label),1),l.value?(e.openBlock(),e.createElementBlock("span",kl,"*")):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,xl)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["w-full",["select","native-select"].includes(n.item.type)?"md:w-[30%]":"md:w-auto"])},[e.renderSlot(c.$slots,"default",e.normalizeProps(e.guardReactiveProps(c.$attrs)))],2)],2),a.value?(e.openBlock(),e.createElementBlock("p",wl,e.toDisplayString(a.value),1)):e.createCommentVNode("",!0)],2))}})};function Ge(n){return{inputClass:e.computed(()=>{const o=`disabled:opacity-50 disabled:cursor-not-allowed outline-none focus:ring-2 focus:ring-ring focus:ring-${n?.primaryColor||"blue"}-500 border border-solid border-stone-200 rounded-md text-sm text-stone-800 placeholder:text-stone-400 `;return n?.size==="sm"?`${o}h-[32px]`:`${o}h-[38px]`})}}const vl=["placeholder","disabled"],El=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(n){const t=n,{inputClass:o}=Ge(t.style),r=e.useModel(n,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");return(s,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"password","onUpdate:modelValue":c[0]||(c[0]=i=>r.value=i),placeholder:a.value,disabled:l.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(o),{"!border-red-600":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,vl)),[[e.vModelText,r.value]])}}),Bl=["placeholder","disabled","maxlength","minlength"],jt=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(n){const t=n,{inputClass:o}=Ge(t.style),r=e.useModel(n,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??""),s=e.computed(()=>t.maxlength??void 0),c=e.computed(()=>t.minlength??void 0);function i(){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:c.value,onBlur:i,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[n.customClass,e.unref(o),{"!border-red-600":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,Bl)),[[e.vModelText,r.value]])}}),_l=["step","placeholder","disabled","min","max"],No=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(n){const t=n,{inputClass:o}=Ge(t.style),r=e.useAttrs(),l=e.useModel(n,"modelValue"),a=e.computed(()=>!!t.disabled),s=u=>{if(u==null||u==="")return;const p=typeof u=="string"?u.trim().replace(",","."):u,f=Number(p);return Number.isFinite(f)?f:void 0},c=e.computed(()=>s(t.min??r.min)),i=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]=f=>l.value=f),placeholder:n.placeholder,disabled:a.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white",[e.unref(o)]]),style:{border:"1px solid #CFD9E0"},min:c.value,max:i.value},null,10,_l)),[[e.vModelText,l.value]])}}),fn=n=>!!String(n??"").trim(),Vt=n=>n?.color?String(n.color):"",Wt=n=>{const t=n?.icon;if(typeof t=="string")return t;const o=n?.imgUrl;return typeof o=="string"?o:""},Gt=n=>{const t=n?.icon;return t&&typeof t!="string"?t:null},Vl={class:"flex items-center gap-[4px]"},Sl=["value","id","disabled"],$l=["for"],Nl=["innerHTML"],Al={key:1,class:"text-[14px] text-gray-700 flex items-center gap-2 dark:text-neutral-400"},Ml=["src"],Fl=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(n,{emit:t}){const o=t,r=n,l=e.computed({get:()=>r.modelValue,set:y=>o("update:modelValue",y)}),a=e.computed(()=>!!r.disabled),s=e.computed(()=>Wt(r.option)),c=e.computed(()=>Gt(r.option)),i=e.computed(()=>Vt(r.option)),d=e.computed(()=>!!(i.value&&!s.value&&!c.value)),u=e.computed(()=>!!(s.value&&i.value)),p=e.computed(()=>i.value?{color:i.value}:void 0),f=e.computed(()=>{if(!(!s.value||!i.value))return{backgroundColor:i.value,WebkitMaskImage:`url(${s.value})`,maskImage:`url(${s.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(y,h)=>(e.openBlock(),e.createElementBlock("div",Vl,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",value:n.value,"onUpdate:modelValue":h[0]||(h[0]=k=>l.value=k),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:n.id,disabled:a.value},null,10,Sl),[[e.vModelCheckbox,l.value]]),e.createElementVNode("label",{for:n.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",n.error?"border-red-600":""]])},[e.createVNode(e.unref(q.Check),{class:"h-4 w-4"})],2),n.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:n.html},null,8,Nl)):(e.openBlock(),e.createElementBlock("span",Al,[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:i.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(f.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,Ml)):c.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(c.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(p.value)},null,8,["style"])):e.createCommentVNode("",!0),e.renderSlot(y.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(n.label),1)])]))],10,$l)]))}}),Dl=["name","value","disabled"],Tl=["innerHTML"],Ll={key:1,class:"flex items-center gap-[6px] text-[14px]"},Il={key:2,class:"text-[16px] inline-flex items-center justify-center"},Ol=["src"],Rl=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(n,{emit:t}){const o=n,r=t,l=e.computed({get:()=>o.modelValue,set:k=>{r("update:modelValue",k)}}),a=e.computed(()=>Array.isArray(l.value)?l.value.includes(o.value):l.value===!0||l.value===o.value),s=e.computed(()=>o.style?.size==="xs"?"p-1.5 text-xs":o.style?.size==="lg"?"p-3.5 text-[20px]":"p-2.5 text-xs"),c=e.computed(()=>({...o.option??{},icon:o.option?.icon??o.icon,imgUrl:o.option?.imgUrl??o.imgUrl,color:o.option?.color})),i=e.computed(()=>Wt(c.value)),d=e.computed(()=>Gt(c.value)),u=e.computed(()=>Vt(c.value)),p=e.computed(()=>!!(u.value&&!i.value&&!d.value)),f=e.computed(()=>!!(i.value&&u.value)),y=e.computed(()=>u.value?{color:u.value}:void 0),h=e.computed(()=>{if(!(!i.value||!u.value))return{backgroundColor:u.value,WebkitMaskImage:`url(${i.value})`,maskImage:`url(${i.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(k,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:n.id,value:n.value,"onUpdate:modelValue":g[0]||(g[0]=v=>l.value=v),disabled:n.disabled},null,8,Dl),[[e.vModelCheckbox,l.value]]),n.html?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-full",innerHTML:n.html},null,8,Tl)):(e.openBlock(),e.createElementBlock("span",Ll,[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),f.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(h.value)},null,4)):i.value||d.value?(e.openBlock(),e.createElementBlock("span",Il,[i.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.value,width:"16",height:"16",alt:"icon"},null,8,Ol)):d.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),{key:1,class:"h-4 w-4",style:e.normalizeStyle(y.value)},null,8,["style"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(k.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(n.label),1)])]))],2))}}),Pl={class:"flex items-center"},Gn=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(n,{emit:t}){const o=n,r=t,l=`radio-${Math.floor(Math.random()*1e4)}`,a=e.computed({get:()=>Array.isArray(o.modelValue)?Array.isArray(o.modelValue)&&o.modelValue.includes(o.value):o.modelValue,set:c=>{if(Array.isArray(o.modelValue)){let i=[...o.modelValue];c?i.includes(o.value)||i.push(o.value):i=i.filter(d=>d!==o.value),r("update:modelValue",i)}else r("update:modelValue",c)}}),s=e.ref(`vs-checkbox-${o.view||"default"}`);return(c,i)=>(e.openBlock(),e.createElementBlock("div",Pl,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value==="vs-checkbox-buttons"?e.unref(Rl):e.unref(Fl)),{value:n.value,label:n.label,html:n.labelHtml,info:n.option?.info,disabled:n.disabled,modelValue:a.value,"onUpdate:modelValue":i[0]||(i[0]=d=>a.value=d),id:l,icon:n.icon,imgUrl:n.imgUrl,option:n.option,style:e.normalizeStyle(n.style),error:n.error},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(n.label),1)]),_:1},8,["value","label","html","info","disabled","modelValue","icon","imgUrl","option","style","error"]))]))}}),zl={key:0,class:"flex items-start gap-x-1"},jl={key:0,class:"text-red-500 text-[14px]"},Ul=["title"],Hl=["disabled"],Yn=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(n){const t=n,o=e.useModel(n,"modelValue");return(r,l)=>t.view==="checkbox"?(e.openBlock(),e.createElementBlock("div",zl,[e.createVNode(Gn,{modelValue:o.value,"onUpdate:modelValue":l[0]||(l[0]=a=>o.value=a),error:n.error||""},null,8,["modelValue","error"]),n.rules?.includes("required")?(e.openBlock(),e.createElementBlock("span",jl,"*")):e.createCommentVNode("",!0),n.i?(e.openBlock(),e.createElementBlock("button",{key:1,class:"cursor-pointer",title:n.i,onClick:l[1]||(l[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(e.unref(q.Info),{class:"h-4 w-4 text-gray-500"})],8,Ul)):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",[o.value?`bg-${n.style?.primaryColor||"blue"}-500`:"bg-stone-200",n.customClass]]),disabled:n.disabled,onClick:l[2]||(l[2]=a=>o.value=!o.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",[o.value?"translate-x-4":"translate-x-0"]])},null,2)],10,Hl))}}),ql=["id","innerHTML"],Xn=e.defineComponent({__name:"vs-input-static",props:{text:{default:""},html:{default:""},style:{},customClass:{default:""},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("div",{id:n.name,class:e.normalizeClass(["text-gray-900",n.customClass]),innerHTML:n.html?n.html:n.text},null,10,ql))}}),Kl=["placeholder","disabled","name"],hn=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(n){const t=n,{inputClass:o}=Ge(t.style),r=e.useModel(n,"modelValue"),l=e.ref(null);let a=null;function s(c){const i={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},d=new Set;let u=!1;for(let f=0;f<c.length;f+=1){const y=c[f];y==="{"?u=!0:y==="}"?u=!1:u&&d.add(y)}const p={};return Object.keys(i).forEach(f=>{d.has(f)||(p[f]=i[f])}),{mask:c,definitions:p,lazy:!1}}return e.onMounted(async()=>{if(l.value){const{default:c}=await Promise.resolve().then(()=>Pn),i=s(t.mask||"");a=c(l.value,i),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,c=>{if(a){const i=s(c||"");a.updateOptions(i)}}),e.watch(r,c=>{a&&a.unmaskedValue!==c&&(a.value=c!=null?String(c):"")}),(c,i)=>(e.openBlock(),e.createElementBlock("input",{type:"text",ref_key:"inputEl",ref:l,placeholder:n.placeholder,disabled:n.disabled,name:n.name,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(o)]]),style:{border:"1px solid #CFD9E0"}},null,10,Kl))}}),Wl={class:"relative w-full bg-white rounded-lg"},Gl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},Yl=["placeholder","disabled"],Zn=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(n){const t=n,{inputClass:o}=Ge(t.style),r=e.useModel(n,"modelValue");return(l,a)=>(e.openBlock(),e.createElementBlock("div",Wl,[e.createElementVNode("div",Gl,[e.createVNode(e.unref(q.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:n.placeholder,disabled:n.disabled,class:e.normalizeClass(["!pl-8 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(o),{"!border-red-600":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Yl),[[e.vModelText,r.value]])]))}}),wt="+99(999)-999-99-99";function St(n){if(!n?.trim())return 0;const t=new Set(["9","0","a","A","*"]);let o=!1,r=0;for(let l=0;l<n.length;l+=1){const a=n[l];if(a==="{"){o=!0;continue}if(a==="}"){o=!1;continue}!o&&t.has(a)&&(r+=1)}return r}const Xl={class:"relative w-full bg-white rounded-lg"},Zl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] pointer-events-none"},Jl=["name","placeholder","disabled","pattern"],Jn=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:{},mask:{default:wt}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const t=n,o=e.computed(()=>`^\\+[1-9]\\d{${(St(t.mask||wt)||St(wt))-1}}$`),{inputClass:r}=Ge(t.style),l=e.useModel(n,"modelValue"),a=e.ref(null);let s=null;function c(u){const p={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},f=new Set;let y=!1;for(let k=0;k<u.length;k+=1){const g=u[k];g==="{"?y=!0:g==="}"?y=!1:y&&f.add(g)}const h={};return Object.keys(p).forEach(k=>{f.has(k)||(h[k]=p[k])}),{mask:u,definitions:h,lazy:!1,disabled:t.disabled}}function i(u){if(u==null||u==="")return"";const p=String(u).trim();return p?p.replace(/\D/g,""):""}function d(){if(!s)return;const u=s.unmaskedValue??"";l.value=u?`+${u}`:""}return e.onMounted(async()=>{if(!a.value)return;const{default:u}=await Promise.resolve().then(()=>Pn),p=c(t.mask||"");s=u(a.value,p),s.on("accept",d),s.on("complete",d);const f=i(l.value);s.unmaskedValue=f}),e.onBeforeUnmount(()=>{s?.destroy(),s=null}),e.watch(()=>t.mask,u=>{s&&s.updateOptions(c(u||""))}),e.watch(()=>t.disabled,u=>{s&&s.updateOptions({disabled:u})}),e.watch(l,u=>{if(!s)return;const p=i(u);s.unmaskedValue!==p&&(s.unmaskedValue=p)}),(u,p)=>(e.openBlock(),e.createElementBlock("div",Xl,[e.createElementVNode("div",Zl,[e.createVNode(e.unref(q.Phone),{class:"h-4 w-4 stroke-gray-500 transition-all"})]),e.createElementVNode("input",{ref_key:"inputEl",ref:a,type:"tel",name:n.name,placeholder:n.placeholder,disabled:n.disabled,pattern:o.value,title:"Міжнародний номер (E.164), наприклад +380XXXXXXXXX",autocomplete:"tel",class:e.normalizeClass(["!pl-10 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(r),{"!border-red-600":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Jl)]))}}),Ql=["value","disabled"],ea=["innerHTML"],ta={key:1,class:"flex items-center gap-2"},na=["src"],oa={class:"text-[13px] text-gray-700"},ra=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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Wt(t.option)),a=e.computed(()=>Gt(t.option)),s=e.computed(()=>Vt(t.option)),c=e.computed(()=>!!(s.value&&!l.value&&!a.value)),i=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,f)=>(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":f[0]||(f[0]=y=>o.value=y),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,Ql),[[e.vModelRadio,o.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":""]])},[o.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,ea)):(e.openBlock(),e.createElementBlock("div",ta,[c.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),i.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,na)):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",oa,e.toDisplayString(t.text),1)]))],2))}}),la=["value","disabled"],aa=["innerHTML"],sa={key:1,class:"flex items-center gap-2"},ia=["src"],ca={class:"text-[13px] text-gray-700"},da={"vs-input-radio-default":ra,"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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Wt(t.option)),a=e.computed(()=>Gt(t.option)),s=e.computed(()=>Vt(t.option)),c=e.computed(()=>!!(s.value&&!l.value&&!a.value)),i=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,f)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex h-full w-full items-center border rounded-lg px-2 py-1",[o.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":f[0]||(f[0]=y=>o.value=y),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,la),[[e.vModelRadio,o.value]]),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,aa)):(e.openBlock(),e.createElementBlock("div",sa,[c.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),i.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,ia)):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",ca,e.toDisplayString(t.text),1)]))],2))}})},Ao=n=>Array.isArray(n)?n:Array.isArray(n?.data)?n.data:[],Mo=n=>{const t=n.host??"",o=n.prefix??"api",r=n.api??`/${o}/suggest/${n.data}`;return`${t}${r}`},ua=n=>({fetchOptions:async(r="")=>{const l=n();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 c=await(await fetch(`${Mo(l)}?${a.toString()}`)).json();return Ao(c)}catch{return[]}},fetchOptionByValue:async r=>{if(r==null||r==="")return null;const l=n();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 c=await(await fetch(`${Mo(l)}?${a.toString()}`)).json();return Ao(c)[0]??null}catch{return null}}}),gn=({props:n,formValues:t=null,watchParent:o=!0})=>{const r=e.ref([]),l=e.computed(()=>n.parent?t?.value?.[n.parent]?.toString?.()??null:null),{fetchOptions:a,fetchOptionByValue:s}=ua(()=>({data:n.data,options:n.options,api:n.api,prefix:n.prefix,host:n.host,start:n.start,parentValue:l.value})),c=async(i="")=>{const d=n.data?await a(i):n.options?[...n.options]:[];return r.value=d,r.value};return e.watch(()=>n.options,()=>{n.data||(r.value=n.options?[...n.options]:[])},{immediate:!0,deep:!0}),o&&e.watch(l,async()=>{n.data&&(r.value=await a())},{immediate:!1}),{optionsList:r,parentValue:l,fetchOptions:a,fetchOptionByValue:s,loadOptions:c}},pa=/\{\{\s*([^}]+?)\s*\}\}/g,ma=n=>(n?String(n):"").replace(/<[^>]*>/g,"").trim(),fa=(n,t)=>t.split(".").reduce((o,r)=>o==null?o:o[r.trim()],n),yn=(n,t)=>{if(!n)return"";const o=(t??"").trim();return o?o.replace(pa,(r,l)=>{const a=String(l).trim(),s=n,i=(a.includes(".")?fa(s,a):void 0)??s[a];return i!=null?String(i):""}):n.text??""},bn=(n,t)=>{if(!n)return"";const o=yn(n,t);return ma(o)||n.text||""},Qn=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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.computed(()=>da[`vs-input-radio-${t.view}`]),l=e.computed(()=>t.slot??t?.optionTemplate??""),a=e.computed(()=>fn(l.value)),s=y=>yn(y,l.value),c=y=>bn(y,l.value),i=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:f}=gn({props:t,formValues:u});return e.onMounted(async()=>{await f()}),(y,h)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(i.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p),k=>(e.openBlock(),e.createElementBlock("div",{key:k?.id,class:e.normalizeClass(["flex items-stretch",n.position==="horizontal"?t.customClass:""]),style:e.normalizeStyle(d.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),e.mergeProps({text:c(k),html:a.value?s(k):"",option:k,value:k.id.toString(),checked:o.value?.toString?.()===k.id?.toString?.(),"custom-class":n.position==="horizontal"?"":t.customClass,modelValue:o.value,"onUpdate:modelValue":h[0]||(h[0]=g=>o.value=g)},{ref_for:!0},y.$attrs),null,16,["text","html","option","value","checked","custom-class","modelValue"]))],6))),128))],2))}}),ha={key:1,class:"w-full flex flex-col gap-4"},ga={key:0,class:"text-sm font-medium text-muted-foreground my-2"},ya="Без категорії",ba=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(n,{emit:t}){const o=n,r=t,l=e.reactive({}),a=e.inject("values",null),{optionsList:s,loadOptions:c}=gn({props:{...o,options:o.options},formValues:a}),i=e.computed(()=>s.value),d=x=>x?.value||x?.id||x?.text||x,u=e.computed(()=>o.slot??o?.optionTemplate??""),p=e.computed(()=>fn(u.value)),f=x=>yn(x,u.value),y=x=>bn(x,u.value),h=x=>`lg:col-span-${x||12}`,k=e.computed(()=>[o.position==="vertical"?"flex flex-col":"",o.colSpan?"grid":"flex justify-start"]),g=x=>x==null||x===""?null:typeof x=="string"||typeof x=="number"?x:String(x),v=e.computed(()=>{if(!o.group)return[];const x=new Map;i.value.forEach(L=>{const B=L[o.group],_=g(B);x.has(_)||x.set(_,[]),x.get(_)?.push(L)});const C=[];o.values?.length&&o.values.forEach(L=>{const B=g(L);C.push(B)});const S=new Set,H=L=>{const B=x.get(L)||[];if(!B.length)return null;const _=L===null?"group-null":`group-${String(L)}`,$=L===null?ya:String(L);return S.add(L),{key:_,label:$,options:B}},K=[];return C.forEach(L=>{const B=H(L);B&&K.push(B)}),x.forEach((L,B)=>{if(S.has(B))return;const _=H(B);_&&K.push(_)}),K});return e.watch(()=>o.modelValue,x=>{if(typeof x=="boolean"&&i.value.length===1){const C=d(i.value[0]);l[C]=x}else if(Array.isArray(x)){const C=new Set(x);i.value.forEach(S=>{if(!S.disabled){const H=d(S);l[H]=C.has(H)}})}},{immediate:!0}),e.watch(l,()=>{if(!i.value.length){r("update:modelValue",null);return}const x=Object.entries(l).filter(([,C])=>C).map(([C])=>C);r("update:modelValue",x.length===0?[]:x)},{deep:!0}),e.onMounted(async()=>{if(await c(),typeof o.modelValue=="boolean"&&i.value.length===1){const x=d(i.value[0]);l[x]=o.modelValue}else if(Array.isArray(o.modelValue)){const x=new Set(o.modelValue);i.value.forEach(C=>{if(!C.disabled){const S=d(C);l[S]=x.has(S)}})}}),(x,C)=>o.group?(e.openBlock(),e.createElementBlock("div",ha,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,S=>(e.openBlock(),e.createElementBlock("div",{key:S.key,class:"flex flex-col gap-2"},[S.label?(e.openBlock(),e.createElementBlock("span",ga,e.toDisplayString(S.label),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-0 w-full gap-[12px]",k.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.options,H=>(e.openBlock(),e.createBlock(Gn,{modelValue:l[d(H)],"onUpdate:modelValue":K=>l[d(H)]=K,value:d(H),class:e.normalizeClass(h(n.colSpan)),disabled:o.disabled||H.disabled,label:y(H),labelHtml:p.value?f(H):"",key:`${S.key}-${d(H)}`,icon:H?.icon,imgUrl:H?.imgUrl,option:H,view:n.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]",k.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,S=>(e.openBlock(),e.createBlock(Gn,{modelValue:l[d(S)],"onUpdate:modelValue":H=>l[d(S)]=H,value:d(S),class:e.normalizeClass(h(n.colSpan)),disabled:o.disabled||S.disabled,label:y(S),labelHtml:p.value?f(S):"",key:d(S),icon:S?.icon,imgUrl:S?.imgUrl,option:S,view:n.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2))}}),Be=(n,t)=>{const o=n.__vccOpts||n;for(const[r,l]of t)o[r]=l;return o},Fo=Be(ba,[["__scopeId","data-v-16c6c9cd"]]),ka=1440*60*1e3,xa=["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"],wa=["січ","лют","бер","квіт","трав","черв","лип","серп","вер","жовт","лист","груд"],Ca=["нд","пн","вт","ср","чт","пт","сб"];function Ue(n){return n instanceof Date&&!Number.isNaN(n.getTime())}const Ut=n=>new Date(n.getTime());function Lt(n){const t=Ut(n);return t.setHours(0,0,0,0),t}function Yt(n){const t=Ut(n);return t.setHours(23,59,59,999),t}function eo(n){return Lt(new Date(n.getFullYear(),n.getMonth(),1))}function to(n){return Yt(new Date(n.getFullYear(),n.getMonth()+1,0))}function no(n,t){const o=new Date(n),r=o.getDate();o.setDate(1),o.setMonth(o.getMonth()+t);const l=new Date(o.getFullYear(),o.getMonth()+1,0).getDate();return o.setDate(Math.min(r,l)),o}function va(n,t){return no(n,-1)}function kn(n,t){const o=new Date(n);return o.setFullYear(o.getFullYear()+t),o}function Do(n,t){return kn(n,-t)}function To(n){return Lt(new Date(n.getFullYear(),0,1))}function Lo(n){return Yt(new Date(n.getFullYear(),11,31))}function Ea(n){const t=Math.floor(n.getFullYear()/10)*10;return Lt(new Date(t,0,1))}function Ba(n){const t=Math.floor(n.getFullYear()/10)*10+9;return Yt(new Date(t,11,31))}const it=n=>n.getFullYear(),xn=n=>Math.floor(n.getFullYear()/10)*10;function _a(n){const t=[];let o=Lt(n.start);const r=Lt(n.end);for(;o<=r;)t.push(Ut(o)),o=new Date(o.getTime()+ka);return t}function Va(n){const t=[];let o=eo(n.start);const r=to(n.end);for(;o<=r;)t.push(Ut(o)),o=no(o,1);return t}function Sa(n){const t=[];let o=To(n.start);const r=Lo(n.end);for(;o<=r;)t.push(Ut(o)),o=kn(o,1);return t}function oo(n,t=1){const o=Lt(n),r=(o.getDay()-t+7)%7;return o.setDate(o.getDate()-r),o}function $a(n,t=1){const o=oo(n,t);return o.setDate(o.getDate()+6),Yt(o)}function Na(n,t,o=0){const r=oo(n,o),l=(t-o+7)%7;return r.setDate(r.getDate()+l),r}const wn=(n,t)=>!!n&&!!t&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate(),ro=(n,t)=>!!n&&!!t&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth(),Io=(n,t)=>!!n&&!!t&&n.getFullYear()===t.getFullYear(),Oo=(n,t)=>!!n&&!!t&&wn(n,t)&&n.getHours()===t.getHours(),Aa=(n,t)=>!!n&&!!t&&Oo(n,t)&&n.getMinutes()===t.getMinutes();function Ma(n,t){const o=n.getTime();return o>=t.start.getTime()&&o<=t.end.getTime()}const Xt=(n,t)=>!!n&&!!t&&n.getTime()<t.getTime(),Zt=(n,t)=>!!n&&!!t&&n.getTime()>t.getTime();function Fa(n){const t=n.filter(o=>Ue(o));if(t.length)return t.reduce((o,r)=>o.getTime()>=r.getTime()?o:r)}function Da(n){const t=n.filter(o=>Ue(o));if(t.length)return t.reduce((o,r)=>o.getTime()<=r.getTime()?o:r)}function Ta(n,t){const o=Ut(n);return typeof t.year=="number"&&o.setFullYear(t.year),typeof t.month=="number"&&o.setMonth(t.month),typeof t.date=="number"&&o.setDate(t.date),typeof t.hours=="number"&&o.setHours(t.hours),typeof t.minutes=="number"&&o.setMinutes(t.minutes),typeof t.seconds=="number"&&o.setSeconds(t.seconds),typeof t.milliseconds=="number"&&o.setMilliseconds(t.milliseconds),o}const Cn=(n,t=2)=>String(n).padStart(t,"0");function Ro(n,t){return t==="wide"?xa[n]:wa[n]}function La(n){return Ca[n]}const Ia=[{token:"LLLL",format:n=>Ro(n.getMonth(),"wide")},{token:"LLL",format:n=>Ro(n.getMonth(),"abbreviated")},{token:"EE",format:n=>La(n.getDay())},{token:"yyyy",format:n=>String(n.getFullYear())},{token:"MM",format:n=>Cn(n.getMonth()+1)},{token:"dd",format:n=>Cn(n.getDate())},{token:"HH",format:n=>Cn(n.getHours())},{token:"mm",format:n=>Cn(n.getMinutes())}];function Jt(n,t){if(!Ue(n))return"";let o="",r=0;for(;r<t.length;){const l=Ia.find(a=>t.startsWith(a.token,r));l?(o+=l.format(n),r+=l.token.length):(o+=t[r],r+=1)}return o}const Oa={"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 Po(n,t){const o=Oa[t];if(!o){const l=new Date(n);return Ue(l)?l:null}const r=n.match(o);if(!r)return null;switch(t){case"yyyy-MM-dd":{const[,l,a,s]=r,c=new Date(Number(l),Number(a)-1,Number(s));return Ue(c)?c:null}case"dd.MM.yyyy":{const[,l,a,s]=r,c=new Date(Number(s),Number(a)-1,Number(l));return Ue(c)?c:null}case"dd.MM.yyyy HH:mm":{const[,l,a,s,c,i]=r,d=new Date(Number(s),Number(a)-1,Number(l),Number(c),Number(i));return Ue(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 Ra=["year","month","day","time","custom"],Pa=e.defineComponent({components:{ChevronLeft:q.ChevronLeft,ChevronRight:q.ChevronRight},emits:{elementClick:n=>Ue(n),left:()=>!0,right:()=>!0,heading:()=>!0,today:()=>!0,clear:()=>!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:n=>typeof n=="string"&&Ra.includes(n)},showButtonBar:{type:Boolean,default:!1},hideHeader:{type:Boolean,default:!1}},setup(){const t=e.getCurrentInstance()?.appContext?.config?.globalProperties?.$t,o=e.computed(()=>{const l=t?.("form.date.today");return l&&l!=="form.date.today"?l:"Сьогодні"}),r=e.computed(()=>{const l=t?.("form.date.clear");return l&&l!=="form.date.clear"?l:"Очистити"});return{todayLabel:o,clearLabel:r}}}),za={key:0,class:"p-datepicker-header flex items-center justify-between mb-1.5"},ja=["disabled"],Ua=["disabled"],Ha={key:0,class:"p-datepicker-weekheader grid [grid-template-columns:var(--popout-column-definition)] text-[12px] text-slate-400 font-medium mb-1.5"},qa=["disabled","onClick"],Ka={key:1,class:"p-datepicker-buttonbar mt-2 pt-2 border-t border-slate-200 flex items-center justify-between"};function Wa(n,t,o,r,l,a){const s=e.resolveComponent("ChevronLeft"),c=e.resolveComponent("ChevronRight");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["p-datepicker-panel p-component text-center text-slate-700 overflow-x-hidden bg-white border border-slate-200 rounded-xl shadow-[0_4px_12px_rgba(0,0,0,0.1)] p-2",n.viewMode==="month"||n.viewMode==="year"?"w-[182px] min-w-[182px]":"w-[268px] min-w-[182px]"]),style:e.normalizeStyle({"--popout-column-definition":`repeat(${n.columnCount}, 1fr)`}),onMousedown:t[5]||(t[5]=e.withModifiers(()=>{},["prevent"]))},[n.hideHeader?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",za,[e.createElementVNode("button",{class:"p-datepicker-prev-button inline-flex items-center justify-center size-8 rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300 disabled:hover:bg-transparent",disabled:n.leftDisabled,onClick:t[0]||(t[0]=e.withModifiers(i=>n.$emit("left"),["stop","prevent"]))},[e.renderSlot(n.$slots,"arrow-left",{},()=>[e.createVNode(s,{class:"h-3.5 w-3.5"})])],8,ja),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.headingClickable?"button":"span"),{class:e.normalizeClass(["p-datepicker-title min-w-0 rounded-md px-2 py-1 text-sm font-semibold leading-snug text-slate-700",n.headingClickable?"hover:bg-slate-100":"",n.viewMode==="month"?"p-datepicker-select-year":"",n.viewMode==="year"?"p-datepicker-decade whitespace-nowrap text-xs px-1":""]),onClick:t[1]||(t[1]=e.withModifiers(i=>n.$emit("heading"),["stop","prevent"]))},{default:e.withCtx(()=>[e.renderSlot(n.$slots,"heading")]),_:3},8,["class"])),e.createElementVNode("button",{class:"p-datepicker-next-button inline-flex items-center justify-center size-8 rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300 disabled:hover:bg-transparent",disabled:n.rightDisabled,onClick:t[2]||(t[2]=e.withModifiers(i=>n.$emit("right"),["stop","prevent"]))},[e.renderSlot(n.$slots,"arrow-right",{},()=>[e.createVNode(c,{class:"h-3.5 w-3.5"})])],8,Ua)])),e.createElementVNode("div",null,["subheading"in n.$slots?(e.openBlock(),e.createElementBlock("div",Ha,[e.renderSlot(n.$slots,"subheading")])):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-datepicker-calendar grid [grid-template-columns:var(--popout-column-definition)] text-[12px] text-slate-700",n.viewMode==="month"?"p-datepicker-month-view":"",n.viewMode==="year"?"p-datepicker-year-view":"",n.viewMode==="month"?"gap-y-1":""])},[e.renderSlot(n.$slots,"body",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.items,i=>(e.openBlock(),e.createElementBlock("button",{key:i.key,disabled:i.disabled,class:e.normalizeClass(["p-[2px] disabled:text-slate-300"]),onClick:e.withModifiers(d=>n.$emit("elementClick",i.value),["stop","prevent"])},[e.createElementVNode("span",{class:e.normalizeClass([n.viewMode==="month"||n.viewMode==="year"?"inline-flex w-full h-8 items-center justify-center rounded-md text-[13px] font-normal transition-colors":"inline-flex w-8 h-8 items-center justify-center rounded-full text-[13px] font-normal transition-colors",n.viewMode==="month"?"p-datepicker-month":"",n.viewMode==="year"?"p-datepicker-year":"",n.viewMode==="day"?"p-datepicker-day":"",i.selected?"bg-blue-500 text-white font-semibold":"",i.current&&!i.selected&&n.viewMode!=="month"&&n.viewMode!=="year"?"border border-slate-300 font-medium":"",!i.disabled&&!i.selected?"hover:bg-slate-100 hover:text-slate-700":"",!i.current&&!i.selected&&i.disabled?"text-slate-300":""])},e.toDisplayString(i.display),3)],8,qa))),128))])],2),e.renderSlot(n.$slots,"after-calendar"),n.showButtonBar?(e.openBlock(),e.createElementBlock("div",Ka,[e.createElementVNode("button",{type:"button",class:"p-datepicker-today-button text-xs font-medium text-slate-500 hover:text-slate-700 transition-colors px-1.5 py-1 rounded-md hover:bg-slate-100",onClick:t[3]||(t[3]=e.withModifiers(i=>n.$emit("today"),["stop","prevent"]))},e.toDisplayString(n.todayLabel),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-clear-button text-xs font-medium text-slate-500 hover:text-slate-700 transition-colors px-1.5 py-1 rounded-md hover:bg-slate-100",onClick:t[4]||(t[4]=e.withModifiers(i=>n.$emit("clear"),["stop","prevent"]))},e.toDisplayString(n.clearLabel),1)])):e.createCommentVNode("",!0)])],38)}const vn=Be(Pa,[["render",Wa]]),Ga=e.defineComponent({components:{PickerPopup:vn},emits:{"update:pageDate":n=>Ue(n),select:n=>Ue(n)},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(n,{emit:t}){const o=e.computed(()=>Ea(n.pageDate)),r=e.computed(()=>Ba(n.pageDate)),l=(p,f,y)=>!f&&!y?!0:!(f&&it(p)<it(f)||y&&it(p)>it(y)),a=e.computed(()=>Sa({start:o.value,end:r.value}).map(p=>({value:p,key:String(it(p)),display:it(p),selected:!!n.selected&&it(p)===it(n.selected),disabled:!l(p,n.lowerLimit,n.upperLimit)}))),s=e.computed(()=>{const p=it(o.value),f=it(r.value);return`${p} - ${f}`}),c=e.computed(()=>n.lowerLimit&&(xn(n.lowerLimit)===xn(n.pageDate)||Xt(n.pageDate,n.lowerLimit))),i=e.computed(()=>n.upperLimit&&(xn(n.upperLimit)===xn(n.pageDate)||Zt(n.pageDate,n.upperLimit)));return{years:a,heading:s,leftDisabled:c,rightDisabled:i,previousPage:()=>t("update:pageDate",Do(n.pageDate,10)),nextPage:()=>t("update:pageDate",kn(n.pageDate,10))}}});function Ya(n,t,o,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{columnCount:2,leftDisabled:n.leftDisabled,rightDisabled:n.rightDisabled,items:n.years,viewMode:"year",onLeft:n.previousPage,onRight:n.nextPage,onElementClick:t[0]||(t[0]=c=>n.$emit("select",c))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(n.heading),1)]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const Xa=Be(Ga,[["render",Ya]]),Za=e.defineComponent({components:{PickerPopup:vn},emits:{"update:pageDate":n=>Ue(n),select:n=>Ue(n),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(n,{emit:t}){const o=e.computed(()=>To(n.pageDate)),r=e.computed(()=>Lo(n.pageDate)),l=e.computed(()=>f=>Jt(f,n.format)),a=(f,y,h)=>!y&&!h?!0:!(y&&Xt(f,eo(y))||h&&Zt(f,to(h))),s=e.computed(()=>Va({start:o.value,end:r.value}).map(f=>({value:f,display:l.value(f),key:l.value(f),selected:!!n.selected&&ro(n.selected,f),disabled:!a(f,n.lowerLimit,n.upperLimit)}))),c=e.computed(()=>it(o.value)),i=e.computed(()=>n.lowerLimit&&(Io(n.lowerLimit,n.pageDate)||Xt(n.pageDate,n.lowerLimit))),d=e.computed(()=>n.upperLimit&&(Io(n.upperLimit,n.pageDate)||Zt(n.pageDate,n.upperLimit)));return{months:s,heading:c,leftDisabled:i,rightDisabled:d,previousPage:()=>t("update:pageDate",Do(n.pageDate,1)),nextPage:()=>t("update:pageDate",kn(n.pageDate,1))}}});function Ja(n,t,o,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:3,items:n.months,leftDisabled:n.leftDisabled,rightDisabled:n.rightDisabled,viewMode:"month",onLeft:n.previousPage,onRight:n.nextPage,onHeading:t[0]||(t[0]=c=>n.$emit("back")),onElementClick:t[1]||(t[1]=c=>n.$emit("select",c))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(n.heading),1)]),_:1},8,["items","leftDisabled","rightDisabled","onLeft","onRight"])}const Qa=Be(Za,[["render",Ja]]),es=e.defineComponent({components:{PickerPopup:vn},emits:{"update:pageDate":n=>Ue(n),select:n=>Ue(n),back:()=>!0,today:()=>!0,clear:()=>!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:n=>typeof n=="number"&&Number.isInteger(n)&&n>=0&&n<=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(n,{emit:t}){const o=e.computed(()=>g=>v=>Jt(v,g)),r=e.computed(()=>eo(n.pageDate)),l=e.computed(()=>to(n.pageDate)),a=e.computed(()=>({start:r.value,end:l.value})),s=e.computed(()=>({start:oo(r.value,n.weekStartsOn),end:$a(l.value,n.weekStartsOn)})),c=e.computed(()=>n.customWeekdays?.length===7?n.customWeekdays:null),i=e.computed(()=>{const g=n.weekStartsOn,v=c.value;if(v)return Array.from({length:7}).map((C,S)=>v[(g+S)%7]);const x=o.value(n.weekdayFormat);return Array.from(Array(7)).map((C,S)=>(g+S)%7).map(C=>Na(new Date,C,n.weekStartsOn)).map(x)}),d=(g,v,x,C)=>C?.dates?.some(S=>wn(g,S))||C?.predicate?.(g)?!1:!v&&!x?!0:!(v&&Xt(g,Lt(v))||x&&Zt(g,Yt(x))),u=e.computed(()=>{const g=new Date,v=o.value(n.format);return _a(s.value).map(x=>({value:x,display:v(x),selected:!!n.selected&&wn(n.selected,x),current:wn(g,x),disabled:!n.allowOutsideInterval&&!Ma(x,a.value)||!d(x,n.lowerLimit,n.upperLimit,n.disabledDates),key:o.value("yyyy-MM-dd")(x)}))}),p=e.computed(()=>o.value(n.headingFormat)(n.pageDate)),f=e.computed(()=>n.lowerLimit&&(ro(n.lowerLimit,n.pageDate)||Xt(n.pageDate,n.lowerLimit))),y=e.computed(()=>n.upperLimit&&(ro(n.upperLimit,n.pageDate)||Zt(n.pageDate,n.upperLimit)));return{weekDays:i,days:u,heading:p,leftDisabled:f,rightDisabled:y,previousPage:()=>t("update:pageDate",va(n.pageDate)),nextPage:()=>t("update:pageDate",no(n.pageDate,1))}}});function ts(n,t,o,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",leftDisabled:n.leftDisabled,rightDisabled:n.rightDisabled,items:n.days,showButtonBar:!0,viewMode:"day",onLeft:n.previousPage,onRight:n.nextPage,onHeading:t[0]||(t[0]=c=>n.$emit("back")),onElementClick:t[1]||(t[1]=c=>n.$emit("select",c)),onToday:t[2]||(t[2]=c=>n.$emit("today")),onClear:t[3]||(t[3]=c=>n.$emit("clear"))},e.createSlots({heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(n.heading),1)]),subheading:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.weekDays,(c,i)=>(e.openBlock(),e.createElementBlock("span",{key:c,class:e.normalizeClass(`v3dp__subheading__weekday__${i}`)},e.toDisplayString(c),3))),128))]),_:2},[n.$slots["after-calendar"]?{name:"after-calendar",fn:e.withCtx(()=>[e.renderSlot(n.$slots,"after-calendar")]),key:"0"}:void 0]),1032,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const ns=Be(es,[["render",ts]]),os=e.defineComponent({components:{PickerPopup:vn,ChevronUp:q.ChevronUp,ChevronDown:q.ChevronDown},emits:{select:n=>Ue(n),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},visible:{type:Boolean,required:!0},disabledTime:{type:Object,required:!1},embedded:{type:Boolean,default:!1}},setup(n,{emit:t}){const o=e.computed(()=>n.pageDate??n.selected),r=e.ref(o.value.getHours()),l=e.ref(o.value.getMinutes());e.watch(()=>n.selected,y=>{let h=0,k=0;y&&(h=y.getHours(),k=y.getMinutes()),r.value=h,l.value=k});const a=(y,h)=>{const k=Ta(new Date(o.value.getTime()),{hours:y,minutes:h,seconds:0});p(k)&&(r.value=y,l.value=h,t("select",k))},s=(y,h)=>y<0?h:y>h?0:y,c=()=>a(s(r.value+1,23),l.value),i=()=>a(s(r.value-1,23),l.value),d=()=>a(r.value,s(l.value+1,59)),u=()=>a(r.value,s(l.value-1,59)),p=y=>!(n.disabledTime?.dates?.some(h=>Oo(y,h)&&Aa(y,h))||n.disabledTime?.predicate?.(y));return{hours:r,minutes:l,padStartZero:y=>`0${y}`.substr(-2),isEnabled:p,incrementHours:c,decrementHours:i,incrementMinutes:d,decrementMinutes:u}}}),rs={key:0,class:"p-datepicker-time-picker mt-2 pt-2 border-t border-slate-200 flex items-center justify-center gap-2 py-1"},ls={class:"p-datepicker-hour-picker flex flex-col items-center gap-1"},as={class:"min-w-8 text-center text-sm font-medium text-slate-700"},ss={class:"p-datepicker-minute-picker flex flex-col items-center gap-1"},is={class:"min-w-8 text-center text-sm font-medium text-slate-700"},cs={class:"col-span-2"},ds={class:"p-datepicker-time-picker flex items-center justify-center gap-2 py-1"},us={class:"p-datepicker-hour-picker flex flex-col items-center gap-1"},ps={class:"min-w-8 text-center text-sm font-medium text-slate-700"},ms={class:"p-datepicker-minute-picker flex flex-col items-center gap-1"},fs={class:"min-w-8 text-center text-sm font-medium text-slate-700"};function hs(n,t,o,r,l,a){const s=e.resolveComponent("ChevronUp"),c=e.resolveComponent("ChevronDown"),i=e.resolveComponent("picker-popup");return n.embedded?(e.openBlock(),e.createElementBlock("div",rs,[e.createElementVNode("div",ls,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[0]||(t[0]=e.withModifiers((...d)=>n.incrementHours&&n.incrementHours(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",as,e.toDisplayString(n.padStartZero(n.hours)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[1]||(t[1]=e.withModifiers((...d)=>n.decrementHours&&n.decrementHours(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])]),t[8]||(t[8]=e.createElementVNode("div",{class:"text-base font-medium text-slate-500"},":",-1)),e.createElementVNode("div",ss,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[2]||(t[2]=e.withModifiers((...d)=>n.incrementMinutes&&n.incrementMinutes(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",is,e.toDisplayString(n.padStartZero(n.minutes)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[3]||(t[3]=e.withModifiers((...d)=>n.decrementMinutes&&n.decrementMinutes(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])])])):(e.openBlock(),e.createBlock(i,{key:1,hideHeader:!0,columnCount:2,viewMode:"time"},{body:e.withCtx(()=>[e.createElementVNode("div",cs,[e.createElementVNode("div",ds,[e.createElementVNode("div",us,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[4]||(t[4]=e.withModifiers((...d)=>n.incrementHours&&n.incrementHours(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",ps,e.toDisplayString(n.padStartZero(n.hours)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[5]||(t[5]=e.withModifiers((...d)=>n.decrementHours&&n.decrementHours(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])]),t[9]||(t[9]=e.createElementVNode("div",{class:"text-base font-medium text-slate-500"},":",-1)),e.createElementVNode("div",ms,[e.createElementVNode("button",{type:"button",class:"p-datepicker-increment-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[6]||(t[6]=e.withModifiers((...d)=>n.incrementMinutes&&n.incrementMinutes(...d),["stop","prevent"]))},[e.createVNode(s,{class:"h-3.5 w-3.5"})]),e.createElementVNode("span",fs,e.toDisplayString(n.padStartZero(n.minutes)),1),e.createElementVNode("button",{type:"button",class:"p-datepicker-decrement-button inline-flex size-8 items-center justify-center rounded-full text-slate-500 transition-colors hover:bg-slate-100 hover:text-slate-700 disabled:text-slate-300",onClick:t[7]||(t[7]=e.withModifiers((...d)=>n.decrementMinutes&&n.decrementMinutes(...d),["stop","prevent"]))},[e.createVNode(c,{class:"h-3.5 w-3.5"})])])])])]),_:1}))}const gs=Be(os,[["render",hs]]),En=["time","day","month","year"],ys=(n,t,o=void 0)=>{let r=o||new Date;const l=Fa([n,r]);l&&(r=l);const a=Da([t,r]);return a&&(r=a),r},bs=e.defineComponent({components:{YearPicker:Xa,MonthPicker:Qa,DayPicker:ns,TimePicker:gs,CalendarDays:q.CalendarDays,Clock3:q.Clock3,X:q.X},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:n=>typeof n=="string"&&En.includes(n)},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:n=>[0,1,2,3,4,5,6].includes(n)},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:n=>typeof n=="string"&&En.includes(n)}},emits:{"update:modelValue":n=>n==null||Ue(n),decadePageChanged:n=>!0,yearPageChanged:n=>!0,monthPageChanged:n=>!0,opened:()=>!0,closed:()=>!0},setup(n,{emit:t}){const o=e.ref("none"),r=e.ref(n.startingViewDate),l=e.ref(null),a=e.ref(null),s=e.ref(null),c=e.ref({}),i=e.ref(!1),d=e.ref(!1);let u=null;const p=e.ref(""),f=Z=>{const ae=Z.replace(/[a-zA-Z]/g,"0");return/0/.test(ae)?ae:""},y=e.computed(()=>f(n.inputFormat));let h=null,k=null;const g=()=>{h?.destroy(),h=null},v=async()=>{if(!k){const{default:Z}=await Promise.resolve().then(()=>Pn);k=Z}return k},x=()=>{h&&h.value!==p.value&&(h.value=p.value??"")},C=Z=>{const ae=Z&&Ue(Z)?Jt(Z,n.inputFormat):"";p.value!==ae&&(p.value=ae),x()},S=async()=>{if(g(),!a.value||!y.value)return;h=(await v())(a.value,{mask:y.value,lazy:!0,overwrite:!1}),x()};e.watch(()=>n.modelValue,Z=>{d.value&&n.typeable||C(Z)},{immediate:!0}),e.watch(()=>n.inputFormat,()=>{d.value&&n.typeable||C(n.modelValue)}),e.onMounted(()=>{y.value&&e.nextTick(()=>{S()})}),e.onBeforeUnmount(()=>{g()}),e.watch(y,Z=>{Z?e.nextTick(()=>{S()}):g()});const H=e.computed(()=>o.value!=="none"),K=e.computed(()=>n.startingView==="time"&&n.minimumView==="time"),L=e.computed(()=>n.startingView==="day"&&n.minimumView==="time"),B=Z=>{n.disabled||(H.value||(r.value=n.modelValue||ys(n.lowerLimit,n.upperLimit,r.value),t("opened")),o.value=Z,e.nextTick(()=>Me()))},_=()=>{H.value&&(u!==null&&(cancelAnimationFrame(u),u=null),o.value="none",t("closed"))},$=(Z="none")=>{Z==="none"?_():B(Z)};e.watchEffect(()=>{n.disabled&&_()});const R=(Z,ae)=>{r.value=ae,Z==="year"?t("decadePageChanged",ae):Z==="month"?t("yearPageChanged",ae):Z==="day"&&t("monthPageChanged",ae)},V=Z=>{r.value=Z,n.minimumView==="year"?(_(),C(Z),t("update:modelValue",Z)):B("month")},T=Z=>{r.value=Z,n.minimumView==="month"?(_(),C(Z),t("update:modelValue",Z)):B("day")},M=Z=>{const ae=L.value?(()=>{const xe=n.modelValue||r.value||new Date,ve=new Date(Z);return ve.setHours(xe.getHours(),xe.getMinutes(),0,0),ve})():Z;r.value=ae,n.minimumView==="day"?(_(),C(ae),t("update:modelValue",ae)):L.value?(C(ae),t("update:modelValue",ae),B("day")):B("time")},O=Z=>{C(Z),t("update:modelValue",Z)},Q=()=>{M(new Date)},J=()=>{n.clearable&&(_(),C(null),t("update:modelValue",null),r.value=n.startingViewDate)},de=()=>{H.value||B(ce.value)},te=()=>{d.value=!0,i.value=!1,B(ce.value)},F=()=>{d.value=!1,n.typeable&&ne({closeOnSuccess:!1,revertOnInvalid:!0})},Y=Z=>{const ae=Z.target;if(p.value=ae?.value??"",!n.typeable)return;const xe=Po(p.value,n.inputFormat);xe&&p.value===Jt(xe,n.inputFormat)&&(r.value=xe)},ne=({closeOnSuccess:Z,revertOnInvalid:ae})=>{const xe=a.value?.value??p.value,ve=Po(xe,n.inputFormat);return!!ve&&xe===Jt(ve,n.inputFormat)&&ve?(r.value=ve,C(ve),t("update:modelValue",ve),Z&&_(),!0):(C(n.modelValue),!1)},W=Z=>{const ae=Z.keyCode?Z.keyCode:Z.which,xe=ae===27,ve=ae===13;if(xe){_(),a.value?.blur();return}n.typeable&&ve&&(ne({closeOnSuccess:!0,revertOnInvalid:!0})||a.value?.focus())},ce=e.computed(()=>{const Z=En.indexOf(n.startingView),ae=En.indexOf(n.minimumView);return Z<ae?n.minimumView:n.startingView}),he=e.computed(()=>n.weekDayNames?.length===7?n.weekDayNames:void 0),re=()=>n.startingView==="time"&&n.minimumView==="time"?null:B("day"),pe=()=>{if(!a.value||!s.value)return;const Z=4,ae=8,xe=a.value.getBoundingClientRect(),ve=s.value.getBoundingClientRect(),je=s.value.firstElementChild?.getBoundingClientRect(),U=window.innerWidth,X=window.innerHeight,le=window.scrollX||window.pageXOffset,ue=window.scrollY||window.pageYOffset,P=Math.max(160,X-ae*2),oe=Math.min(ve.height||0,P),Ve=X-xe.bottom-Z-ae,Ne=xe.top-Z-ae,z=Ve<oe&&Ne>Ve;let w=z?xe.top-Z-oe:xe.bottom+Z;w=Math.max(ae,Math.min(w,X-ae-oe));const N=je?.width||ve.width||268;let I=xe.left;I+N>U-ae&&(I=U-ae-N),I<ae&&(I=ae);const se=z?Math.max(120,xe.top-Z-ae):Math.max(120,X-xe.bottom-Z-ae);c.value={position:"absolute",top:`${Math.round(w+ue)}px`,left:`${Math.round(I+le)}px`,maxHeight:`${Math.round(Math.min(P,se))}px`,overflowX:"hidden",overflowY:"auto",zIndex:"2147483000"},L.value&&o.value==="day"&&(c.value.minWidth="345px")},Ce=(Z,ae)=>Z.bottom>ae.top&&Z.top<ae.bottom&&Z.right>ae.left&&Z.left<ae.right,ke=Z=>{const ae=[];let xe=Z.parentElement;for(;xe;){const ve=window.getComputedStyle(xe),Fe=ve.overflowY,je=ve.overflowX,U=["auto","scroll","hidden","clip"].includes(Fe),X=["auto","scroll","hidden","clip"].includes(je);(U||X)&&ae.push(xe),xe=xe.parentElement}return ae},Se=()=>{if(!a.value)return!1;const Z=a.value.getBoundingClientRect(),ae=new DOMRect(0,0,window.innerWidth,window.innerHeight);return Ce(Z,ae)?ke(a.value).every(ve=>Ce(Z,ve.getBoundingClientRect())):!1},De=()=>{if(H.value){if(!Se()){i.value=!0,_();return}Me();return}i.value&&document.activeElement===a.value&&Se()&&(i.value=!1,B(ce.value))};e.watch(o,()=>{H.value&&e.nextTick(()=>Me())});const Me=()=>{pe(),u!==null&&cancelAnimationFrame(u),u=requestAnimationFrame(()=>{pe(),u=null})};e.onMounted(()=>{window.addEventListener("resize",De),window.addEventListener("scroll",De,!0),document.addEventListener("pointerdown",Te,!0)}),e.onBeforeUnmount(()=>{u!==null&&(cancelAnimationFrame(u),u=null),window.removeEventListener("resize",De),window.removeEventListener("scroll",De,!0),document.removeEventListener("pointerdown",Te,!0)});const Te=Z=>{if(o.value==="none")return;const ae=Z.target;if(!ae)return;const xe=!!l.value?.contains(ae),ve=!!s.value?.contains(ae);!xe&&!ve&&(i.value=!1,_())};return{rootRef:l,blur:F,focus:te,click:de,input:p,inputRef:a,pageDate:r,renderView:$,updatePageDate:R,selectYear:V,selectMonth:T,selectDay:M,selectToday:Q,selectTime:O,keyUp:W,onInput:Y,isTimeOnlyMode:K,isDateTimeMode:L,normalizedWeekdayNames:he,viewShown:o,goBackFromTimepicker:re,clearModelValue:J,initialView:ce,log:Z=>console.log(Z),popupAnchorStyle:c,popupRef:s}}}),ks={ref:"rootRef",class:"relative"},xs={class:"p-datepicker p-component p-inputwrapper relative"},ws=["readonly","value","placeholder","disabled","tabindex"],Cs={class:"p-datepicker-input-icon-container absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-slate-400"},vs={class:"absolute right-8 top-1/2 -translate-y-1/2"};function Es(n,t,o,r,l,a){const s=e.resolveComponent("Clock3"),c=e.resolveComponent("CalendarDays"),i=e.resolveComponent("X"),d=e.resolveComponent("year-picker"),u=e.resolveComponent("month-picker"),p=e.resolveComponent("time-picker"),f=e.resolveComponent("day-picker");return e.openBlock(),e.createElementBlock("div",ks,[e.createElementVNode("div",xs,[e.createElementVNode("input",e.mergeProps({type:"text",ref:"inputRef",class:"p-inputtext p-component p-datepicker-input",readonly:!n.typeable,value:n.input},n.$attrs,{placeholder:n.placeholder,disabled:n.disabled,tabindex:n.disabled?-1:0,onInput:t[0]||(t[0]=(...y)=>n.onInput&&n.onInput(...y)),onKeyup:t[1]||(t[1]=(...y)=>n.keyUp&&n.keyUp(...y)),onBlur:t[2]||(t[2]=(...y)=>n.blur&&n.blur(...y)),onFocus:t[3]||(t[3]=(...y)=>n.focus&&n.focus(...y)),onClick:t[4]||(t[4]=(...y)=>n.click&&n.click(...y))}),null,16,ws),e.createElementVNode("span",Cs,[n.isTimeOnlyMode?(e.openBlock(),e.createBlock(s,{key:0,class:"h-4 w-4"})):(e.openBlock(),e.createBlock(c,{key:1,class:"h-4 w-4"}))]),e.withDirectives(e.createElementVNode("div",vs,[e.renderSlot(n.$slots,"clear",{onClear:n.clearModelValue},()=>[e.createElementVNode("button",{type:"button",class:"inline-flex h-5 w-5 items-center justify-center rounded-full text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 focus:outline-none focus:ring-2 focus:ring-blue-500/30","aria-label":"Очистити дату",onClick:t[5]||(t[5]=y=>n.clearModelValue())},[e.createVNode(i,{class:"h-3 w-3"})])])],512),[[e.vShow,n.clearable&&n.modelValue]])]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.withDirectives(e.createElementVNode("div",{ref:"popupRef",style:e.normalizeStyle(n.popupAnchorStyle)},[e.withDirectives(e.createVNode(d,{pageDate:n.pageDate,"onUpdate:pageDate":t[6]||(t[6]=y=>n.updatePageDate("year",y)),selected:n.modelValue,lowerLimit:n.lowerLimit,upperLimit:n.upperLimit,onSelect:n.selectYear},null,8,["pageDate","selected","lowerLimit","upperLimit","onSelect"]),[[e.vShow,n.viewShown==="year"]]),e.withDirectives(e.createVNode(u,{pageDate:n.pageDate,"onUpdate:pageDate":t[7]||(t[7]=y=>n.updatePageDate("month",y)),selected:n.modelValue,onSelect:n.selectMonth,lowerLimit:n.lowerLimit,upperLimit:n.upperLimit,format:n.monthListFormat,onBack:t[8]||(t[8]=y=>n.viewShown="year")},null,8,["pageDate","selected","onSelect","lowerLimit","upperLimit","format"]),[[e.vShow,n.viewShown==="month"]]),e.withDirectives(e.createVNode(f,{pageDate:n.pageDate,"onUpdate:pageDate":t[9]||(t[9]=y=>n.updatePageDate("day",y)),selected:n.modelValue,weekStartsOn:n.weekStartsOn,lowerLimit:n.lowerLimit,upperLimit:n.upperLimit,headingFormat:n.dayPickerHeadingFormat,disabledDates:n.disabledDates,weekdayFormat:n.weekdayFormat,"allow-outside-interval":n.allowOutsideInterval,format:n.dayFormat,"custom-weekdays":n.normalizedWeekdayNames,onSelect:n.selectDay,onToday:n.selectToday,onClear:n.clearModelValue,onBack:t[10]||(t[10]=y=>n.viewShown="month")},e.createSlots({_:2},[n.isDateTimeMode?{name:"after-calendar",fn:e.withCtx(()=>[e.createVNode(p,{embedded:!0,pageDate:n.pageDate,visible:n.viewShown==="day"&&n.isDateTimeMode,selected:n.modelValue,disabledTime:n.disabledTime,onSelect:n.selectTime,onBack:n.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"])]),key:"0"}:void 0]),1032,["pageDate","selected","weekStartsOn","lowerLimit","upperLimit","headingFormat","disabledDates","weekdayFormat","allow-outside-interval","format","custom-weekdays","onSelect","onToday","onClear"]),[[e.vShow,n.viewShown==="day"]]),e.withDirectives(e.createVNode(p,{pageDate:n.pageDate,visible:n.viewShown==="time",selected:n.modelValue,disabledTime:n.disabledTime,onSelect:n.selectTime,onBack:n.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"]),[[e.vShow,n.viewShown==="time"&&!n.isDateTimeMode]])],4),[[e.vShow,n.viewShown!=="none"]])]))],512)}const Bs=Be(bs,[["render",Es]]),zo=Be(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},dateFormat:{},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(n,{emit:t}){const o=n,r=t,{inputClass:l}=Ge(o.style),a=e.getCurrentInstance(),s=e.computed(()=>o.mode?o.mode:o.time?"datetime":"date"),c=e.computed(()=>["py-1.5 px-3 block w-full placeholder:text-[#767f8f] bg-white",l.value,o.customClass,{"!border-red-600":o.error}]),i=e.computed(()=>!o.modelValue&&o.now?new Date:null),d=e.computed({get:()=>L(o.modelValue??i.value,s.value)||void 0,set:F=>r("update:modelValue",B(F,s.value))}),u=["Пн","Вт","Ср","Чт","Пт","Сб","Нд"],p=e.computed(()=>{if(o.dayNames?.length)return o.dayNames.length===7?o.dayNames:u}),f=e.computed(()=>{const F=o.weekStart,Y=typeof F=="string"?Number(F):F;return Y===void 0||Number.isNaN(Y)?1:Math.min(6,Math.max(0,Y))}),y=e.computed(()=>{switch(s.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"}}}),h={date:"dd.MM.yyyy",datetime:"dd.MM.yyyy HH:mm",month:"MM.yyyy",time:"HH:mm",week:"dd.MM.yyyy",year:"yyyy"};function k(){const F=a?.appContext?.config?.globalProperties?.$i18n?.locale;if(typeof F=="string"&&F)return F;if(F&&typeof F=="object"&&"value"in F&&F.value)return String(F.value);if(typeof localStorage<"u"){const Y=localStorage.getItem("locale")||localStorage.getItem("language");if(Y)return Y}return"uk"}function g(){const Y=a?.appContext?.config?.globalProperties?.$settings?.dateFormat;if(!Y)return"";if(typeof Y=="string")return Y;if(typeof Y=="object"){const ne=k();return Y[ne]||Y[ne.split("-")[0]]||Y.uk||Y.en||""}return""}function v(F){return F?F.replaceAll("dd","__DAY2__").replaceAll("d","__DAY1__").replaceAll("mm","__MONTH2__").replaceAll("m","__MONTH1__").replaceAll("yy","__YEAR2__").replaceAll("y","__YEAR1__").replaceAll("__DAY2__","dd").replaceAll("__DAY1__","d").replaceAll("__MONTH2__","MM").replaceAll("__MONTH1__","M").replaceAll("__YEAR2__","yy").replaceAll("__YEAR1__","yyyy"):""}const x=e.computed(()=>{const F=h[s.value]||"dd.MM.yyyy";if(s.value==="time")return F;const Y=o.dateFormat||g();if(!Y)return F;const ne=v(Y);return ne?s.value==="datetime"?`${ne} HH:mm`:ne:F});function C(F,Y){return F?Y==="week"?"рррр-тиждень":F.replaceAll("yyyy","рррр").replaceAll("yy","рр").replaceAll("MM","мм").replaceAll("M","м").replaceAll("dd","дд").replaceAll("d","д").replaceAll("HH","гг").replaceAll("H","г").replaceAll("mm",Y==="time"||Y==="datetime"?"хх":"мм"):""}const S={date:"дд.мм.рррр",datetime:"дд.мм.рррр гг:хх",month:"мм.рррр",week:"рррр-тиждень",time:"гг:хх",year:"рррр"},H=e.computed(()=>{if(o.placeholder)return o.placeholder;const F=s.value;return C(x.value,F)||S[F]||""}),K=e.ref(!1);e.watch(()=>o.modelValue,F=>{F?K.value=!0:o.now||(K.value=!1)},{immediate:!0}),e.watchEffect(()=>{o.now&&!o.modelValue&&!K.value&&(r("update:modelValue",B(new Date,s.value)),K.value=!0)}),e.watch(x,()=>{r("update:modelValue",B(d.value,s.value))});function L(F,Y){if(!F)return null;if(F instanceof Date&&!Number.isNaN(F.getTime()))return F;if(typeof F!="string")return null;switch(Y){case"datetime":return V(F);case"time":return O(F);case"month":return T(F);case"year":return M(F);case"week":return Q(F);default:return R(F)}}function B(F,Y){if(!F)return null;const ne=F instanceof Date?F:L(F,Y);if(!ne)return null;switch(Y){case"datetime":return`${_(ne)}T${$(ne)}`;case"time":return $(ne);case"month":return`${ne.getFullYear()}-${te(ne.getMonth()+1)}`;case"year":return`${ne.getFullYear()}`;case"week":{const{year:W,week:ce}=J(ne);return`${W}-W${te(ce)}`}default:return _(ne)}}function _(F){return`${F.getFullYear()}-${te(F.getMonth()+1)}-${te(F.getDate())}`}function $(F){return`${te(F.getHours())}:${te(F.getMinutes())}`}function R(F){const Y=F.split("-");if(Y.length<3)return null;const[ne,W,ce]=Y.map(Number);return!ne||!W||!ce?null:new Date(ne,W-1,ce)}function V(F){const Y=F.includes("T")?F:F.replace(" ","T"),ne=new Date(Y);return Number.isNaN(ne.getTime())?null:ne}function T(F){const[Y,ne]=F.split("-").map(Number);return!Y||Number.isNaN(ne)?null:new Date(Y,(ne||1)-1,1)}function M(F){const Y=Number(F);return Y?new Date(Y,0,1):null}function O(F){const Y=F.match(/^(\d{1,2}):(\d{2})$/);if(!Y)return null;const[,ne,W]=Y,ce=new Date;return ce.setHours(Number(ne),Number(W),0,0),ce}function Q(F){const Y=F.match(/^(\d{4})-W(\d{2})$/);if(!Y)return null;const[,ne,W]=Y,ce=Number(W);return de(Number(ne),ce)}function J(F){const Y=new Date(Date.UTC(F.getFullYear(),F.getMonth(),F.getDate())),ne=Y.getUTCDay()||7;Y.setUTCDate(Y.getUTCDate()+4-ne);const W=new Date(Date.UTC(Y.getUTCFullYear(),0,1)),ce=Math.ceil(((Y.getTime()-W.getTime())/864e5+1)/7);return{year:Y.getUTCFullYear(),week:ce}}function de(F,Y){if(!F||!Y)return null;const ne=new Date(F,0,1+(Y-1)*7),W=ne.getDay(),ce=ne;return W<=4?ce.setDate(ne.getDate()-ne.getDay()+1):ce.setDate(ne.getDate()+8-ne.getDay()),ce}function te(F){return String(F).padStart(2,"0")}return(F,Y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-date-picker",o.customClass])},[e.createVNode(Bs,{modelValue:d.value,"onUpdate:modelValue":Y[0]||(Y[0]=ne=>d.value=ne),placeholder:H.value,disabled:o.disabled,clearable:o.clearable,typeable:o.editable,"week-day-names":p.value,"week-starts-on":f.value,"starting-view":y.value.startingView,"minimum-view":y.value.minimumView,"input-format":x.value,name:o.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"])],2))}}),[["__scopeId","data-v-44a289c8"]]),_s=(n,t)=>{if(!t||!Object.keys(t).length)return n;const[o,r=""]=n.split("?"),l=new URLSearchParams(r);Object.entries(t).forEach(([s,c])=>{c==null||c===""||l.set(s,String(c))});const a=l.toString();return a?`${o}?${a}`:o},jo=async(n,t={})=>{try{const o=new FormData;o.append("unique","true"),o.append("file",n);const{api:r,id:l="1",form:a="form",table:s="table",customParams:c}=t,i=r||`/file/upload/uploads?id=${l||""}&form=${a||""}&table=${s||""}`,d=_s(i,c);return(await fetch(d,{method:"POST",body:o}).then(p=>p.json()))?.result}catch(o){return ye.notify({type:"error",title:"Помилка!",message:"Сталась помилка під час завантаження файлу",position:"right-bottom"}),console.error("Сталась помилка завантаження файлу",o),null}},Vs=async n=>{try{return await fetch(`file/delete${n}`),!0}catch(t){return console.error(t),!1}},Uo=async n=>{try{const t=await fetch(`/file/download${n}`);if(!t.ok)throw new Error(`Download failed with status ${t.status}`);const o=await t.blob(),l=(t.headers.get("content-disposition")||"").match(/filename\*?=(?:UTF-8''|")?([^\";]+)/i),a=l?.[1]?decodeURIComponent(l[1].replace(/"/g,"").trim()):"",s=n.split("/").filter(Boolean).pop()||"download",c=a||s,i=document.createElement("a");i.setAttribute("download",c),i.href=window.URL.createObjectURL(o),i.click(),window.URL.revokeObjectURL(i.href)}catch(t){console.error(t.message)}},Ss=n=>{if(!n)return"";const t=n?.split(".");return t[t.length-1]},$s=n=>{const t=Ss(n),o={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 o.imageFormat.includes(t)?"img":o.sheetsFormat.includes(t)?q.Table:o.textsFormat.includes(t)?q.FileCode:o.documentsFormat.includes(t)?q.FileText:o.archivesFormat.includes(t)?q.FileArchive:q.FileText},Ns=["title"],As={class:"absolute hidden top-0 right-0 flex items-center gap-x-2 w-full h-full justify-center"},lo=Be(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(n){const t=e.useModel(n,"value"),o=e.useModel(n,"item"),r=n,l=e.computed(()=>o.value?typeof o.value=="string"?o.value:o.value.file_path:""),a=i=>typeof i=="string"?i:i?.file_path||"",s=()=>{const i=l.value;Vs(i),r.multiple&&Array.isArray(t.value)?t.value=t.value.filter(d=>a(d)!==i):t.value=""},c=()=>{l.value&&window.open(l.value,"_blank")};return(i,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($s)(l.value)),{src:l.value,alt:"file",class:"w-full h-full object-cover cursor-pointer",onClick:d[0]||(d[0]=u=>e.unref(Uo)(l.value))},null,8,["src"])),e.createElementVNode("div",As,[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(q.Trash2),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:c,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(q.Eye),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:d[1]||(d[1]=u=>e.unref(Uo)(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(q.Download),{class:"w-4 h-4"})])])],8,Ns))}}),[["__scopeId","data-v-21affae7"]]),Ms={class:"flex items-center gap-x-2"},Fs=["accept","multiple","disabled"],Ds={key:1,class:"flex items-center flex-wrap gap-2"},Ts={key:1,class:"loader"},Ls={key:1,class:"loader"},Ho=Be(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(n,{emit:t}){const o=n,r=e.useModel(n,"modelValue"),l=t,a=e.computed(()=>{const x=r.value;return!o.multiple||!Array.isArray(x)?[]:x}),s=e.ref(null),c=e.ref(!1),i=e.inject("values"),d=e.computed(()=>o.format?o.format.split(",").map(x=>x.trim().toLowerCase()).filter(Boolean):[]),u=x=>{if(o.max_size&&x.size>o.max_size*1024*1024){const C=(x.size/1048576).toFixed(2);return ye.notify({type:"error",title:"Помилка!",message:`Файл "${x.name}" занадто великий. Максимальний розмір: ${o.max_size} МБ, розмір файлу: ${C} МБ`,position:"right-bottom"}),!1}return!0},p=x=>{if(!d.value.length)return!0;const C=`.${x.name.split(".").pop()?.toLowerCase()||""}`,S=d.value.includes(C);return S||ye.notify({type:"error",title:"Помилка!",message:`Неприпустимий формат файлу "${x.name}". Дозволені формати: ${d.value.join(", ")}`,position:"right-bottom"}),S},f=e.computed(()=>{const x={},C=[];if(!o.customParams?.length)return{params:x,missingSources:C};const S=i?.value??{};return o.customParams.forEach(H=>{if(!H)return;const[K,L]=H.split("="),B=K?.trim(),_=L?.trim();if(!B||!_)return;const $=S[_];if($==null||$===""){C.push(_);return}x[B]=$}),{params:x,missingSources:C}}),y=()=>{const{params:x}=f.value;return{api:o.api,customParams:Object.keys(x).length?x:void 0}},h=()=>{const x=f.value.missingSources;if(!x.length)return!0;const C=x.join(", ");return ye.notify({type:"warning",title:"Заповніть поля",message:`Поля (${C}) необхідні для завантаження файлу`,position:"right-bottom"}),!1},k=x=>{ye.notify({type:"error",title:"Помилка завантаження",message:x||"Не вдалося завантажити файл. Спробуйте ще раз.",position:"right-bottom"})},g=()=>{o.disabled||c.value||h()&&s.value?.click()},v=async x=>{const{files:C}=x.target;if(!C||C.length===0)return;if(!h()){s.value&&(s.value.value="");return}const S=Array.from(C);if(o.max_size&&S.filter(L=>!u(L)).length>0){s.value&&(s.value.value="");return}if(S.filter(K=>!p(K)).length>0){s.value&&(s.value.value="");return}c.value=!0;try{if(o.multiple){const K=Array.from(C).map(async R=>await jo(R,y())),L=await Promise.all(K),B=L.filter(R=>R?.file_path);if(B.length===0){k();return}B.length<L.length&&k("Деякі файли не вдалося завантажити. Перевірте їх та спробуйте знову.");const _=B.map(R=>R.file_path),$=Array.isArray(r.value)?r.value:[];r.value=[...$,..._],l("change",r.value)}else{const K=C[0],L=await jo(K,y());if(!L?.file_path){k();return}const B=L.file_path;r.value=B,l("change",B)}}catch(K){const L=K?.message||void 0;k(L)}finally{c.value=!1,s.value&&(s.value.value="")}};return(x,C)=>(e.openBlock(),e.createElementBlock("div",Ms,[e.createElementVNode("input",{class:"hidden",ref_key:"fileInput",ref:s,type:"file",accept:o.format,multiple:n.multiple,onChange:v,disabled:c.value||n.disabled},null,40,Fs),!n.multiple&&r.value&&!Array.isArray(r.value)?(e.openBlock(),e.createBlock(lo,{key:0,item:r.value,value:r.value,"onUpdate:value":C[0]||(C[0]=S=>r.value=S)},null,8,["item","value"])):n.multiple?(e.openBlock(),e.createElementBlock("div",Ds,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(S,H)=>(e.openBlock(),e.createBlock(lo,{multiple:n.multiple,key:H,value:r.value,"onUpdate:value":C[1]||(C[1]=K=>r.value=K),item:S},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",n.disabled||c.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500 hover:bg-blue-50"])},[c.value?(e.openBlock(),e.createElementBlock("div",Ts)):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:0,class:"h-4 w-4"}))],2)])):e.createCommentVNode("",!0),n.multiple?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:2,onClick:g,class:e.normalizeClass([n.disabled||c.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"])},[c.value?(e.openBlock(),e.createElementBlock("div",Ls)):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:0,class:"h-4 w-4"}))],2))]))}}),[["__scopeId","data-v-f452b969"]]),Is={class:"vs-input-file2 flex flex-col gap-4"},Os={class:"flex items-center gap-x-2"},Rs=["accept","disabled"],Ps={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"},zs={key:0,class:"rounded-lg border border-[#CFD9E0] bg-white p-4 shadow-sm"},js={class:"flex items-center justify-between text-sm"},Us={class:"truncate pr-4"},Hs={class:"font-medium text-slate-800 truncate"},qs={class:"text-slate-500"},Ks={class:"text-slate-500 whitespace-nowrap"},Ws={class:"mt-3 h-2 rounded-full bg-slate-100 overflow-hidden"},Gs={class:"mt-3 flex flex-wrap gap-2 text-sm"},Ys={key:0,class:"mt-2 text-sm text-rose-600"},Xs=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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.ref(null),l=e.ref(null),a=e.ref(""),s=e.ref(0),c=e.ref(!1),i=e.ref(""),d=e.ref(null),u=e.inject("values"),p=e.computed(()=>t.format?t.format.split(",").map(V=>V.trim().toLowerCase()).filter(Boolean):[]),f=e.computed(()=>!l.value||!l.value.size?0:Math.min(100,Math.round(s.value/l.value.size*100))),y=e.computed(()=>l.value?`${g(s.value)} / ${g(l.value.size)}`:""),h=e.computed(()=>t.disabled?"opacity-50 cursor-not-allowed":c.value?"cursor-default text-blue-500":"cursor-pointer hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500"),k=()=>{t.disabled||c.value||S()&&r.value?.click()},g=V=>{if(!Number.isFinite(V))return"0 B";const T=["B","KB","MB","GB"];let M=0,O=V;for(;O>=1024&&M<T.length-1;)O/=1024,M+=1;return`${O.toFixed(M===0?0:1)} ${T[M]}`},v=V=>{if(!t.max_size)return!0;const T=t.max_size*1024*1024;return V.size>T?(ye.notify({type:"error",title:"Файл занадто великий",message:`Максимальний розмір ${t.max_size} МБ`,position:"right-bottom"}),!1):!0},x=V=>{if(!p.value.length)return!0;const T=`.${V.name.split(".").pop()?.toLowerCase()||""}`;return p.value.includes(T)?!0:(ye.notify({type:"error",title:"Непідтримуваний формат",message:`Дозволені формати: ${p.value.join(", ")}`,position:"right-bottom"}),!1)},C=e.computed(()=>{const V={},T=[];if(!t.customParams?.length)return{params:V,missing:T};const M=u?.value??{};return t.customParams.forEach(O=>{if(!O)return;const[Q,J]=O.split("="),de=Q?.trim(),te=J?.trim();if(!de||!te)return;const F=M[te];F==null||F===""?T.push(te):V[de]=F}),{params:V,missing:T}}),S=()=>C.value.missing.length?(ye.notify({type:"warning",title:"Заповніть поля",message:`Потрібні значення: ${C.value.missing.join(", ")}`,position:"right-bottom"}),!1):!0,H=V=>{const T=V.target,M=T.files?.[0];if(M){if(!S()){T.value="";return}if(!v(M)||!x(M)){T.value="";return}l.value=M,s.value=0,a.value="",i.value=""}},K=async()=>{if(!l.value){k();return}try{i.value="";const V={id:a.value||"",fileName:l.value.name,subdir:t.subdir,size:l.value.size,...C.value.params},T=await fetch("/api/file/upload2/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(V)});if(!T.ok)throw new Error("Не вдалося ініціалізувати завантаження");const M=await T.json();a.value=M.id||a.value,s.value=M.uploaded||0,await L()}catch(V){i.value=V?.message||"Помилка при старті завантаження"}},L=async()=>{if(!(!l.value||!a.value)){c.value=!0;try{for(;s.value<l.value.size;){const V=s.value,T=Math.min(V+t.chunkSize,l.value.size),M=l.value.slice(V,T);d.value=new AbortController;const O=await fetch(`/api/file/upload2/${a.value}`,{method:"PATCH",headers:{"Content-Range":`bytes ${V}-${T-1}/${l.value.size}`},body:M,signal:d.value.signal});if(!O.ok)throw new Error("Помилка завантаження частини");const Q=await O.json().catch(()=>({}));if(Q.uploaded!=null?s.value=Number(Q.uploaded):s.value=T,Q.finished||s.value>=l.value.size){c.value=!1;const J=Q.file_path||Q.url||a.value;o.value={file_id:Q.file_id??a.value??J,file_path:J},ye.notify({type:"success",title:"Файл завантажено",message:l.value.name,position:"right-bottom"}),R();return}}}catch(V){if(V?.name==="AbortError")return;i.value=V?.message||"Помилка при завантаженні",c.value=!1}finally{d.value=null,c.value=!1}}},B=()=>{c.value&&(d.value?.abort(),d.value=null,c.value=!1)},_=async()=>{if(l.value){if(!a.value){await K();return}await L()}},$=()=>{d.value?.abort(),d.value=null,R()},R=()=>{const V=r.value;V&&(V.value=""),l.value=null,a.value="",s.value=0,i.value=""};return(V,T)=>(e.openBlock(),e.createElementBlock("div",Is,[e.createElementVNode("div",Os,[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",class:"hidden",accept:t.format,disabled:c.value||t.disabled,onChange:H},null,40,Rs),o.value?(e.openBlock(),e.createBlock(lo,{key:0,item:o.value,"onUpdate:item":T[0]||(T[0]=M=>o.value=M),value:o.value,"onUpdate:value":T[1]||(T[1]=M=>o.value=M)},null,8,["item","value"])):(e.openBlock(),e.createElementBlock("div",{key:1,onClick:k,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",h.value])},[c.value?(e.openBlock(),e.createElementBlock("div",Ps,[T[2]||(T[2]=e.createElementVNode("div",{class:"loader"},null,-1)),e.createElementVNode("span",null,e.toDisplayString(f.value)+"%",1)])):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:1,class:"h-4 w-4"}))],2))]),l.value&&!o.value?(e.openBlock(),e.createElementBlock("div",zs,[e.createElementVNode("div",js,[e.createElementVNode("div",Us,[e.createElementVNode("div",Hs,e.toDisplayString(l.value.name),1),e.createElementVNode("div",qs,e.toDisplayString(g(l.value.size)),1)]),e.createElementVNode("div",Ks,e.toDisplayString(y.value),1)]),e.createElementVNode("div",Ws,[e.createElementVNode("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-300",style:e.normalizeStyle({width:`${f.value}%`})},null,4)]),e.createElementVNode("div",Gs,[!c.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:_}," Resume ")):e.createCommentVNode("",!0),c.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),!c.value&&s.value===0?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:K}," Upload ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"rounded border border-rose-200 px-3 py-1 text-rose-600",onClick:$}," Cancel ")]),i.value?(e.openBlock(),e.createElementBlock("p",Ys,e.toDisplayString(i.value),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]))}}),ao=Be(Xs,[["__scopeId","data-v-19ea2129"]]),Zs={class:"flex items-center justify-center h-[30px] w-[30px]"},Js={class:"max-w-[55vw]"},Qs={class:"text-sm font-semibold text-gray-800 truncate dark:text-neutral-200"},ei={class:"flex items-center text-xs text-gray-500 truncate dark:text-neutral-500"},ti={class:"px-[5px]"},ni={class:""},Bn=e.defineComponent({__name:"vs-widget-file-info",props:{item:{default:null}},setup(n){const t=n,o=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",Zs,[e.createVNode(e.unref(q.FileText),{class:"icon icon-tabler icons-tabler-outline icon-tabler-file h-4 w-4"})]),e.createElementVNode("div",Js,[e.createElementVNode("p",Qs,e.toDisplayString(n.item?.uploaded_name),1),e.createElementVNode("p",ei,[e.createElementVNode("span",null,e.toDisplayString(n.item?.username),1),e.withDirectives(e.createElementVNode("span",ti,"|",512),[[e.vShow,n.item?.username]]),e.createElementVNode("span",null,e.toDisplayString(o.value),1),a[0]||(a[0]=e.createElementVNode("span",{class:"px-[5px]"},"|",-1)),e.createElementVNode("span",ni,e.toDisplayString(r(n.item?.size)),1)])])],64))}}),oi={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-md w-full"},ri={key:0,class:"flex w-full gap-x-3 items-center"},li={key:1,class:"flex gap-x-3 w-full items-center"},ai={key:2,class:"flex gap-x-3 w-full items-center"},si=["href"],ii={key:3,class:"flex gap-x-3 w-full items-center"},ci={class:"lg:absolute lg:top-3 lg:end-1 opacity-100"},di={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"},ui={class:"inline-block"},pi={class:"inline-block"},mi={class:"inline-block"},fi=e.defineComponent({__name:"vs-widget-file-item",props:{item:{default:null},index:{default:0},prefix:{default:"/api"}},emits:["update","openModal","openLightbox"],setup(n,{emit:t}){const o=n,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 f=document.createElement("a");f.setAttribute("download",p?.uploaded_name),f.href=p?.file_path,f.click()}function c(p){p?.file_path&&window.open(p.file_path,"_blank")}async function i(){try{await fetch(`${o.prefix}/widget/file/${o.item.entity_id}/${o.item.file_id}`),r("update")}catch(p){console.error(p)}}function d(){r("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:i,updateListOnConfirm:!0})}function u(p){(o.item.ext==="jpg"||o.item.ext==="png")&&r("openLightbox",{item:o.item,index:p})}return(p,f)=>(e.openBlock(),e.createElementBlock("div",oi,[n.item.ext==="jpg"||n.item.ext==="png"?(e.openBlock(),e.createElementBlock("div",ri,[e.createElementVNode("div",{class:"max-w-[55vw] cursor-pointer flex gap-x-3 w-full items-center",onClick:f[0]||(f[0]=y=>u(n.index))},[e.createVNode(Bn,{item:n.item},null,8,["item"])])])):l(n.item)?(e.openBlock(),e.createElementBlock("div",li,[e.createVNode(Bn,{item:n.item},null,8,["item"])])):a(n.item)?(e.openBlock(),e.createElementBlock("div",ai,[e.createElementVNode("a",{href:`/api/file-preview?id=${n.item.file_id}`,target:"_blank",class:"flex gap-x-3 w-full items-center"},[e.createVNode(Bn,{item:n.item},null,8,["item"])],8,si)])):(e.openBlock(),e.createElementBlock("div",ii,[e.createVNode(Bn,{item:n.item},null,8,["item"])])),e.createElementVNode("div",ci,[e.createElementVNode("div",di,[e.createElementVNode("div",ui,[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:f[1]||(f[1]=y=>c(n.item))},[e.createVNode(e.unref(q.Eye),{class:"h-4 w-4"})])]),e.createElementVNode("div",pi,[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:f[2]||(f[2]=y=>s(n.item))},[e.createVNode(e.unref(q.Download),{class:"h-4 w-4"})])]),f[4]||(f[4]=e.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),e.createElementVNode("div",mi,[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:f[3]||(f[3]=y=>d())},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})])])])])]))}}),hi={class:"flex flex-col widget-file xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700 w-full"},gi={class:"flex w-full mb-[12px] items-center gap-x-2"},yi={class:"font-semibold text-gray-800 dark:text-neutral-200 text-[14px]"},bi={class1:"ml-auto"},ki={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"},xi={key:0,class:"py-4 mb-4 space-y-4 border-gray-200 border-y dark:border-neutral-700"},wi={class:"relative"},Ci={class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-[1] ps-3.5"},vi={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"},Ei={key:0},qo=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(n,{emit:t}){const o=n,r=e.inject("form"),l=e.computed(()=>r.value.formId),a=e.ref(!1),s=e.ref(0),c=t,i=e.ref(!1),d=e.ref({}),u=e.ref([]),p=e.ref(""),f=e.computed(()=>Array.isArray(u.value)?u.value.filter(C=>C.ext==="jpg"||C.ext==="png").map(C=>C?.file_path):[]),y=e.computed(()=>p.value===""?u.value:u.value.filter(C=>C?.uploaded_name?.includes(p.value))),h=C=>{const S=f.value.findIndex(H=>H===C.item.file_path);S!==-1&&(a.value=!0,s.value=S)},k=async()=>{try{const C=await fetch(`${o.prefix}/widget/file/${l.value}`).then(S=>S.json());u.value=C?.rows}catch(C){console.error(C)}},g=async C=>{await Promise.all(Array.from(C.target.files).map(async S=>{const H=new FormData;H.append("file",S);try{const K=`${o.prefix}/widget/file/${l.value}`,L=await fetch(K,{method:"POST",body:H});return L.ok?(c("update","file-list"),S):(ye.notify({type:L.status>=400&&L.status<500?"warning":"error",title:"Error",message:`Error code: ${L.status}`}),null)}catch(K){return ye.notify({type:"error",title:"Error",message:K.message||"Unknown error"}),console.error(K),null}})),await k()},v=C=>{const S={...C};return C.cancel||(S.cancel=()=>{i.value=!1}),C.updateListOnConfirm&&(S.confirm=async()=>{await C.confirm(),i.value=!1,k()}),S},x=C=>{d.value=v(C),i.value=!0};return e.watch(l,C=>{C&&k()}),e.onMounted(()=>{l.value&&k()}),(C,S)=>{const H=e.resolveComponent("Lightbox"),K=e.resolveComponent("MessageBox");return e.openBlock(),e.createElementBlock("div",hi,[e.createElementVNode("div",gi,[e.createElementVNode("h2",yi," Файлів: "+e.toDisplayString(u.value?.length),1),e.createElementVNode("div",bi,[e.createElementVNode("label",null,[e.createElementVNode("input",{type:"file",class:"hidden",onChange:S[0]||(S[0]=L=>g(L))},null,32),e.createElementVNode("div",ki,[e.createVNode(e.unref(q.Upload),{class:"h-4 w-4"})])])])]),u.value?.length>4?(e.openBlock(),e.createElementBlock("div",xi,[e.createElementVNode("div",null,[e.createElementVNode("div",wi,[e.createElementVNode("div",Ci,[e.createVNode(e.unref(q.Search),{class:"flex-shrink-0 text-gray-500 size-4 dark:text-neutral-400"})]),e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":S[1]||(S[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",vi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,(L,B)=>(e.openBlock(),e.createBlock(fi,{key:B,prefix:n.prefix,item:L,index:B,onUpdate:S[2]||(S[2]=_=>C.$emit("update","file-list")),onOpenModal:S[3]||(S[3]=_=>x(_)),onOpenLightbox:S[4]||(S[4]=_=>h(_))},null,8,["prefix","item","index"]))),128)),y.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Ei,[...S[8]||(S[8]=[e.createElementVNode("p",{class:"text-sm text-gray-600 font-sm"}," Файлів з такою назвою не існує, введіть інше пошукове слово ",-1)])]))])):e.createCommentVNode("",!0),e.createVNode(H,{modelValue:a.value,"onUpdate:modelValue":S[5]||(S[5]=L=>a.value=L),startIndex:s.value,"onUpdate:index":S[6]||(S[6]=L=>s.value=L),images:f.value},null,8,["modelValue","startIndex","images"]),e.createVNode(K,e.mergeProps({modelValue:i.value,"onUpdate:modelValue":S[7]||(S[7]=L=>i.value=L),onConfirm:d.value.confirm},d.value),null,16,["modelValue","onConfirm"])])}}}),Bi={class:"flex items-center justify-between"},_i={class:"text-[16px] text-gray-900 font-medium"},Vi={class:"grid gap-3"},Si=Be(e.defineComponent({__name:"vs-container-switcher",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(n){const t=n,o=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{o.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",Bi,[e.createElementVNode("p",_i,e.toDisplayString(n.title),1),e.createVNode(Yn,{modelValue:o.value,"onUpdate:modelValue":l[0]||(l[0]=a=>o.value=a),style:e.normalizeStyle(n.style)},null,8,["modelValue","style"])]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",Vi,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,o.value]])]),_:3})]))}}),[["__scopeId","data-v-00f2f0fc"]]),$i={class:"text-[16px] text-gray-900 font-medium"},Ni={class:"grid gap-3"},Ai=Be(e.defineComponent({__name:"vs-container-accordion",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(n){const t=n,o=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{o.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("button",{type:"button",onClick:l[0]||(l[0]=a=>o.value=!o.value),class:"flex items-center gap-2"},[e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 duration-300",[o.value?"-rotate-180":""]])},null,8,["class"]),e.createElementVNode("span",$i,e.toDisplayString(n.title),1)]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",Ni,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,o.value]])]),_:3})]))}}),[["__scopeId","data-v-dde48964"]]),Mi={class:"flex items-center justify-between"},Fi={switcher:Si,accordion:Ai,default:e.defineComponent({__name:"vs-container-default",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})}},setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",Mi,[e.createElementVNode("p",null,e.toDisplayString(n.title),1)]),e.renderSlot(t.$slots,"default")]))}})},ot={Equal:"==",Inequal:"!=",Higer:">",HigerOrEqual:">=",Lower:"<",LowerOrEqual:"<=",Between:"between",StartWith:"^",EndWith:"$",Contain:"*",In:"in",NotIn:"not_in"},Di=(n,t)=>String(n)===String(t),Ti=(n,t)=>String(n)!==String(t),Li=(n,t)=>n>t,Ii=(n,t)=>n>=t,Oi=(n,t)=>n<t,Ri=(n,t)=>n<=t,Pi=(n,t)=>Array.isArray(t)&&t.length===2?n>=t[0]&&n<=t[1]:!1,zi=(n,t)=>String(n).startsWith(String(t)),ji=(n,t)=>String(n).endsWith(String(t)),Ui=(n,t)=>String(n).includes(String(t)),Hi=(n,t)=>Array.isArray(t)?t.includes(n):!1,qi=(n,t)=>Array.isArray(t)?!t.includes(n):!0,Ki=(n,t)=>{if(!t)return!0;switch(t?.[1]){case ot.Equal:return Di(n,t?.[2]);case ot.Inequal:return Ti(n,t?.[2]);case ot.Higer:return Li(n,t?.[2]);case ot.HigerOrEqual:return Ii(n,t?.[2]);case ot.Lower:return Oi(n,t?.[2]);case ot.LowerOrEqual:return Ri(n,t?.[2]);case ot.Between:return Pi(n,t?.[2]);case ot.StartWith:return zi(n,t?.[2]);case ot.EndWith:return ji(n,t?.[2]);case ot.Contain:return Ui(n,t?.[2]);case ot.In:return Hi(n,t?.[2]);case ot.NotIn:return qi(n,t?.[2]);default:return!0}};function Ko(n,t,o){return t==null||!Array.isArray(t)||t.length===0?!0:(Array.isArray(t[0])?t:[t]).every(l=>{if(!Array.isArray(l)||l.length<2)return!0;const a=l[0],s=o?n?.[o]?.[a]??n?.[a]:n?.[a];return Ki(s,l)})}const Wo=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(n){const t=n,o=e.inject("values",e.ref({})),r=e.inject("form"),l=e.computed(()=>t.schema?.filter(c=>Ko(o.value,c?.conditions,t.name||void 0))),a=e.computed(()=>Fi[t.view]),s=e.computed(()=>{if(o.value||(o.value={}),!t.name)return o.value;const c=o.value[t.name];if(c)return c;const i={};return o.value={...o.value,[t.name]:i},i});return(c,i)=>n.schema?.length?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:0,title:n.title,style:e.normalizeStyle(n.style)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,d=>(e.openBlock(),e.createBlock(gr,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:n.style,error:e.unref(r)?.errors?.[d.name]}),null,16,["item","modelValue","onUpdate:modelValue","style","error"]))),128))]),_:1},8,["title","style"])):e.createCommentVNode("",!0)}}),Go=({props:n,fetchOptionByValue:t,optionsList:o,selectedOption:r,modelValue:l,onCreated:a})=>{const s=e.ref(!1),c=e.ref({}),i=e.ref([]),d=e.ref(null),u=e.computed(()=>n.add?.title||"Додати"),p=e.computed(()=>n.add?.token||n.add?.model||""),f=e.computed(()=>n.add?.pk||"id");return{isOpenAdd:s,addData:c,addSchema:i,addForm:d,addTitle:u,addOption:async()=>{if(!(!p.value||d?.value.validate()))try{const g=n.add?.api??`/api/table/${p.value}`,v=await fetch(g,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(c.value)}),x=await v.json().catch(()=>({})),C=x?.error||x?.message,S=Number(x?.code)>=400;if(!v.ok||S){ye.notify({title:"Помилка",type:"error",message:C||`Код помилки: ${x?.code||v.status}`});return}const H=x?.[f.value]??x?.id;if(!H){ye.notify({title:"Помилка",type:"error",message:"Обʼєкт створено, але в відповіді відсутній ID."});return}const K=await t(H);K&&(o.value.some(B=>String(B?.id)===String(K.id))||o.value.push(K)),a?await a(K,H):K&&(r.value=K,l.value=H),s.value=!1,ye.notify({title:"Успіх",message:"Обʼєкт успішно створено."})}catch(g){ye.notify({title:"Помилка",type:"error",message:g?.message||"Не вдалося створити обʼєкт."})}},onAddValue:async()=>{if(!n.add)return null;const k=await fetch(`/api/template/form/${n.add.form}`).then(g=>g.json());return i.value=k.schema,c.value={},s.value=!0,null}}},Wi=["aria-expanded","data-focus"],Gi={class:"relative flex flex-1 items-center gap-1 py-0.5 pl-1 pr-0 overflow-hidden h-full min-w-0"},Yi={key:0,class:"flex flex-nowrap items-center gap-1 overflow-x-auto overflow-y-hidden min-w-0 flex-1 py-0.5"},Xi={class:"flex items-center gap-1 min-w-0"},Zi=["title"],Ji=["innerHTML"],Qi=["onClick"],ec={class:"flex-1 min-w-[2px]"},tc=["placeholder"],nc=["title"],oc=["innerHTML"],rc={key:3,class:"truncate flex-1 min-w-0"},lc={key:2,class:"flex-1 min-w-[2px]"},ac=["placeholder"],sc={key:3,class:"flex-1 flex items-center min-h-[30px] py-0.5 pl-2 text-sm truncate text-inherit"},ic={class:"flex items-center shrink-0"},cc=["disabled"],dc={key:1,class:"self-stretch w-px bg-[#ccc] my-[1px]"},uc=["disabled","title"],pc=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(n,{emit:t}){const o=n,r=t,l=e.computed({get:()=>o.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",n.disabled?"bg-gray-100 text-gray-400 cursor-not-allowed":""]),role:"combobox","aria-expanded":n.isOpen,"aria-haspopup":"listbox",onKeydown:s[10]||(s[10]=(...c)=>n.onControlKeydown&&n.onControlKeydown(...c)),onClick:s[11]||(s[11]=(...c)=>n.onControlClick&&n.onControlClick(...c)),"data-focus":n.isOpen||n.inputFocus?"true":"false",ref:n.setTriggerRef},[e.createElementVNode("div",Gi,[n.isMulti?(e.openBlock(),e.createElementBlock("div",Yi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.selectedOptions,c=>(e.openBlock(),e.createElementBlock("div",{key:c.id,class:"flex min-w-0 bg-[rgb(230,230,230)] rounded-[2px] m-[2px] box-border max-w-full"},[e.createElementVNode("div",Xi,[n.shouldShowColorDot(c)?(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:c?.color})},null,4)):e.createCommentVNode("",!0),!n.optionTemplate&&n.optionHasIcon(c)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(n.iconWrapperClass),style:e.normalizeStyle(n.getIconColorStyle(c)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.resolveOptionIcon(c)),{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:n.getLabel(c)},[n.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:n.renderTemplate(c)},null,8,Ji)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(c.text),1)],64))],8,Zi)]),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(i=>n.onRemoveSelected(c.id),["stop"])},[e.createVNode(e.unref(q.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Qi)]))),128)),e.createElementVNode("div",ec,[!n.disabled&&n.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref:n.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:n.selectedIds.length?" ":n.placeholder,"onUpdate:modelValue":s[0]||(s[0]=c=>l.value=c),onFocus:s[1]||(s[1]=(...c)=>n.onInputFocus&&n.onInputFocus(...c)),onBlur:s[2]||(s[2]=(...c)=>n.onInputBlur&&n.onInputBlur(...c)),onKeydown:s[3]||(s[3]=(...c)=>n.onInputKeydown&&n.onInputKeydown(...c))},null,40,tc)),[[e.vModelText,l.value]]):e.createCommentVNode("",!0)])])):!n.isMulti&&n.selectedOptionLabel&&l.value===""?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["truncate flex items-center gap-1 min-w-0 pl-2",n.disabled||!n.search?"relative z-0 flex-1 min-h-[30px] py-0.5 text-inherit":"absolute inset-x-0 top-0 bottom-0 z-[1] text-gray-900"]),title:n.selectedOptionLabel},[n.shouldShowColorDot(n.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[14px] h-[14px] rounded-md block flex-shrink-0",style:e.normalizeStyle({backgroundColor:n.selectedOption?.color})},null,4)):e.createCommentVNode("",!0),!n.optionTemplate&&n.optionHasIcon(n.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(n.iconWrapperClass),style:e.normalizeStyle(n.getIconColorStyle(n.selectedOption)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.resolveOptionIcon(n.selectedOption)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),n.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:2,class:"truncate flex-1 min-w-0",innerHTML:n.renderTemplate(n.selectedOption)},null,8,oc)):(e.openBlock(),e.createElementBlock("span",rc,e.toDisplayString(n.selectedOption?.text),1))],10,nc)):e.createCommentVNode("",!0),!n.isMulti&&!n.disabled&&n.search?(e.openBlock(),e.createElementBlock("div",lc,[e.withDirectives(e.createElementVNode("input",{ref:n.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:n.selectedOptionLabel?" ":n.placeholder,"onUpdate:modelValue":s[4]||(s[4]=c=>l.value=c),onFocus:s[5]||(s[5]=(...c)=>n.onInputFocus&&n.onInputFocus(...c)),onBlur:s[6]||(s[6]=(...c)=>n.onInputBlur&&n.onInputBlur(...c)),onKeydown:s[7]||(s[7]=(...c)=>n.onInputKeydown&&n.onInputKeydown(...c))},null,40,ac),[[e.vModelText,l.value]])])):!n.isMulti&&n.disabled&&(!n.selectedOptionLabel||l.value!=="")?(e.openBlock(),e.createElementBlock("div",sc,e.toDisplayString(n.placeholder),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",ic,[n.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:n.disabled,onClick:s[8]||(s[8]=e.withModifiers((...c)=>n.onClearSelected&&n.onClearSelected(...c),["stop"]))},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,cc)):e.createCommentVNode("",!0),n.showClear?(e.openBlock(),e.createElementBlock("div",dc)):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:n.disabled,onClick:s[9]||(s[9]=e.withModifiers((...c)=>n.onToggleSelect&&n.onToggleSelect(...c),["stop"])),title:n.isOpen?"Закрити список":"Відкрити список"},[e.createVNode(e.unref(q.ChevronDown),{class:"h-4 w-4"})],8,uc)])],42,Wi))}}),mc=["aria-disabled","onMousedown"],fc={class:"leading-[19px]"},hc=["innerHTML"],gc={key:1,class:"px-3 py-2 text-center text-gray-500"},yc=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(n){return(t,o)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.isOpen?(e.openBlock(),e.createElementBlock("div",{key:0,ref:n.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(n.dropdownStyle),role:"listbox"},[e.createElementVNode("div",{class:"overflow-y-auto py-1",style:e.normalizeStyle({maxHeight:n.dropdownStyle.maxHeight||"300px"}),ref:n.setListRef},[n.filteredOptionsList.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(n.filteredOptionsList,(r,l)=>(e.openBlock(),e.createElementBlock("div",{key:r.id,ref_for:!0,ref:a=>n.setItemRef(a,l),class:e.normalizeClass(["flex px-3 py-2 gap-2 cursor-pointer select-none text-gray-900",n.isSelected(r.id)?"bg-[#2684ff] text-white":"bg-white hover:bg-[#deebff] hover:text-[#172b4d]",n.selectedNavIndex===l&&!n.isSelected(r.id)?"bg-[#deebff] text-[#172b4d]":""]),"aria-disabled":n.isSelected(r.id)?"true":"false",role:"option",tabindex:"-1",onMousedown:e.withModifiers(a=>n.onOptionClick(r),["prevent","stop"])},[n.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),!n.optionTemplate&&n.optionHasIcon(r)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(n.iconWrapperClass),style:e.normalizeStyle(n.getIconColorStyle(r)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n.resolveOptionIcon(r)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",fc,[n.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:n.renderTemplate(r)},null,8,hc)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r.text),1)],64))])],42,mc))),128)):(e.openBlock(),e.createElementBlock("div",gc," No options "))],4)],4)):e.createCommentVNode("",!0)]))}}),bc=["disabled"],kc="__autoMeta",Yo="w-[16px] h-[16px] flex items-center justify-center flex-shrink-0 text-current",so=Be(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(n,{emit:t}){const o=n,r=t,l=e.computed(()=>o.multiple),a=e.computed(()=>o.disabled),s=e.computed(()=>o.search);Ge(o.style);const c=e.computed({get:()=>o.modelValue,set:j=>r("update:modelValue",j)});!c.value&&o.defaultValue&&(c.value=o.defaultValue);const i=e.ref(null),d=e.ref(null),u=e.ref(null),p=e.ref(null),f=e.ref(!1),y=e.ref(!1),h=e.ref(null),k=e.ref(-1),g=e.ref([]),v=e.ref(""),x=e.ref(null),C=j=>{d.value=j},S=j=>{x.value=j},H=j=>{p.value=j},K=j=>{u.value=j},L=(j,ee)=>{g.value[ee]=j},B=e.ref({}),_=e.ref([]),$=e.computed(()=>{if(!_.value.length)return[];const j=ke.value,ee=new Map(j.map(fe=>[fe.id?.toString(),fe]));return _.value.map(fe=>ee.get(fe?.toString())).filter(fe=>!!fe)}),R=e.computed(()=>o.placeholder||"Select..."),V=e.computed(()=>F(h.value)),T=e.computed(()=>a.value?!1:l.value?_.value.length>0:!!c.value),M=j=>l.value?_.value.some(ee=>ee?.toString()===j?.toString()):c.value?.toString()===j?.toString(),O=e.computed(()=>{let j=ke.value??[];if(!o.data&&v.value.trim()!==""){const ee=v.value.toLowerCase();j=j.filter(fe=>{const $e=F(fe).toLowerCase(),Oe=fe.text?.toLowerCase?.()||"";return $e.includes(ee)||Oe.includes(ee)})}if(l.value&&_.value.length){const ee=new Set(_.value.map(fe=>fe?.toString()));j=j.filter(fe=>!ee.has(fe.id?.toString()))}return j}),Q=e.inject("values"),J=e.inject("field-props"),de=e.computed(()=>o.slot??o?.optionTemplate??""),te=j=>yn(j,de.value),F=j=>bn(j,de.value),Y=e.computed(()=>fn(de.value)),ne=j=>Gt(j),W=j=>!!(!Y.value&&Vt(j)&&!ne(j)),ce=j=>{const ee=Vt(j);return ee?{color:ee}:void 0},he=j=>!!(!Y.value&&(Wt(j)||ne(j))),re=(j,ee,fe)=>{if(!J)return!1;const $e=J.value?.[j]??{},Oe=(Re,tt,pt)=>{if(!tt.length)return Re;const[mt,...kt]=tt,st={...Re};if(!kt.length)return st[mt]=pt,st;const un=typeof Re[mt]=="object"&&Re[mt]!==null?Re[mt]:{};return st[mt]=Oe(un,kt,pt),st},We=Oe($e,ee,fe);return J.value={...J.value||{},[j]:We},!0},pe=j=>{if(!J||!o.name)return;const ee=J.value?.[o.name]??{};J.value={...J.value||{},[o.name]:{...ee,[kc]:j}}},Ce=j=>{if(!o.set)return;const ee=Q?.value;!ee&&!J||Object.entries(o.set).forEach(([fe,$e])=>{if(!fe)return;const Oe=j?j[$e]:null,We=fe.split(".").map(pt=>pt.trim()).filter(Boolean);if(!We.length)return;const[Re,...tt]=We;tt.length&&re(Re,tt,Oe??null)||ee&&(ee[Re]=Oe??null)})},{optionsList:ke,parentValue:Se,fetchOptions:De,fetchOptionByValue:Me,loadOptions:Te}=gn({props:o,formValues:Q,watchParent:!1}),Z=j=>j==null?"":String(j),ae=j=>{if(l.value){if(!_.value.length){ke.value=j;return}}else if(!h.value){ke.value=j;return}const ee=new Set(j.map($e=>Z($e.id)).filter(Boolean));if(l.value){const $e=new Set(_.value.map(We=>Z(We)).filter(Boolean)),Oe=(ke.value??[]).filter(We=>{const Re=Z(We.id);return!Re||!$e.has(Re)?!1:!ee.has(Re)});ke.value=[...Oe,...j];return}const fe=Z(h.value?.id);if(fe&&!ee.has(fe)){ke.value=[h.value,...j];return}ke.value=j},xe=e.ref(0),ve=async j=>{const ee=++xe.value,fe=await De(j);return ee!==xe.value?null:fe},Fe=async()=>{if(o.data){const j=await ve(v.value);return j&&ae(j),ke.value}return Te()},je=async j=>{if(j==null||j==="")return null;const ee=ke.value?.find(fe=>fe?.id?.toString()===String(j));return ee||Me(j)},U=async j=>{const ee=new Set(ke.value.map($e=>$e.id?.toString())),fe=j.filter($e=>!ee.has($e?.toString()));fe.length&&await fe.reduce(async($e,Oe)=>{await $e;const We=await je(Oe);We&&ke.value.push(We)},Promise.resolve())},X=()=>{if(!O.value.length){k.value=-1;return}let j=0;if(!l.value&&h.value){const ee=h.value.id?.toString(),fe=O.value.findIndex($e=>$e.id?.toString()===ee);fe>=0&&(j=fe)}k.value=j,e.nextTick(()=>{I(g.value[j],u.value)})},le=async()=>{a.value||(f.value=!0,await e.nextTick(()=>{be()}),await Fe(),await e.nextTick(()=>{be(),x.value?.focus()}),X())},ue=()=>{f.value=!1,k.value=-1,e.nextTick(()=>{x.value?.blur()})},P=async j=>{if(a.value)return;(j!==void 0?j:!f.value)?await le():ue()},oe=async()=>{if(!a.value){if(f.value){ue();return}await le()}},Ve=()=>{l.value?(_.value=[],c.value=[],r("change",[]),z(null,[])):(h.value=null,c.value=null,r("change",null),z(null,null)),Ce(null),v.value="",e.nextTick(()=>{x.value?.focus(),f.value||le()})},Ne=j=>{l.value&&(_.value=_.value.filter(ee=>ee?.toString()!==j?.toString()),c.value=[..._.value],r("change",c.value),z(null),e.nextTick(()=>x.value?.focus()))},z=(j,ee)=>{const fe=ee??(l.value?[..._.value]:j?.id??null);r("value-selected",{name:o.name,value:fe,option:j})},w=(j,ee="manual")=>{l.value?(M(j.id)||(_.value=[..._.value,j.id],c.value=[..._.value],r("change",c.value),z(j)),v.value="",e.nextTick(()=>{x.value?.focus(),k.value=Math.min(k.value,O.value.length-1)}),Ce(null)):(h.value=j,c.value=j.id,r("change",c.value),z(j),v.value="",ue(),Ce(j),ee==="parent-auto"&&pe({source:ee,parentField:o.parent??null,parentValue:Se.value??null}))},N=j=>{if(M(j.id)){l.value||ue();return}w(j)},I=(j,ee)=>{if(!j||!ee)return;const fe=j.offsetTop,$e=fe+j.offsetHeight,Oe=ee.scrollTop,We=Oe+ee.clientHeight;let Re=ee.scrollTop;fe<Oe?Re=fe-80:$e>We&&(Re=$e-ee.clientHeight+4);const tt=ee;tt.scrollTop=Re},se=j=>{let ee=j.parentElement;for(;ee;){if(ee.classList.contains("ui-dialog__content"))return ee;const fe=window.getComputedStyle(ee),$e=fe.overflow+fe.overflowY+fe.overflowX;if($e.includes("auto")||$e.includes("scroll")||ee===document.body||ee===document.documentElement)return ee;ee=ee.parentElement}return document.body},be=()=>{if(!d.value)return;const j=d.value.getBoundingClientRect(),ee=window.innerHeight||document.documentElement.clientHeight,fe=window.innerWidth||document.documentElement.clientWidth,$e=8,Oe=8,We=o.maxHeight||300,Re=ee-j.bottom-Oe-$e,tt=j.top-Oe-$e,pt=Re>=tt,mt=Math.max(fe-$e*2,0);let{width:kt}=j;mt>0&&kt>mt&&(kt=mt);let{left:st}=j;st+kt+$e>fe&&(st=fe-kt-$e),st=Math.max(st,$e);const un=Math.min(We,Math.max(pt?Re:tt,50));B.value={position:"fixed",left:`${st}px`,width:`${kt}px`,maxHeight:`${un}px`,transform:pt?"none":"translateY(-100%)",top:pt?`${j.bottom+Oe}px`:`${j.top-Oe}px`}},Le=async j=>{a.value||!f.value&&(j.key==="ArrowDown"||j.key==="ArrowUp")&&(j.preventDefault(),await le())},Ae=j=>{if(!f.value)return;const{key:ee}=j;if(ee==="ArrowDown")j.preventDefault(),k.value+1<O.value.length&&(k.value+=1,I(g.value[k.value],u.value));else if(ee==="ArrowUp")j.preventDefault(),k.value>0&&(k.value-=1,I(g.value[k.value],u.value));else if(ee==="Enter"){j.preventDefault();const fe=O.value[k.value];fe&&w(fe),x.value?.blur()}else ee==="Escape"?(j.preventDefault(),ue()):ee==="Backspace"?l.value&&v.value===""&&_.value.length&&(_.value=_.value.slice(0,-1),c.value=[..._.value],r("change",c.value)):ee==="Home"?(k.value=0,I(g.value[0],u.value)):ee==="End"?(k.value=O.value.length-1,I(g.value[k.value],u.value)):ee==="Tab"&&ue()},Ke=()=>{a.value||(y.value=!0)},dt=()=>{y.value=!1,v.value=""},ut=j=>{j.key==="Escape"&&f.value&&ue()},Ie=j=>{const ee=j.target;i.value?.contains(ee)||p.value?.contains(ee)||ue()},lt=j=>{f.value&&u.value&&!u.value.contains(j.target)&&be()},Pt=()=>{f.value&&be()},jn=()=>{f.value&&be()};async function Ft(){if(l.value)Array.isArray(c.value)?_.value=[...c.value]:(_.value=c.value==null?[]:[c.value],c.value=[..._.value]),o.data&&_.value.length&&(await U(_.value),await e.nextTick());else{if(Array.isArray(c.value)){const j=c.value[0]??null;c.value=j??null}c.value!=null&&(h.value=await je(c.value)),Ce(h.value??null)}}e.watch(c,()=>{Ft()}),e.onMounted(async()=>{if(addEventListener("keydown",ut),addEventListener("scroll",lt,!0),addEventListener("resize",Pt),document.addEventListener("click",Ie,!0),d.value&&se(d.value).addEventListener("scroll",jn,!0),o.options?.length&&!o.data)ke.value=[...o.options];else if(o.data){const j=await ve("");j&&ae(j)}await Ft(),Dt.value=!1}),e.onUnmounted(()=>{removeEventListener("keydown",ut),removeEventListener("scroll",lt,!0),removeEventListener("resize",Pt),document.removeEventListener("click",Ie,!0),d.value&&se(d.value).removeEventListener("scroll",jn,!0)});const{isOpenAdd:cn,addData:bt,addSchema:zt,addForm:vo,addTitle:Bt,addOption:Eo,onAddValue:qt}=Go({props:o,fetchOptionByValue:Me,optionsList:ke,selectedOption:h,modelValue:c});function at(j,ee=200){let fe;return(...$e)=>{fe&&clearTimeout(fe),fe=window.setTimeout(()=>j(...$e),ee)}}const dn=at(async j=>{const ee=await ve(j);ee&&ae(ee)},200);e.watch(v,j=>{o.data&&dn(j.trim())}),e.watch(()=>o.options,j=>{!o.data&&j?.length&&(ke.value=[...j],Ft())},{immediate:!0});const Dt=e.ref(!0);return e.watch(Se,async()=>{if(o.data&&(Dt.value||(l.value?(_.value=[],c.value=[],r("change",[])):(h.value=null,c.value=null,r("change",null))),await Fe(),o.auto===1&&Se.value&&ke.value.length>0)){const j=ke.value[0];j&&w(j,"parent-auto")}}),(j,ee)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(ye.VsModal),{visible:e.unref(cn),"onUpdate:visible":ee[1]||(ee[1]=fe=>e.isRef(cn)?cn.value=fe:null),class:"z-[1000]",title:e.unref(Bt),buttonText:"Додати",onDone:e.unref(Eo),teleport:n.teleport},{default:e.withCtx(()=>[e.createVNode(rt,{schema:e.unref(zt),modelValue:e.unref(bt),"onUpdate:modelValue":ee[0]||(ee[0]=fe=>e.isRef(bt)?bt.value=fe:null),ref_key:"addForm",ref:vo},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone","teleport"]),e.createElementVNode("div",{class:"flex gap-1 w-full",ref_key:"selectRoot",ref:i,onClick:ee[4]||(ee[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",o.customClass])},[ee[5]||(ee[5]=e.createElementVNode("span",{id:"react-select-live-region",class:"sr-only"},null,-1)),ee[6]||(ee[6]=e.createElementVNode("span",{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text",role:"log",class:"sr-only"},null,-1)),e.createVNode(pc,{keyWord:v.value,"onUpdate:keyWord":ee[2]||(ee[2]=fe=>v.value=fe),disabled:a.value,"is-open":f.value,"input-focus":y.value,"is-multi":l.value,"selected-options":$.value,"selected-ids":_.value,placeholder:R.value,search:s.value,"option-template":de.value,"icon-wrapper-class":Yo,"selected-option-label":V.value,"selected-option":h.value,"show-clear":T.value,"set-trigger-ref":C,"set-input-ref":S,"should-show-color-dot":W,"option-has-icon":he,"get-icon-color-style":ce,"resolve-option-icon":ne,"render-template":te,"get-label":F,"on-control-keydown":Le,"on-control-click":oe,"on-input-focus":Ke,"on-input-blur":dt,"on-input-keydown":Ae,"on-remove-selected":Ne,"on-clear-selected":Ve,"on-toggle-select":P},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(yc,{"is-open":f.value,"dropdown-style":B.value,"filtered-options-list":O.value,"selected-nav-index":k.value,"option-template":de.value,"icon-wrapper-class":Yo,"set-dropdown-ref":H,"set-list-ref":K,"set-item-ref":L,"is-selected":M,"on-option-click":N,"should-show-color-dot":W,"option-has-icon":he,"get-icon-color-style":ce,"resolve-option-icon":ne,"render-template":te},null,8,["is-open","dropdown-style","filtered-options-list","selected-nav-index","option-template"])],2),o.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:ee[3]||(ee[3]=(...fe)=>e.unref(qt)&&e.unref(qt)(...fe)),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(q.Plus),{class:"h-4 w-4"}),ee[7]||(ee[7]=e.createElementVNode("span",null,"Додати",-1))],8,bc)):e.createCommentVNode("",!0)],512)],64))}}),[["__scopeId","data-v-548e9de9"]]),io=(n="")=>`${n}${Math.floor(Math.random()*1e4)}`,xc=["disabled","aria-expanded"],wc={class:"truncate"},Cc={class:"py-2 px-4"},vc={class:"block font-medium text-[13px] text-foreground"},Ec={class:"truncate"},Bc={class:"p-1 border-t border-gray-200"},_c={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"},Vc=["onClick"],Sc=["checked"],$c={class:"shrink-0 size-3.5 flex justify-center items-center"},Nc={key:1,class:"shrink-0 size-2 block mx-auto rounded-full bg-secondary/60"},Ac={class:"truncate"},Mc={key:0,class:"px-3 py-2 text-xs text-stone-500"},_n=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(n,{emit:t}){const o=n,r=t;Ge(o.style);const l=e.computed({get:()=>Array.isArray(o.modelValue)?o.modelValue[0]??null:o.modelValue??null,set:re=>r("update:modelValue",re)});l.value==null&&o.defaultValue!=null&&(l.value=o.defaultValue);const a=e.inject("values"),s=e.inject("field-props"),c=e.computed(()=>!!o.disabled),i=e.ref(null),d=e.ref(!1),u=e.ref(null),p=e.ref(null),f=e.ref(null),y=e.ref({}),h=`vs-input-inline-select-${io()}`,k=e.computed(()=>o.placeholder||"Оберіть значення"),g=e.computed(()=>H(i.value)||o.placeholder||"Оберіть значення"),v=e.computed(()=>o.slot??""),x=e.computed(()=>fn(v.value)),C=e.computed(()=>o.teleport||"body"),S=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6}|[\da-fA-F]{8})$/,H=re=>bn(re,v.value),K=re=>!!(!x.value&&Vt(re)),L=e.computed(()=>{const re=Vt(i.value).trim();return re?S.test(re)?`bg-[${re}] border-[${re}]`:`bg-${re.toLowerCase()}-500 border-${re.toLowerCase()}-500`:""}),{optionsList:B,parentValue:_,fetchOptions:$,fetchOptionByValue:R,loadOptions:V}=gn({props:o,formValues:a,watchParent:!1}),T=(re,pe,Ce)=>{if(!s)return!1;const ke=s.value?.[re]??{},Se=(Me,Te,Z)=>{if(!Te.length)return Me;const[ae,...xe]=Te,ve={...Me};if(!xe.length)return ve[ae]=Z,ve;const Fe=typeof Me[ae]=="object"&&Me[ae]!==null?Me[ae]:{};return ve[ae]=Se(Fe,xe,Z),ve},De=Se(ke,pe,Ce);return s.value={...s.value||{},[re]:De},!0},M=re=>{if(!o.set)return;const pe=a?.value;!pe&&!s||Object.entries(o.set).forEach(([Ce,ke])=>{if(!Ce)return;const Se=re?re[ke]:null,De=Ce.split(".").map(Z=>Z.trim()).filter(Boolean);if(!De.length)return;const[Me,...Te]=De;Te.length&&T(Me,Te,Se??null)||pe&&(pe[Me]=Se??null)})},O=re=>l.value?.toString?.()===re?.toString?.(),Q=()=>{if(!p.value||typeof window>"u")return;const re=p.value.getBoundingClientRect(),pe=8,Ce=8,ke=window.innerHeight||document.documentElement.clientHeight,Se=window.innerWidth||document.documentElement.clientWidth,De=f.value?.offsetHeight||260,Me=Math.max(re.width,176),Te=Math.max(Se-pe*2,120),Z=Math.min(Me,Te);let ae=re.left;ae+Z+pe>Se&&(ae=Se-Z-pe),ae=Math.max(ae,pe);const xe=ke-re.bottom-Ce-pe,ve=re.top-Ce-pe,Fe=xe<Math.min(De,260)&&ve>xe,je=Math.max(120,Math.min(320,Fe?ve:xe));y.value={position:"fixed",left:`${ae}px`,top:Fe?`${re.top-Ce}px`:`${re.bottom+Ce}px`,transform:Fe?"translateY(-100%)":"none",width:`${Z}px`,maxHeight:`${je}px`}},J=async()=>{if(o.data){B.value=await $("");return}await V()},de=async()=>{if(l.value==null||l.value===""){i.value=null,M(null);return}const re=B.value.find(pe=>pe.id?.toString()===String(l.value));if(re){i.value=re,M(re);return}i.value=await R(l.value),M(i.value??null)},te=async()=>{c.value||(d.value=!0,await e.nextTick(),Q(),await J(),await e.nextTick(),Q())},F=()=>{d.value=!1},Y=async()=>{if(d.value){F();return}await te()},ne=re=>{r("value-selected",{name:o.name,value:re?.id??null,option:re})},W=re=>{i.value=re,l.value=re.id,r("change",re.id),ne(re),M(re),F()},ce=re=>{const pe=re.target;u.value?.contains(pe)||f.value?.contains(pe)||F()},he=()=>{d.value&&Q()};return e.watch(()=>o.options,re=>{o.data||(B.value=re?[...re]:[],de())},{immediate:!0,deep:!0}),e.watch(l,()=>{de()}),e.watch(_,async()=>{o.data&&(await J(),i.value&&!B.value.some(re=>re.id?.toString()===i.value?.id?.toString())&&(i.value=null,l.value=null,r("change",null),ne(null),M(null)))}),e.onMounted(async()=>{document.addEventListener("click",ce,!0),window.addEventListener("resize",he),window.addEventListener("scroll",he,!0),await J(),await de()}),e.onUnmounted(()=>{document.removeEventListener("click",ce,!0),window.removeEventListener("resize",he),window.removeEventListener("scroll",he,!0)}),(re,pe)=>(e.openBlock(),e.createElementBlock("div",{class:"relative inline-flex w-full max-w-full",ref_key:"rootRef",ref:u,onClick:pe[0]||(pe[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("button",{ref_key:"triggerRef",ref:p,type:"button",disabled:c.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:Y},[e.createElementVNode("span",wc,e.toDisplayString(g.value),1)],10,xc),(e.openBlock(),e.createBlock(e.Teleport,{to:C.value},[d.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:f,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(y.value),role:"menu","aria-orientation":"vertical"},[e.createElementVNode("div",Cc,[e.createElementVNode("span",vc,[e.createElementVNode("span",Ec,e.toDisplayString(k.value),1)])]),e.createElementVNode("div",Bc,[e.createElementVNode("div",_c,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(B),Ce=>(e.openBlock(),e.createElementBlock("label",{key:Ce.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(ke=>W(Ce),["prevent"])},[e.createElementVNode("input",{type:"radio",class:"hidden",name:h,checked:O(Ce.id),tabindex:"-1"},null,8,Sc),e.createElementVNode("span",$c,[K(Ce)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"shrink-0 size-2 block mx-auto rounded-full",style:e.normalizeStyle({backgroundColor:Ce.color})},null,4)):(e.openBlock(),e.createElementBlock("span",Nc))]),e.createElementVNode("span",Ac,e.toDisplayString(H(Ce)),1),e.createVNode(e.unref(q.Check),{class:e.normalizeClass(["shrink-0 size-3.5 ms-auto transition-opacity",O(Ce.id)?"opacity-100":"opacity-0"])},null,8,["class"])],8,Vc))),128))]),e.unref(B).length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Mc,"Немає варіантів"))])],4)):e.createCommentVNode("",!0)],8,["to"]))],512))}}),Fc=["placeholder","disabled"],Xo=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(n){const t=n,{inputClass:o}=Ge(t.style),r=e.useModel(n,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");function s(){typeof r.value=="string"&&(r.value=r.value.trim())}return(c,i)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{"onUpdate:modelValue":i[0]||(i[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(o)]]),style:{border:"1px solid #CFD9E0"}},null,42,Fc)),[[e.vModelText,r.value]])}}),Zo=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(n){const t=e.defineAsyncComponent(()=>Promise.resolve().then(()=>_0)),o=n,{inputClass:r}=Ge(o.style),l=e.useModel(n,"modelValue"),a=e.computed(()=>!!o.disabled),s=e.computed(()=>o.placeholder??""),c=e.computed(()=>({height:o.richtextProps.height||"300px",format:o.format,...o.richtextProps}));return(i,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["!h-full",[n.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},c.value),null,16,["modelValue","placeholder"])],6))}}),Dc={},Tc={viewBox:"0 0 178 90",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function Lc(n,t){return e.openBlock(),e.createElementBlock("svg",Tc,[...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 Ic=Be(Dc,[["render",Lc]]),Oc={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden flex flex-col"},Rc={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"},Pc={key:0,class:"relative flex-1 min-w-0"},zc={class:"flex flex-nowrap items-center justify-end gap-2 shrink-0"},jc={class:"w-full overflow-x-auto"},Uc={class:"w-full min-w-[640px] table-auto divide-y divide-gray-200"},Hc={class:"bg-gray-50"},qc={class:"border-b border-gray-200"},Kc={class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 w-12 text-center"},Wc=["onClick"],Gc={key:0,class:"text-gray-400"},Yc={key:0,colspan:"100%",class:"text-center"},Xc={class:"w-full"},Zc={class:"p-5 min-h-[200px] flex flex-col justify-center items-center text-center"},Jc=["data-row-index","onDragstart","onDragover","onDrop"],Qc=["onPointerdown"],ed={class:"flex items-center justify-center"},td=["innerHTML"],nd={key:0,class:"flex items-center gap-3 text-sm text-gray-700"},od={key:0},rd=["src"],ld={key:1,class:"rounded-md max-w-[45px] w-[45px] max-h-[45px] h-[45px] bg-gray-200 flex items-center justify-center"},ad={key:1,class:"flex items-center justify-center"},sd={key:2,class:"text-sm font-medium text-gray-900"},id={class:"px-4 py-3 text-right whitespace-nowrap"},cd={class:"flex items-center justify-end gap-2"},dd=["onClick"],ud=["onClick"],pd={class:"vs-form__head mr-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},Jo=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(n){const t=n,o=e.useSlots(),r=U=>t.actions===void 0?!0:t.actions.includes(U),l=["search","import","export","add"],a=e.computed(()=>l.some(U=>r(U))),s=e.useModel(n,"modelValue"),c=e.ref({}),i=e.ref(""),d=e.ref(null),u=e.ref("asc"),p=e.computed(()=>{const U=s.value??[],X=i.value?U.filter(P=>f.value?.some(oe=>{const Ve=oe.key||oe.name;if(!Ve)return!1;const Ne=P[Ve];return Ne?Array.isArray(Ne)?Ne.join(", ").toLowerCase().includes(i.value.toLowerCase()):String(Ne).toLowerCase().includes(i.value.toLowerCase()):!1})):U;if(!d.value)return X;const le=d.value,ue=[...X].sort((P,oe)=>{const Ve=Se(P?.[le]),Ne=Se(oe?.[le]);return typeof Ve=="number"&&typeof Ne=="number"?Ve-Ne:String(Ve).localeCompare(String(Ne))});return u.value==="asc"?ue:ue.reverse()}),f=e.computed(()=>(t.colModel??[]).filter(U=>!U.tableHidden)),y=e.ref(null),h=e.ref(null),k=e.ref(null);function g(U){return U.pointerType==="touch"||U.pointerType==="pen"}function v(U,X){const ue=document.elementFromPoint(U,X)?.closest?.("[data-row-index]")??null;if(!ue)return null;const P=ue.getAttribute("data-row-index");if(P==null)return null;const oe=Number.parseInt(P,10);return Number.isNaN(oe)?null:oe}function x(U,X){g(U)&&(U.preventDefault(),U.currentTarget.setPointerCapture(U.pointerId),y.value=X,h.value=X)}function C(U){if(y.value===null||!g(U))return;U.preventDefault();const X=v(U.clientX,U.clientY);X!==null&&(h.value=X)}function S(U){if(y.value===null||!g(U))return;U.preventDefault();const X=v(U.clientX,U.clientY);B(X??y.value);try{U.currentTarget.releasePointerCapture(U.pointerId)}catch{}}function H(U){if(g(U)){y.value=null,h.value=null;try{U.currentTarget.releasePointerCapture(U.pointerId)}catch{}}}const K=U=>{y.value=U},L=U=>{h.value=U},B=U=>{if(y.value===null||y.value===U){y.value=null,h.value=null;return}const X=[...s.value],[le]=X.splice(y.value,1);X.splice(U,0,le),s.value=X,y.value=null,h.value=null},_=()=>{k.value&&k.value.click()},$=U=>{const X=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tif"],le=U.toLowerCase();return X.some(ue=>le.endsWith(ue))},R=U=>{const le=U.target.files?.[0];if(!le)return;const ue=new FileReader;ue.onload=P=>{try{const oe=P.target?.result;if(typeof oe=="string"){const Ve=JSON.parse(oe);Array.isArray(Ve)&&s.value.push(...Ve)}}catch(oe){console.error("Error parsing file:",oe)}},ue.readAsText(le)},V=()=>{const U=JSON.stringify(s.value,null,2),X=new Blob([U],{type:"application/json"}),le=URL.createObjectURL(X),ue=document.createElement("a");ue.href=le,ue.download="data.json",ue.click(),URL.revokeObjectURL(le)},T=new Set(["autocomplete","select","radio","checkbox","combobox"]),M=new Map,O=(U,X)=>{const le=`/api/suggest/${U}`,ue=le.includes("?")?"&":"?",P=X?`&val=${X}`:"";return`${le}${ue}json=1${P}`},Q=U=>U==null||U===""?null:typeof U=="object"?U?.id!==void 0&&U.id!==null&&U.id!==""?U.id:null:U,J=U=>{const X=new Set;return Array.isArray(s.value)&&s.value.forEach(le=>{const ue=le?.[U];if(ue==null||ue==="")return;if(Array.isArray(ue)){ue.forEach(oe=>{const Ve=Q(oe);Ve!==null&&X.add(Ve)});return}const P=Q(ue);P!==null&&X.add(P)}),X},de=async()=>{if(!t.colModel?.length)return;const U=t.colModel.filter(X=>X.data&&T.has(X.type?.toLowerCase()||""));U.length&&await Promise.all(U.map(async X=>{const le=X.key||X.name;if(!le)return;const ue=J(le),P=Array.from(ue).map(Ne=>String(Ne)).sort(),oe=P.join(",");if(!P.length||M.get(le)===oe)return;M.set(le,oe);const Ve=P.map(encodeURIComponent).join(",");try{const z=await(await fetch(O(X.data,Ve))).json();c.value[le]=z?.data??z}catch(Ne){console.error("Failed to fetch column values",Ne)}}))};e.watch([()=>t.colModel,()=>s.value],()=>{de()},{immediate:!0,deep:!0});const te=e.ref(""),F=e.ref(!1);let Y="edit",ne=0;const W=U=>(U?.format||U?.type||"").toString().toLowerCase(),ce=e.computed(()=>(t.colModel?.filter(X=>W(X)!=="slot")??[]).map(X=>{const le=X.key||X.name;return le?{...X,name:le,key:le}:X})),he=e.ref({}),re=e.ref({}),pe=U=>typeof U!="string"?!1:!!o[U],Ce=(U,X)=>X?X.split(".").reduce((le,ue)=>le==null?le:le[ue.trim()],U):U,ke=(U,X)=>typeof U!="string"?"":U.replace(/{{\s*([^}]+)\s*}}/g,(le,ue)=>{const P=Ce(X,ue.trim());return P??""}),Se=U=>{if(U==null||U==="")return"";if(typeof U=="number")return U;if(typeof U=="boolean")return U?1:0;if(typeof U=="string")return U.toLowerCase();if(Array.isArray(U))return U.map(X=>Se(X)).join(", ");if(typeof U=="object"){if(U.text!==void 0)return String(U.text).toLowerCase();if(U.label!==void 0)return String(U.label).toLowerCase();if(U.id!==void 0)return String(U.id).toLowerCase()}return String(U).toLowerCase()},De=U=>{const X=U.key||U.name;if(X){if(d.value===X){u.value=u.value==="asc"?"desc":"asc";return}d.value=X,u.value="asc"}};async function Me(){te.value="Додати",F.value=!0,Y="add",he.value={}}function Te(U,X){if(!U?.length)return null;const le=typeof X=="object"?X?.id:X;return le==null||le===""?null:U.find(ue=>ue?.id?.toString()===le.toString())?.text??null}function Z(U){return U==null||U===""?"-":Array.isArray(U)?U.map(X=>typeof X=="object"?X?.text??X?.id??"-":X).join(", "):typeof U=="object"?U?.text??U?.id??"-":U}function ae(U,X){const le=X.key||X.name,ue=U?.[le],P=c.value[le];if(!ue)return"-";if(Array.isArray(ue)){const Ve=ue.map(Ne=>Te(P,Ne)).filter(Boolean);return Ve.length?Ve.join(", "):Z(ue)}const oe=Te(P,ue);return oe||Z(ue)}async function xe(U,X){te.value="Редагувати",F.value=!0,Y="edit",ne=X,he.value={...U}}function ve(){const U=re.value.validate();if(U){ye.notify({type:"warning",title:"Помилка валідації",message:Object.entries(U).map(([X,le])=>`${X}: ${le}`).join(`
|
|
2
2
|
`)});return}Y==="add"?Array.isArray(s.value)?s.value=[...s.value,he.value]:s.value=[he.value]:s.value=s.value.map((X,le)=>le===ne?he.value:X),F.value=!1}function Fe(U){s.value=s.value.filter((X,le)=>le!==U)}function je(){F.value=!1}return(U,X)=>(e.openBlock(),e.createElementBlock("div",Oc,[a.value?(e.openBlock(),e.createElementBlock("div",Rc,[r("search")?(e.openBlock(),e.createElementBlock("div",Pc,[e.createVNode(e.unref(q.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":X[0]||(X[0]=le=>i.value=le),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,i.value]])])):e.createCommentVNode("",!0),e.createElementVNode("div",zc,[r("import")?(e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"fileInput",ref:k,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:_,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(q.Upload),{class:"h-4 w-4 text-gray-700"}),X[4]||(X[4]=e.createTextVNode(" Імпорт ",-1))])):e.createCommentVNode("",!0),r("export")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:V,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(q.Download),{class:"h-4 w-4 text-gray-700"}),X[5]||(X[5]=e.createTextVNode(" Експорт ",-1))])):e.createCommentVNode("",!0),r("add")?(e.openBlock(),e.createElementBlock("button",{key:3,onClick:Me,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(q.Plus),{class:"h-4 w-4 text-white"}),X[6]||(X[6]=e.createTextVNode(" Додати ",-1))])):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",jc,[e.createElementVNode("table",Uc,[e.createElementVNode("thead",Hc,[e.createElementVNode("tr",qc,[e.createElementVNode("th",Kc,[e.createVNode(e.unref(q.GripVertical),{class:"mx-auto h-4 w-4 text-gray-400"})]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,le=>(e.openBlock(),e.createElementBlock("th",{key:le.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[e.createElementVNode("button",{type:"button",onClick:ue=>De(le),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(le.ua||le.label),1),d.value===(le.key||le.name)?(e.openBlock(),e.createElementBlock("span",Gc,e.toDisplayString(u.value==="asc"?"▲":"▼"),1)):e.createCommentVNode("",!0)],8,Wc)]))),128)),X[7]||(X[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":!h.value}])},[p.value.length===0?(e.openBlock(),e.createElementBlock("td",Yc,[e.createElementVNode("div",Xc,[e.createElementVNode("div",Zc,[e.createVNode(Ic,{class:"w-48 mx-auto"}),X[8]||(X[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,(le,ue)=>(e.openBlock(),e.createElementBlock("tr",{key:le.id,"data-row-index":ue,class:e.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":y.value===ue,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":h.value===ue}]),draggable:"true",onDragstart:P=>K(ue),onDragover:e.withModifiers(P=>L(ue),["prevent"]),onDrop:P=>B(ue)},[e.createElementVNode("td",{class:"px-4 py-3 text-center align-middle touch-none select-none",onPointerdown:P=>x(P,ue),onPointermove:C,onPointerup:S,onPointercancel:H},[e.createElementVNode("div",ed,[e.createVNode(e.unref(q.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])],40,Qc),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,P=>(e.openBlock(),e.createElementBlock("td",{key:P.key,class:"px-4 py-3 align-middle"},[W(P)==="slot"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[pe(P.slot)?e.renderSlot(U.$slots,P.slot,{key:0,row:le,value:le[P.key],column:P}):(e.openBlock(),e.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:ke(P.slot,le)},null,8,td))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[W(P)==="file"?(e.openBlock(),e.createElementBlock("div",nd,[$(ae(le,P))?(e.openBlock(),e.createElementBlock("div",od,[e.createElementVNode("img",{src:ae(le,P),alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,rd)])):(e.openBlock(),e.createElementBlock("div",ld,[e.createVNode(e.unref(q.FileText),{class:"h-4 w-4 min-w-4"})]))])):W(P)==="color"?(e.openBlock(),e.createElementBlock("div",ad,[e.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:e.normalizeStyle({backgroundColor:ae(le,P)||"#ffffff"})},null,4)])):(e.openBlock(),e.createElementBlock("div",sd,e.toDisplayString(ae(le,P)),1))],64))]))),128)),e.createElementVNode("td",id,[e.createElementVNode("div",cd,[e.createElementVNode("button",{onClick:P=>xe(le,ue),class:"p-1.5 text-gray-600 hover:text-blue-600 hover:bg-blue-50 rounded transition-colors"},[e.createVNode(e.unref(q.Pencil),{class:"h-4 w-4"})],8,dd),e.createElementVNode("button",{onClick:P=>Fe(ue),class:"p-1.5 text-gray-600 hover:text-red-600 hover:bg-red-50 rounded transition-colors"},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,ud)])])],42,Jc))),128))],2)])]),e.createVNode(e.unref(ye.VsModal),{visible:F.value,title:te.value,size:"lg",onClose:je,teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(rt,{schema:ce.value,"form-id":"datatable-row",values:he.value,"onUpdate:values":X[1]||(X[1]=le=>he.value=le),form:re.value,"onUpdate:form":X[2]||(X[2]=le=>re.value=le)},null,8,["schema","values","form"]),e.createElementVNode("div",pd,[e.createElementVNode("button",{type:"button",onClick:X[3]||(X[3]=le=>F.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:ve,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"])]))}}),md={},fd={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 hd(n,t){return e.openBlock(),e.createElementBlock("svg",fd,[...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 gd=Be(md,[["render",hd]]),yd={},bd={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 kd(n,t){return e.openBlock(),e.createElementBlock("svg",bd,[...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 xd=Be(yd,[["render",kd]]),wd={},Cd={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 vd(n,t){return e.openBlock(),e.createElementBlock("svg",Cd,[...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 Ed=Be(wd,[["render",vd]]),Bd={class:"bg-white/30 p-1 rounded-md shadow w-fit"},_d={class:"flex gap-2"},Vd=["onClick","title"],Sd=["src"],$d=e.defineComponent({__name:"map-layers",props:{basemaps:{}},emits:["onLayerChange"],setup(n,{emit:t}){const o=n,r=e.ref(Object.keys(o.basemaps)[0]),l=t;function a(i){l("onLayerChange",i),r.value=i}const s={z:13,x:4790,y:2762};function c(i){if(i?.preview)return i.preview;if(!i?.url)return;const d={"{z}":s.z,"{x}":s.x,"{y}":s.y};let u=i.url;return Object.entries(d).forEach(([p,f])=>{u=u.replace(new RegExp(p,"gi"),String(f))}),u}return(i,d)=>(e.openBlock(),e.createElementBlock("div",Bd,[e.createElementVNode("div",_d,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.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:f=>a(p),title:u.name||p,role:"button",tabindex:"0"},[e.createElementVNode("img",{src:c(u),alt:"",class:"w-10 h-10 object-cover"},null,8,Sd)],10,Vd))),128))])]))}}),It=1e-10,Vn=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,Nd=/^[+-]?\d+(?:\.\d+)?$/;function Ad(n,t,o){const r=n.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,f=t==="decimal"?Md(d,p,o):er(d,p,o);if(!f.ok){l.push(...f.errors);return}const y=a[a.length-1];if(y&&nr(y,f.point)){l.push({line:p,message:"Послідовні точки не повинні дублюватися."});return}a.push(f.point)}),l.length)return{ok:!1,errors:l};if(new Set(a.map(Dd)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const c=[...a];let i=!1;return nr(c[0],c[c.length-1])||(c.push(c[0]),i=!0),Td(c)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:c,wasClosedAutomatically:i}}function Md(n,t,o){return Qo(n,"decimal",o,t)}function Qo(n,t,o,r=1){return t==="decimal"?Fd(n,r,o):er(n,r,o)}function Fd(n,t,o){const r=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(n))return{ok:!1,errors:[{line:t,message:"У десятковому форматі не допускаються літери."}]};const l=n.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=>Nd.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 c=o==="lat-lon"?a:s,i=o==="lat-lon"?s:a;return(c<-90||c>90)&&r.push({line:t,message:"Широта поза діапазоном (-90..90)."}),(i<-180||i>180)&&r.push({line:t,message:"Довгота поза діапазоном (-180..180)."}),r.length?{ok:!1,errors:r}:{ok:!0,point:[i,c]}}function er(n,t,o){Vn.lastIndex=0;const r=[...n.matchAll(Vn)];if(r.length<2)return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати DMS-координати."}]};if(r.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(Vn.lastIndex=0,n.replace(Vn," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:t,message:"У рядку виявлено зайві символи або значення."}]};const a=tr(r[0],t,o==="lat-lon"?"lat":"lon"),s=tr(r[1],t,o==="lat-lon"?"lon":"lat"),c=[];if(a.ok||c.push(a.error),s.ok||c.push(s.error),c.length)return{ok:!1,errors:c};const i=o==="lat-lon"?a.value:s.value;return{ok:!0,point:[o==="lat-lon"?s.value:a.value,i]}}function tr(n,t,o){const r=Number(n[1]),l=Number(n[2]),a=Number(n[3]),s=String(n[4]).toUpperCase();if(!Number.isFinite(r)||!Number.isFinite(l)||!Number.isFinite(a))return{ok:!1,error:{line:t,message:"Невірні значення DMS-координат."}};if(o==="lat"&&!(s==="N"||s==="S")||o==="lon"&&!(s==="E"||s==="W"))return{ok:!1,error:{line:t,message:o==="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=o==="lat"?90:180;if(d>u)return{ok:!1,error:{line:t,message:o==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===u&&(l!==0||a!==0))return{ok:!1,error:{line:t,message:o==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const p=d+l/60+a/3600;return{ok:!0,value:s==="S"||s==="W"?-p:p}}function Dd(n){return`${n[0].toFixed(12)}:${n[1].toFixed(12)}`}function nr(n,t){return Math.abs(n[0]-t[0])<It&&Math.abs(n[1]-t[1])<It}function Td(n){if(n.length<4)return!1;for(let t=0;t<n.length-1;t+=1){const o=n[t],r=n[t+1];for(let l=t+1;l<n.length-1;l+=1){if(Math.abs(t-l)<=1||t===0&&l===n.length-2)continue;const a=n[l],s=n[l+1];if(Ld(o,r,a,s))return!0}}return!1}function Ld(n,t,o,r){const l=Sn(n,t,o),a=Sn(n,t,r),s=Sn(o,r,n),c=Sn(o,r,t);return!!(l!==a&&s!==c||l===0&&$n(n,o,t)||a===0&&$n(n,r,t)||s===0&&$n(o,n,r)||c===0&&$n(o,t,r))}function Sn(n,t,o){const r=(t[1]-n[1])*(o[0]-t[0])-(t[0]-n[0])*(o[1]-t[1]);return Math.abs(r)<It?0:r>0?1:2}function $n(n,t,o){return t[0]<=Math.max(n[0],o[0])+It&&t[0]+It>=Math.min(n[0],o[0])&&t[1]<=Math.max(n[1],o[1])+It&&t[1]+It>=Math.min(n[1],o[1])}const Id=["title"],Od={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"},Rd=["onClick"],Pd=["placeholder"],zd={class:"absolute inset-y-0 right-2 flex items-center gap-1"},jd={class:"flex items-center justify-between gap-2 px-3 py-2 border-b border-gray-100"},Ud={class:"text-xs font-semibold uppercase tracking-wide text-gray-500"},Hd={class:"max-h-[260px] overflow-auto"},qd={key:0,class:"divide-y divide-gray-100"},Kd=["onClick"],Wd={key:1,class:"px-3 py-3 text-xs text-gray-500"},or="formMapSearchAddressHistory",Gd=12,Yd="https://geo.rv.ua/api-user/dzk.api",Xd="https://nominatim.openstreetmap.org/search",Zd=Be(e.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(n,{emit:t}){const o={mounted(z,w){if(typeof document>"u")return;let N=null;const I=8,se=()=>{const Le=String(w?.value??"");if(!Le)return;N=document.createElement("div"),N.textContent=Le,Object.assign(N.style,{position:"absolute",background:"#333",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"9999"}),document.body.appendChild(N);const Ae=z.getBoundingClientRect();N.style.left=`${Ae.right+window.scrollX+I}px`,N.style.top=`${Ae.top+window.scrollY+(Ae.height-N.offsetHeight)/2}px`},be=()=>{N?.parentNode&&N.parentNode.removeChild(N),N=null};z.addEventListener("mouseenter",se),z.addEventListener("mouseleave",be),Object.assign(z,{tooltipRightHandlers:{show:se,hide:be}})},unmounted(z){if(typeof document>"u")return;const w=z.tooltipRightHandlers;w&&(z.removeEventListener("mouseenter",w.show),z.removeEventListener("mouseleave",w.hide))}},r=n,l=t,a=e.getCurrentInstance();function s(){return typeof globalThis<"u"&&globalThis.proxy?globalThis.proxy:typeof window<"u"&&window.proxy?window.proxy:null}function c(){const w=a?.appContext.config.globalProperties?.$settings?.map?.searchViewbox;if(w)return Array.isArray(w)?w.join(","):String(w);const I=s()?.map?.searchViewbox;if(I)return Array.isArray(I)?I.join(","):String(I)}function i(){const w=a?.appContext.config.globalProperties?.$settings?.map?.addressSuggest;if(typeof w=="string"&&w.trim())return w.trim();const I=s()?.map?.addressSuggest;if(typeof I=="string"&&I.trim())return I.trim()}function d(){if(typeof r.config?.cadastreSuggest=="string"&&r.config.cadastreSuggest.trim())return r.config.cadastreSuggest.trim();const z=a?.appContext.config.globalProperties?.$settings,w=z?.map?.cadastreSuggest??z?.map?.parcelSuggest??z?.map?.parcelSearch;if(typeof w=="string"&&w.trim())return w.trim();const N=s(),I=N?.map?.cadastreSuggest??N?.map?.parcelSuggest??N?.map?.parcelSearch;if(typeof I=="string"&&I.trim())return I.trim()}const u=!!i(),p=!!c(),f=e.computed(()=>{const z=["nominatim","xy","parcel"];return u&&z.unshift("address"),p?z:z.filter(w=>w!=="nominatim")}),y=e.computed(()=>{const z=f.value,w=r.config?.tools?.filter(N=>z.includes(N));return w&&w.length?w:z}),h=e.computed(()=>r.config?.placeholder?.trim()||"Пошук…"),k=e.ref(y.value[0]);e.watch(y,z=>{z.includes(k.value)||(k.value=z[0])});const g=e.ref(""),v=e.ref(!1),x=e.ref(null),C=e.ref(null),S=e.ref(null),H=e.ref(null),K=e.ref([]),L=e.ref(null),B=e.ref(!1),_=e.ref([]),$=e.computed(()=>(k.value==="address"||k.value==="nominatim")&&B.value),R=e.computed(()=>r.config?.addressDebounceMs??1e3);let V=null;const T=e.ref(!1),M=e.computed(()=>g.value.trim().length>0?K.value:_.value),O=e.computed(()=>g.value.trim().length?`Знайдено ${K.value.length}`:"Історія пошуку"),Q=e.computed(()=>g.value.trim().length?"Нічого не знайдено":"Історія порожня");function J(){if(typeof window>"u")return[];try{const z=window.localStorage?.getItem?.(or);if(!z)return[];const w=JSON.parse(z);return Array.isArray(w)?w:[]}catch{return[]}}function de(z){typeof window>"u"||window.localStorage?.setItem?.(or,JSON.stringify(z))}function te(z){const N=[z,..._.value.filter(I=>I.id!==z.id)].slice(0,10);_.value=N,de(N)}const F=e.reactive({position:"absolute",left:"0px",top:"0px",width:"100%",display:"none"});function Y(){if(!H.value)return;const z=H.value.getBoundingClientRect(),w=S.value?.getBoundingClientRect(),N=w?.width??z.width,I=(w?.left??z.left)+window.scrollX,se=z.bottom+window.scrollY+Gd;F.left=`${I}px`,F.top=`${se}px`,F.width=`${N}px`,F.display="block"}const ne=()=>{$.value&&Y()};function W(){V&&(clearTimeout(V),V=null)}e.watch(k,()=>{g.value="",v.value=!1,K.value=[],B.value=!1,W(),T.value=!1}),e.watch($,z=>{z?e.nextTick(()=>{Y()}):F.display="none"}),e.watch(g,z=>{if(k.value!=="address"&&k.value!=="nominatim"){K.value=[],W();return}if(!z.trim()){K.value=[],B.value=_.value.length>0,W();return}W(),B.value=!0,V=window.setTimeout(()=>{le(z).catch(w=>{const N=w?.message||"Помилка пошуку адреси";ye.notify({type:"error",title:"Пошук адреси",message:N})})},R.value)});function ce(z){const w=[];C.value&&w.push(C.value),z instanceof HTMLElement&&w.push(z),x.value?.querySelectorAll("li")?.forEach(I=>{w.push(I)}),w.forEach(I=>{I.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))})}function he(z){v.value&&ce(z.target),v.value=!v.value}function re(z,w){ce(w?.target),k.value=z}function pe(){g.value="",K.value=[],B.value=!1,T.value=!1}function Ce(z){const w=z.target;if(v.value){const N=x.value;N&&!N.contains(w)&&(ce(w),v.value=!1)}if($.value){const N=L.value,I=H.value;N&&!N.contains(w)&&(!I||!I.contains(w))&&(B.value=!1)}}e.onMounted(()=>{_.value=J(),window.addEventListener("click",Ce,!0),window.addEventListener("scroll",ne,!0),window.addEventListener("resize",ne)}),e.onBeforeUnmount(()=>{window.removeEventListener("click",Ce,!0),window.removeEventListener("scroll",ne,!0),window.removeEventListener("resize",ne),W()});function ke(z){return z==="xy"?"Координати":z==="parcel"?"Кадастр":z==="nominatim"?"Адреса":"Адресний"}function Se(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 De(z){const w=Qo(z.trim(),"dms","lat-lon");if(w.ok){const[Ie,lt]=w.point;return{lat:lt,lng:Ie}}const N=z.replace(/[,]+/g," ").trim();if(!N)return null;const I=N.split(/\s+/).filter(Boolean);if(I.length<2)return null;const se=I.slice(0,2).map(Number);if(!se.every(Ie=>Number.isFinite(Ie)))return null;let[be,Le]=se,Ae=be,Ke=Le;const dt=Ie=>Math.abs(Ie)<=90,ut=Ie=>Math.abs(Ie)<=180;if(!dt(Ae)||!ut(Ke))if(dt(Ke)&&ut(Ae))Ae=Le,Ke=be;else return null;return{lat:Ae,lng:Ke}}function Me(z){const w=z?.result||z?.data||z;return(Array.isArray(w)?w:w?[w]:[]).map((I,se)=>{const be=I?.geom_centroid,Le=Array.isArray(be?.coordinates)?be.coordinates:null;if(!Le||Le.length<2)return null;const Ae=Number(Le[0]),Ke=Number(Le[1]);return!Number.isFinite(Ke)||!Number.isFinite(Ae)?null:{id:String(I?.parcel_id??I?.cad_num??se),title:I?.cadnum||I?.cad_num||"Земельна ділянка",lat:Ke,lng:Ae}}).filter(I=>!!I)}function Te(z){return(Array.isArray(z?.features)?z.features:[]).map((N,I)=>{const se=N?.geometry?.coordinates,be=Number(se?.[0]),Le=Number(se?.[1]);if(!Number.isFinite(Le)||!Number.isFinite(be))return null;const Ae=N?.properties||{},Ke=Ae?.geocoding?.label||Ae?.display_name||Ae?.label||"Адреса";return{id:String(Ae?.geocoding?.place_id||Ae?.place_id||I),title:Ke,lat:Le,lng:be}}).filter(N=>!!N)}function Z(z){return Number.isFinite(z.lat)&&Number.isFinite(z.lng)}function ae(z){if(z==null||typeof z=="string"&&!z.trim())return null;const w=Number(z);return Number.isFinite(w)?w:null}function xe(z){const w=ae(z.lng)??ae(z.lon)??ae(z.longitude)??ae(z.x),N=ae(z.lat)??ae(z.latitude)??ae(z.y);if(w!=null&&N!=null)return{lat:N,lng:w};const I=z?.geometry?.coordinates??z?.geom_centroid?.coordinates??z?.centroid?.coordinates??z?.geojson?.geometry?.coordinates??z?.geom?.coordinates;if(Array.isArray(I)&&I.length>=2){const se=ae(I[0]),be=ae(I[1]);if(se!=null&&be!=null)return{lat:be,lng:se}}return null}function ve(z){return(Array.isArray(z?.data)?z.data:[]).map((N,I)=>{const se=xe(N),be=String(N.text??N.title??N.label??N.name??N.address??N.display_name??N.id??"Адреса"),Le=String(N.id??N.code??N.value??I);return se?{id:Le,title:be,...se}:{id:Le,title:be}}).filter(N=>!!N?.title)}function Fe(z){const w=d()||Yd;if(w.includes(":id"))return w.replace(":id",encodeURIComponent(z));if(w.includes(":name"))return w.replace(":name",encodeURIComponent(z));try{const N=new URL(w,window.location.origin),I=r.config?.parcelQueryParam?.trim()||"cad_num";return N.searchParams.set(I,z),N.toString()}catch{return w}}function je(z){const w=i();if(!w)return null;if(w.includes(":name"))return w.replace(":name",encodeURIComponent(z));try{const N=new URL(w,window.location.origin);return z.trim()&&N.searchParams.set("q",z),N.toString()}catch{return w}}async function U(z){const w=je(z);if(!w)return[];const N=await fetch(w);if(!N.ok)throw new Error(`HTTP ${N.status}`);const I=await N.json();return ve(I)}async function X(z){const w=new URL(Xd);w.searchParams.set("format","geojson"),w.searchParams.set("q",z),w.searchParams.set("addressdetails","1"),w.searchParams.set("bounded","1");const N=c();N&&w.searchParams.set("viewbox",N);const I=await fetch(w.toString());if(!I.ok)throw new Error(`HTTP ${I.status}`);const se=await I.json();return Te(se)}async function le(z){if(K.value=[],W(),k.value==="address"){if(!i()){ye.notify({type:"warning",title:"Пошук адреси",message:"Не налаштовано addressSuggest"});return}const I=await U(z);if(!I.length){ye.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}K.value=I;return}const w=await X(z);if(!w.length){ye.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}K.value=w}async function ue(z){if(Z(z)){Ve(z),te(z);return}ye.notify({type:"warning",title:"Пошук адреси",message:"Геометрія для обраної адреси відсутня"})}function P(){k.value!=="address"&&k.value!=="nominatim"||(B.value=!0,e.nextTick(()=>{Y()}))}function oe(z){const N=z.replace(/\s+/g,"").split(":");if(N.length!==4)return!1;const I=[10,2,3,4];return N.every((se,be)=>se.length===I[be]&&/^\d+$/.test(se))}function Ve(z){l("goToCoordinates",[z.lat,z.lng]),T.value=!0}async function Ne(){const z=g.value.trim();if(z){if(k.value==="xy"){const w=De(z);if(!w){ye.notify({type:"warning",title:"Пошук координат",message:"Використайте `lat lon` або DMS у форматі `50°27'00\"N 30°31'24\"E`."});return}Ve(w);return}if(k.value==="address"||k.value==="nominatim"){try{await le(z)}catch(w){const N=w?.message||"Помилка пошуку адреси";ye.notify({type:"error",title:"Пошук адреси",message:N})}return}try{if(!oe(z)){ye.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}const w=await fetch(Fe(z));if(!w.ok)throw new Error(`HTTP ${w.status}`);const N=await w.json(),I=Me(N);if(!I.length)ye.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const se=I.find(Z);if(!se){ye.notify({type:"warning",title:"Пошук",message:"Геометрія ділянки відсутня"});return}Ve(se)}}catch(w){const N=w?.message||"Помилка пошуку";ye.notify({type:"error",title:"Пошук",message:N})}}}return(z,w)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:S,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(Ne,["prevent"])},[y.value.length>1?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:x,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:he},[e.withDirectives((e.openBlock(),e.createElementBlock("span",{ref_key:"selectedToolLabelRef",ref:C,class:"block w-full truncate",title:ke(k.value)},[e.createTextVNode(e.toDisplayString(ke(k.value)),1)],8,Id)),[[o,Se(k.value)]]),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-4 h-4 text-gray-500 transition-transform",{"rotate-180":v.value}]),viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},[...w[3]||(w[3]=[e.createElementVNode("path",{d:"M6 9l6 6 6-6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2))]),v.value?(e.openBlock(),e.createElementBlock("div",Od,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,N=>e.withDirectives((e.openBlock(),e.createElementBlock("li",{key:N,class:"px-3 py-2 cursor-pointer hover:bg-gray-100 text-gray-900",onClick:I=>re(N,I)},[e.createTextVNode(e.toDisplayString(ke(N)),1)],8,Rd)),[[o,Se(N)]])),128))])])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"searchWrapperRef",ref:H,class:"relative flex-1 min-w-[140px]"},[k.value==="parcel"?(e.openBlock(),e.createBlock(hn,{key:0,modelValue:g.value,"onUpdate:modelValue":w[0]||(w[0]=N=>g.value=N),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",T.value?"!pr-14":"!pr-8"])},null,8,["modelValue","class"])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":w[1]||(w[1]=N=>g.value=N),placeholder:h.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",T.value?"!pr-14":"!pr-8"]),onFocus:P},null,42,Pd)),[[e.vModelText,g.value,void 0,{trim:!0}]]),e.createElementVNode("div",zd,[T.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Очистити",onClick:pe},[...w[4]||(w[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),w[5]||(w[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))]),$.value?(e.openBlock(),e.createBlock(e.Teleport,{key:2,to:"body"},[e.createElementVNode("div",{ref_key:"addressResultsRef",ref:L,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(F)},[e.createElementVNode("div",jd,[e.createElementVNode("span",Ud,e.toDisplayString(O.value),1),e.createElementVNode("button",{type:"button",class:"text-gray-400 hover:text-gray-600","aria-label":"Закрити",onClick:w[2]||(w[2]=N=>B.value=!1)}," ✕ ")]),e.createElementVNode("div",Hd,[M.value.length?(e.openBlock(),e.createElementBlock("ul",qd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,N=>(e.openBlock(),e.createElementBlock("li",{key:N.id,class:"px-3 py-2 cursor-pointer hover:bg-gray-50",onClick:I=>ue(N)},e.toDisplayString(N.title),9,Kd))),128))])):(e.openBlock(),e.createElementBlock("div",Wd,e.toDisplayString(Q.value),1))])],4)])):e.createCommentVNode("",!0)],512)],32)],512))}}),[["__scopeId","data-v-8c9147ac"]]),Jd={class:"pt-1 border-t border-gray-100"},Qd={class:"space-y-1"},eu=e.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(n,{emit:t}){const o=t,r=e.ref(null),l=e.ref(null),a=(i,d,u)=>Math.min(Math.max(i,d),u),s=()=>{if(r.value===null||l.value===null||!Number.isFinite(r.value)||!Number.isFinite(l.value))return;const i=a(r.value,-90,90),d=a(l.value,-180,180);o("submit",{lat:i,lng:d}),r.value=null,l.value=null},c=()=>{r.value=null,l.value=null,o("cancel")};return(i,d)=>(e.openBlock(),e.createElementBlock("div",Jd,[d[2]||(d[2]=e.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),e.createElementVNode("div",Qd,[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:c}," Скасувати ")])])]))}}),tu=e.defineComponent({__name:"BtnAdd",emits:["click"],setup(n){return(t,o)=>(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:o[0]||(o[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Plus),{size:12,"stroke-width":2}),o[1]||(o[1]=e.createTextVNode(" Додати ",-1))]))}}),nu=e.defineComponent({__name:"BtnClear",emits:["click"],setup(n){return(t,o)=>(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:o[0]||(o[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Trash2),{size:12,"stroke-width":2}),o[1]||(o[1]=e.createTextVNode(" Очистити ",-1))]))}}),ou=e.defineComponent({__name:"BtnComplete",emits:["click"],setup(n){return(t,o)=>(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:o[0]||(o[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Circle),{size:12,"stroke-width":2}),o[1]||(o[1]=e.createTextVNode("Замкнути ",-1))]))}}),ru=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function Ot(n){return ru.format(n)}function rr(n){return n>=1e3?`${Ot(n/1e3)} км`:`${Ot(n)} м`}const lu={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},au={key:0,class:"flex-1 flex gap-1"},su={key:1,class:"flex-1 font-mono text-gray-700"},iu=e.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(n,{emit:t}){const o=n,r=t,l=e.computed(()=>`${o.coords.lat.toFixed(4)}°, ${o.coords.lng.toFixed(4)}°`),a=e.ref(!1),s=e.ref(o.coords.lat),c=e.ref(o.coords.lng);e.watch(()=>o.coords,f=>{s.value=f.lat,c.value=f.lng},{deep:!0,immediate:!0});const i=(f,y,h)=>Math.min(Math.max(f,y),h),d=()=>{a.value=!0},u=()=>{if(!Number.isFinite(s.value)||!Number.isFinite(c.value))return;const f=i(s.value,-90,90),y=i(c.value,-180,180);r("update",{id:o.id,coords:{lat:f,lng:y}}),a.value=!1},p=()=>{r("delete",o.id)};return(f,y)=>(e.openBlock(),e.createElementBlock("div",lu,[e.createVNode(e.unref(q.MapPin),{size:12,"stroke-width":2,class:"text-gray-400 flex-shrink-0"}),a.value?(e.openBlock(),e.createElementBlock("div",au,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":y[0]||(y[0]=h=>s.value=h),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":y[1]||(y[1]=h=>c.value=h),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,c.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",su,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}," ✕ ")]))}}),cu={class:"ruler-control px-3 py-2.5 space-y-2"},du={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},uu={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"},pu={class:"text-sm font-semibold text-slate-700"},mu={class:"ruler-row"},fu={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},hu={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"},gu={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},yu=["onClick"],bu={class:"flex items-center gap-2 mt-0.5 pl-7"},ku={key:0,class:"text-base font-semibold text-green-600"},xu={key:1,class:"text-xs text-gray-400"},wu={class:"ruler-row flex items-center gap-2 cursor-pointer"},Cu={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"},vu={class:"text-xs font-medium text-gray-600 flex-1"},Eu={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},Bu=e.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(n){const t=n,o=e.ref(!1),r=e.ref("km2"),l=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],a=()=>{o.value=!o.value},s=(h,k)=>{const g=_=>_*Math.PI/180,v=g(k.lat-h.lat),x=g(k.lng-h.lng),C=g(h.lat),S=g(k.lat),H=Math.sin(v/2),K=Math.sin(x/2);return 6371e3*(2*Math.asin(Math.sqrt(H*H+Math.cos(C)*Math.cos(S)*K*K)))},c=e.computed(()=>{if(t.points.length<2)return 0;let h=0;for(let k=1;k<t.points.length;k+=1)h+=s(t.points[k-1].coords,t.points[k].coords);return t.isShapeClosed&&t.points.length>=2&&(h+=s(t.points[t.points.length-1].coords,t.points[0].coords)),h}),i=e.computed(()=>c.value>=1e3?`${Ot(c.value/1e3)} км`:`${Ot(c.value)} м`);function d(h){if(h.length<3)return 0;const k=h[0].lat,g=h[0].lng,v=(C,S)=>{const H=(C-k)*110574;return{x:(S-g)*111320*Math.cos(k*Math.PI/180),y:H}};let x=0;for(let C=0;C<h.length;C++){const S=(C+1)%h.length,H=v(h[C].lat,h[C].lng),K=v(h[S].lat,h[S].lng);x+=H.x*K.y-H.y*K.x}return Math.abs(x)*.5}const u=e.computed(()=>{if(!t.isShapeClosed||t.points.length<3)return 0;const h=t.points.map(k=>k.coords);return d(h)}),p=e.computed(()=>u.value>0),f=e.computed(()=>{const h=u.value;if(h===0)return"—";if(r.value==="km2"){const g=h/1e6;return`${Ot(g)} км²`}if(r.value==="ha"){const g=h/1e4;return`${Ot(g)} га`}const k=h>=1?Math.round(h):h;return`${Ot(k)} м²`}),y=e.computed(()=>{const h=t.points.length;return h===1?"1 точка":h>=2&&h<=4?`${h} точки`:`${h} точок`});return e.watch(()=>t.points.length,()=>{t.points.length===0&&(o.value=!1)}),(h,k)=>(e.openBlock(),e.createElementBlock("div",cu,[e.createElementVNode("button",du,[e.createElementVNode("span",uu,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),k[1]||(k[1]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),e.createElementVNode("span",pu,e.toDisplayString(i.value),1)]),e.createElementVNode("div",mu,[e.createElementVNode("button",fu,[e.createElementVNode("span",hu,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),k[2]||(k[2]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),e.createElementVNode("div",gu,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,(g,v)=>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",v===0&&"rounded-l-md",v===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(x=>r.value=g.id,["stop"])},e.toDisplayString(g.label),11,yu)),64))])]),e.createElementVNode("div",bu,[p.value?(e.openBlock(),e.createElementBlock("span",ku,e.toDisplayString(f.value),1)):(e.openBlock(),e.createElementBlock("span",xu,"—"))])]),e.createElementVNode("div",wu,[e.createElementVNode("span",Cu,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),e.createElementVNode("span",vu,e.toDisplayString(y.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"])}," Координати ")]),o.value?(e.openBlock(),e.createElementBlock("div",Eu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.points,(g,v)=>(e.openBlock(),e.createBlock(iu,{key:g.id,id:g.id,index:v+1,coords:g.coords,onUpdate:k[0]||(k[0]=x=>h.$emit("update-point",x)),onDelete:x=>h.$emit("delete-point",g.id)},null,8,["id","index","coords","onDelete"]))),128))])):e.createCommentVNode("",!0)]))}}),_u={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},Vu={class:"flex items-start gap-2"},Su=e.defineComponent({__name:"InfoHint",setup(n){return(t,o)=>(e.openBlock(),e.createElementBlock("div",_u,[e.createElementVNode("div",Vu,[e.createVNode(e.unref(q.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),o[0]||(o[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))])]))}}),$u={class:"space-y-1.5"},Nu={class:"space-y-1 max-h-40 overflow-y-auto"},Au={class:"text-gray-700"},Mu={class:"font-semibold text-slate-800"},Fu=e.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(n){const t=n;function o(a,s){const c=y=>y*Math.PI/180,i=c(s.lat-a.lat),d=c(s.lng-a.lng),u=c(a.lat),p=c(s.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(i/2)**2+Math.cos(u)*Math.cos(p)*Math.sin(d/2)**2)))}function r(a){return rr(a)}const l=e.computed(()=>{const a=[],s=t.points;if(s.length<2)return a;for(let c=0;c<s.length;c++){const i=c===s.length-1&&t.isShapeClosed?0:c+1;if(i>=s.length)break;const d=o(s[c].coords,s[i].coords);a.push({from:c+1,to:i+1,label:r(d)})}return a});return(a,s)=>(e.openBlock(),e.createElementBlock("div",$u,[s[0]||(s[0]=e.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),e.createElementVNode("div",Nu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(c,i)=>(e.openBlock(),e.createElementBlock("div",{key:i,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[e.createElementVNode("span",Au,"Точка "+e.toDisplayString(c.from)+" → Точка "+e.toDisplayString(c.to),1),e.createElementVNode("span",Mu,e.toDisplayString(c.label),1)]))),128))])]))}}),Du={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},Tu={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},Lu={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},Iu={class:"flex items-center gap-2"},Ou={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},Ru={class:"flex border-b border-gray-200"},Pu={key:1,class:"px-3 py-2.5"},zu={key:1,class:"text-xs text-gray-500"},ju={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},Uu={class:"flex gap-1.5"},Hu=e.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(n,{expose:t,emit:o}){const r=o,l=e.ref([]),a=e.computed(()=>l.value.length>0),s=e.ref(!1),c=e.ref(!1),i=e.ref("general");function d($){i.value=$,r("tab-change",$)}e.onMounted(()=>{r("tab-change",i.value)});const u=e.computed(()=>l.value.length>=3&&!c.value);let p=1;const f=()=>l.value.map($=>({id:$.id,coords:{...$.coords}})),y=()=>{l.value.length<3&&c.value&&(c.value=!1,r("shape-closed-change",!1)),r("points-change",f())},h=()=>{const $=p;return p+=1,$},k=$=>{l.value=[...l.value,{id:h(),coords:{lat:$.lat,lng:$.lng}}],y()},g=({id:$,coords:R})=>{const V=l.value.findIndex(M=>M.id===$);if(V===-1)return;const T=[...l.value];T[V]={id:$,coords:{...R}},l.value=T,y()},v=$=>{l.value=l.value.filter(R=>R.id!==$),y()},x=()=>{l.value=[],c.value&&(c.value=!1,r("shape-closed-change",!1)),y()},C=$=>{g($)},S=$=>{v($)},H=()=>{s.value=!0,r("add-request")},K=$=>{k($),s.value=!1},L=()=>{s.value=!1},B=()=>{u.value&&(c.value=!0,r("complete"),r("shape-closed-change",!0))},_=()=>{x(),s.value=!1,r("close")};return t({addPoint:k,clearPoints:x}),($,R)=>(e.openBlock(),e.createElementBlock("div",Du,[e.createElementVNode("div",Tu,[e.createElementVNode("div",Lu,[e.createElementVNode("div",Iu,[e.createElementVNode("div",Ou,[e.createVNode(e.unref(q.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),R[2]||(R[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:_},[e.createVNode(e.unref(q.X),{size:14,"stroke-width":2,class:"text-white"})])]),e.createElementVNode("div",Ru,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:R[0]||(R[0]=V=>d("general"))}," Загальна ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",i.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:R[1]||(R[1]=V=>d("topoint"))}," До точки ",2)]),i.value==="general"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.value?(e.openBlock(),e.createBlock(Bu,{key:1,points:l.value,"is-shape-closed":c.value,onUpdatePoint:C,onDeletePoint:S},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createBlock(Su,{key:0}))],64)):(e.openBlock(),e.createElementBlock("div",Pu,[a.value?(e.openBlock(),e.createBlock(Fu,{key:0,points:l.value,"is-shape-closed":c.value},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createElementBlock("p",zu,"Додайте точки на карті, щоб бачити відстані між ними."))])),e.createElementVNode("div",ju,[e.createElementVNode("div",Uu,[s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(tu,{key:0,onClick:H})),u.value?(e.openBlock(),e.createBlock(ou,{key:1,onClick:B})):e.createCommentVNode("",!0)]),s.value?(e.openBlock(),e.createBlock(eu,{key:0,onSubmit:K,onCancel:L})):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(nu,{key:1,onClick:x})):e.createCommentVNode("",!0)])])]))}}),Xe="ruler-points",Ct="ruler-line",vt="ruler-polygon",Et="ruler-segments",qu=e.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(n){function t(h,k){const g=K=>K*Math.PI/180,v=g(k.lat-h.lat),x=g(k.lng-h.lng),C=g(h.lat),S=g(k.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(v/2)**2+Math.cos(C)*Math.cos(S)*Math.sin(x/2)**2)))}function o(h){return rr(h)}const r=n;function l(){return{type:"FeatureCollection",features:[]}}function a(h,k,g){const v=g??"general",x=[];let C=0;x.push(0);for(let S=1;S<h.length;S++)C+=t(h[S-1].coords,h[S].coords),x.push(C);return k&&h.length>=2&&(C+=t(h[h.length-1].coords,h[0].coords)),{type:"FeatureCollection",features:h.map((S,H)=>{const K=v==="general"?H===0?"0":o(x[H]):H===0?"0":o(t(h[H-1].coords,h[H].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[S.coords.lng,S.coords.lat]},properties:{id:S.id,index:H+1,label:K}}})}}function s(h,k){if(h.length<2)return l();const g=[];for(let v=0;v<h.length;v++){const x=v===h.length-1&&k?0:v+1;if(x>=h.length)break;const C=h[v].coords,S=h[x].coords,H=t(C,S);g.push({type:"Feature",geometry:{type:"LineString",coordinates:[[C.lng,C.lat],[S.lng,S.lat]]},properties:{distance:o(H)}})}return{type:"FeatureCollection",features:g}}function c(h,k){if(h.length<2)return l();const g=h.map(v=>[v.coords.lng,v.coords.lat]);return k&&g.push(g[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:g},properties:{}}]}}function i(h){if(h.length<3)return l();const k=h.map(g=>[g.coords.lng,g.coords.lat]);return k.push(k[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[k]},properties:{}}]}}let d=!1;function u(h){h.getSource(Xe)||(h.addSource(Xe,{type:"geojson",data:l()}),h.addLayer({id:`${Xe}-circle`,type:"circle",source:Xe,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),h.addLayer({id:`${Xe}-labels`,type:"symbol",source:Xe,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}})),h.getSource(Et)||(h.addSource(Et,{type:"geojson",data:l()}),h.addLayer({id:`${Et}-labels`,type:"symbol",source:Et,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}})),h.getSource(Ct)||(h.addSource(Ct,{type:"geojson",data:l()}),h.addLayer({id:`${Ct}-layer`,type:"line",source:Ct,paint:{"line-color":"#3b82f6","line-width":2}})),h.getSource(vt)||(h.addSource(vt,{type:"geojson",data:l()}),h.addLayer({id:`${vt}-layer`,type:"fill",source:vt,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function p(h){if(h){try{h.getLayer(`${vt}-layer`)&&h.removeLayer(`${vt}-layer`),h.getSource(vt)&&h.removeSource(vt),h.getLayer(`${Ct}-layer`)&&h.removeLayer(`${Ct}-layer`),h.getSource(Ct)&&h.removeSource(Ct),h.getLayer(`${Et}-labels`)&&h.removeLayer(`${Et}-labels`),h.getSource(Et)&&h.removeSource(Et),h.getLayer(`${Xe}-labels`)&&h.removeLayer(`${Xe}-labels`),h.getLayer(`${Xe}-circle`)&&h.removeLayer(`${Xe}-circle`),h.getSource(Xe)&&h.removeSource(Xe)}catch{}d=!1}}function f(h){if(!h)return;const k=h.getSource(Xe),g=h.getSource(Ct),v=h.getSource(vt),x=h.getSource(Et),C=r.points,S=r.labelMode??"general";k&&k.setData(a(C,r.isShapeClosed,S)),g&&g.setData(c(C,r.isShapeClosed)),v&&v.setData(i(C)),x&&x.setData(S==="topoint"?s(C,r.isShapeClosed):l())}function y(){const h=r.map;h&&(d||u(h),f(h))}return e.watch(()=>[r.points,r.isShapeClosed,r.labelMode],()=>y(),{deep:!0,immediate:!0}),e.watch(()=>r.map,()=>y(),{immediate:!0}),e.onBeforeUnmount(()=>{p(r.map)}),(h,k)=>null}});function Ku(n={}){const t=e.ref(!1),o=e.ref([]),r=e.ref(!1),l=e.ref("general"),a=e.ref(null);function s(){t.value?c():(t.value=!0,n.onActivate?.())}function c(){t.value=!1,o.value=[],r.value=!1,a.value?.clearPoints(),n.onDeactivate?.()}function i(y){o.value=y}function d(y){l.value=y}function u(y){r.value=y}function p(y){t.value&&a.value?.addPoint({lat:y.lat,lng:y.lng})}const f=e.computed(()=>o.value.length>0);return{isRulerActive:t,rulerPoints:o,rulerShapeClosed:r,rulerActiveTab:l,rulerPanelRef:a,hasRulerPoints:f,toggleRuler:s,closeRuler:c,onRulerPointsChange:i,onRulerTabChange:d,onRulerShapeClosedChange:u,handleRulerMapClick:p}}const Wu={key:0,class:"absolute top-4 left-4 z-[1000] w-[calc(100%-20px)] sm:w-[350px]"},Gu={key:1,class:"form-geom__panel flex gap-1 items-start mt-2"},Yu={class:"flex items-center gap-1"},Xu=["disabled"],Zu={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"},Ju=["disabled"],Qu=["disabled"],ep={class:"mt-4 flex justify-end gap-2"},tp=["disabled"],np={class:"absolute top-4 right-4 z-[1000]"},op={class:"flex flex-col gap-[2px]"},rp=["disabled"],lp=["disabled"],ap=["disabled"],sp=["disabled"],ip={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"},cp={class:"space-y-0.5"},dp={class:"text-gray-500"},up={class:"text-gray-900 text-right break-all"},pp={class:"absolute left-4 bottom-[36px] z-[1000]"},mp={class:"flex flex-col gap-2"},fp={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]"},hp={class:"flex flex-col gap-1"},gp=["checked","disabled","onChange"],yp={class:"text-gray-700 text-xs font-medium"},bp={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"},kp={key:0,class:"form-geom__feature flex items-center text-xs transition-all gap-2 w-full px-2 pb-1"},xp={class:"mr-auto flex items-center gap-2 min-w-0 relative"},wp={class:"shrink-0"},Cp={key:0,class:"font-bold"},vp=["onClick","disabled"],Ep={key:0},Bp={class:"flex items-center"},_p={class:"text-xs mr-2"},Vp={key:0},Sp={key:1},$p={key:0,class:"text-xs mr-2"},Np={key:1,class:"text-xs mr-2"},Ap=["disabled"],Mp=["disabled"],Nn="__vs_form_maplibre_loader__",An="vs-global-bounds-src",Mn="vs-global-bounds-line",lr=Be(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(n,{emit:t}){const o=n,r=t,l=e.useAttrs(),a=e.computed(()=>{const m=l?.multiple,b=l?.multi,E=A=>A===""||A===!0||A==="true"||A===1||A==="1";return!!o.multi||!!o.multiple||E(b)||E(m)}),s=e.computed(()=>!!o.disabled),c=e.ref(!1),i=e.ref(null),d=e.ref(0),u=e.ref(""),p=e.ref(null),f=e.ref([]),y=e.ref(null),h=e.ref(null),k=Ku({onActivate(){if(oe)try{oe.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""},onDeactivate(){}});function g(){k.toggleRuler()}const v=e.getCurrentInstance(),x=v?.appContext?.config?.globalProperties?.$settings??{},C=x?.map??{},S=v?.vnode?.props??{};function H(m){return Object.prototype.hasOwnProperty.call(S,m)||Object.prototype.hasOwnProperty.call(S,m.replace(/[A-Z]/g,b=>`-${b.toLowerCase()}`))}const K=Array.isArray(C.center)&&C.center.length===2?C.center:Array.isArray(x.center)&&x.center.length===2?x.center:[30,50],L=typeof C.zoom=="number"?C.zoom:typeof x.zoom=="number"?x.zoom:typeof x.defaultZoom=="number"?x.defaultZoom:10;function B(m){if(m!=null){if(Array.isArray(m)&&m.length>=2){const b=Number(m[0]),E=Number(m[1]);return!Number.isFinite(b)||!Number.isFinite(E)?void 0:[b,E]}if(typeof m=="object"){const b=m,E=b.geom;if(b.type==="Point"&&Array.isArray(b.coordinates)){const G=b.coordinates,ie=Number(G[0]),me=Number(G[1]);if(Number.isFinite(ie)&&Number.isFinite(me))return[ie,me]}if(E?.type==="Point"&&Array.isArray(E.coordinates)){const G=E.coordinates,ie=Number(G[0]),me=Number(G[1]);if(Number.isFinite(ie)&&Number.isFinite(me))return[ie,me]}const A=Number(b.lat),D=Number(b.lng??b.lon);if(Number.isFinite(A)&&Number.isFinite(D))return[D,A]}}}const _=e.computed(()=>{const m=B(o.center);if(m)return m;if(!H("center"))return B(C.center)??B(x.center)}),$=e.computed(()=>H("zoom")?o.zoom:C.zoom??o.zoom),R=e.computed(()=>H("katottg")?String(o.katottg??""):String(C.katottg??o.katottg??"")),V=e.computed(()=>H("layers")?o.layers??[]:C.layers??o.layers??[]),T=e.computed(()=>H("bounds")?o.bounds:C.bounds??o.bounds),M=e.ref(Array.isArray(_.value)&&_.value.length===2?[..._.value]:K),O=e.ref(typeof $.value=="number"?$.value:L),Q=e.ref(o.modelValue),J=e.ref(null),de=e.ref(null),te=e.ref([]),F=e.ref(!1),Y=e.ref(!1),ne=e.ref([]),W=e.ref({coordinates:"",format:"decimal",order:"lat-lon"}),ce={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 he=!1,re=!1;const pe=e.reactive({}),Ce=e.ref([]),ke=e.computed(()=>Ce.value.map(m=>pe[m]).filter(Boolean)),Se=e.ref(null),De=e.computed(()=>Se.value?.entries??[]),Me=e.computed(()=>{if(Se.value)return{left:`${Se.value.point.x+12}px`,top:`${Se.value.point.y+12}px`}}),Te=e.computed(()=>{if(Array.isArray(o.tools)&&o.tools.length)return o.tools;const m=l?.tools;return Array.isArray(m)?m.map(b=>String(b)):typeof m=="string"?m.split(",").map(b=>b.trim()).filter(Boolean):[]}),Z=e.computed(()=>{const m={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Te.value.length)return{...m,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const b=new Set(Te.value.map(E=>E.toLowerCase()));return{search:b.has("search"),import:b.has("import"),export:b.has("export"),point:b.has("point"),line:b.has("line"),polygon:b.has("polygon"),rectangle:b.has("rectangle"),ruler:b.has("ruler")}});function ae(m){if(typeof m!="string"||!m.trim())return"";if(/^https?:\/\//i.test(m))return m;const b=window?.location?.origin??"",E=m.replace(/^\/+/,"");return E?b?`${b}/${E}`:`/${E}`:b}function xe(){const m=Array.isArray(C.basemaps)&&C.basemaps.length?C.basemaps:x.basemaps;if(Array.isArray(m)&&m.length){const E=m.map((A,D)=>{const G=String(A?.key??A?.id??A?.name??`b${D}`),ie=ae(String(A?.url??""));if(!ie)return null;const me=typeof A?.preview=="string"&&A.preview?ae(A.preview):"";return[G,{...A,url:ie,preview:me}]}).filter(A=>Array.isArray(A)&&A.length===2).reduce((A,[D,G])=>(A[D]=G,A),{});if(Object.keys(E).length)return E}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 ve=xe(),Fe=Object.keys(ve),je=e.ref(Fe.length?Fe[0]:"");async function U(){if(typeof window>"u")return null;const m=window;if(m[Nn])return m[Nn];const b=G=>{if(Array.from(document.styleSheets).some(Pe=>Pe?.href?.includes(G)))return;const me=document.createElement("link");me.rel="stylesheet",me.href=G,document.head.appendChild(me)},E=async()=>{const G=new Function("u","return import(u)"),ie=await G("https://esm.sh/maplibre-gl@3.6.2"),me=ie?.default??ie;if(!me)throw new Error("maplibre esm fallback failed");window.maplibregl=me,window.mapboxgl=me;const Pe=await G("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),nt=Pe?.default??Pe;if(!nt)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=nt},D=(async()=>{b("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),b("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await E();const G=window.maplibregl,ie=window.MapboxDraw;if(!G)throw new Error("maplibregl not available after load");if(!ie)throw new Error("MapboxDraw not available after load");return{maplibregl:G,MapboxDraw:ie}})().catch(G=>{throw delete m[Nn],G});return m[Nn]=D,D}function X(m){return{version:8,sources:{rasterSource:{type:"raster",tiles:[m],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let le=null,ue=null,P=null,oe=null,Ve=[],Ne=null,z=null,w=null,N=!1,I=!1,se=!1,be=null;function Le(){return{onSetup(){const m=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(m),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:m,startPoint:null,hasCoordinates:!1}},onMouseMove(m,b){if(!m.startPoint)return;const[E,A]=m.startPoint,D=b.lngLat.lng,G=b.lngLat.lat;m.rectangle.setCoordinates([[[E,A],[D,A],[D,G],[E,G],[E,A]]])},onClick(m,b){if(!m.startPoint){m.startPoint=[b.lngLat.lng,b.lngLat.lat],m.hasCoordinates=!0,m.rectangle.setCoordinates([[[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat]]]);return}const[E,A]=m.startPoint,D=b.lngLat.lng,G=b.lngLat.lat;return Math.abs(E-D)>0&&Math.abs(A-G)>0?(m.rectangle.setCoordinates([[[E,A],[D,A],[D,G],[E,G],[E,A]]]),this.map.fire("draw.create",{features:[m.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[m.rectangle.id]})):(this.deleteFeature([m.rectangle.id],{silent:!0}),m.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(m){this.deleteFeature([m.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(m,b,E){const A=b.properties.id===m.rectangle.id;A&&!m.hasCoordinates||(b.properties.active=A?"true":"false",E(b))}}}const Ae=[{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 Ke(){const m=je.value;return!m||!ve[m]?.url?"":ve[m].url}function dt(m,b){return m?.id?String(m.id):m?.url?`${m.url}-${b}`:`layer-${b}`}function ut(m){const b=String(m?.url??"").trim();if(!b)return"";if(/^https?:\/\//i.test(b))return b;const E=window.location?.origin??"",A=b.replace(/^\/+/,"");return`${E}/${A}`}function Ie(m){m&&Se.value?.layerId!==m||(Se.value=null)}function lt(m,b={}){return m.popup===!1?[]:Array.isArray(m.popup)?m.popup.length?m.popup.map(E=>{const A=E?.field||E?.name;if(!A)return null;const D=b[A];return D==null||D===""?null:{key:E.label||A,value:String(D)}}).filter(Boolean):[]:Object.entries(b).slice(0,5).map(([E,A])=>({key:E,value:A==null?"—":String(A)}))}function Pt(m){if(!Array.isArray(m))return[];const b=A=>Array.isArray(A)&&A.length>=2&&Number.isFinite(Number(A[0]))&&Number.isFinite(Number(A[1])),E=A=>{if(!A.length)return A;const D=A[0],G=A[A.length-1];return!G||D[0]!==G[0]||D[1]!==G[1]?[...A,D]:A};if(m.length&&b(m[0])){const A=m.map(D=>[Number(D[0]),Number(D[1])]).filter(b);return A.length?[E(A)]:[]}return m.length&&Array.isArray(m[0])&&b(m[0][0])?m.map(D=>Array.isArray(D)?D.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(D=>D.length).map(E):m.length&&Array.isArray(m[0])&&Array.isArray(m[0][0])&&b(m[0][0][0])?m.flatMap(D=>Array.isArray(D)?D:[]).map(D=>Array.isArray(D)?D.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(D=>D.length).map(E):[]}function jn(m){const b=m.style??{},E=b.color??"#3b82f6";if(!b.colorAttr||!b.colorSet)return E;const A=Object.keys(b.colorSet);if(!A.length)return E;const D=["match",["to-string",["get",b.colorAttr]]];return A.forEach(G=>{D.push(String(G),b.colorSet?.[G]??E)}),D.push(E),D}function Ft(m){if(!P)return;m.handlers.forEach(E=>{try{P.off(E.type,E.layerId,E.handler)}catch{}}),m.handlers=[],[...m.layerIds,...m.boundsIds].forEach(E=>{P.getLayer(E)&&P.removeLayer(E)}),P.getSource(m.sourceId)&&P.removeSource(m.sourceId);const b=`vs-ov-bounds-src-${m.id}`;P.getSource(b)&&P.removeSource(b),Ie(m.id)}function cn(m,b){if(!P)return[];const E=`vs-ov-bounds-src-${b}`,A=`vs-ov-bounds-line-${b}`,D=m.bounds??T.value??te.value,G=Pt(D);if(!G.length)return[];const ie={type:"FeatureCollection",features:G.map(me=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:me}}))};return P.getSource(E)&&P.removeSource(E),P.addSource(E,{type:"geojson",data:ie}),P.addLayer({id:A,type:"line",source:E,paint:{"line-color":m.style?.stroke??m.style?.color??"#2563eb","line-width":m.style?.width??2,"line-opacity":m.style?.opacity??.8,"line-dasharray":[2,2]}}),[A]}function bt(m){if(!P)return;Ft(m);const b=m.config,E=ut(b);if(!E)return;const A=[],D=[];if(/\.v(?:m)?t(?:\?|$)/i.test(E)||/\.pbf(?:\?|$)/i.test(E)){const me=b.sourceLayer||b.layer||b.service_layer||b.dataset?.layer||b.id;P.addSource(m.sourceId,{type:"vector",tiles:[E]});const Pe=String(b.style?.type??"polygon").toLowerCase(),nt=jn(b),ft=b.style?.opacity??.5;if(Pe==="point"){const xt=`vs-ov-point-${m.id}`;P.addLayer({id:xt,type:"circle",source:m.sourceId,"source-layer":me,paint:{"circle-color":nt,"circle-radius":5,"circle-opacity":ft}}),A.push(xt)}else if(Pe==="polyline"||Pe==="line"){const xt=`vs-ov-line-${m.id}`;P.addLayer({id:xt,type:"line",source:m.sourceId,"source-layer":me,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":nt,"line-width":b.style?.width??2,"line-opacity":ft}}),A.push(xt)}else{const xt=`vs-ov-fill-${m.id}`,mn=`vs-ov-border-${m.id}`;P.addLayer({id:xt,type:"fill",source:m.sourceId,"source-layer":me,paint:{"fill-color":nt,"fill-opacity":ft}}),P.addLayer({id:mn,type:"line",source:m.sourceId,"source-layer":me,paint:{"line-color":b.style?.stroke??b.style?.color??"#2563eb","line-width":b.style?.width??1,"line-opacity":ft}}),A.push(xt,mn)}}else{P.addSource(m.sourceId,{type:"raster",tiles:[E],tileSize:256});const me=`vs-ov-raster-${m.id}`;P.addLayer({id:me,type:"raster",source:m.sourceId,paint:{"raster-opacity":b.style?.opacity??1}}),A.push(me)}A.forEach(me=>{const Pe=ft=>{if(!ft?.features?.length){Ie(m.id);return}const xt=ft.features[0]?.properties??{},mn=lt(m.config,xt);if(!mn.length){Ie(m.id);return}Se.value={layerId:m.id,entries:mn,point:{x:ft.point.x,y:ft.point.y}}},nt=()=>Ie(m.id);P.on("mousemove",me,Pe),P.on("mouseleave",me,nt),D.push({layerId:me,type:"mousemove",handler:Pe},{layerId:me,type:"mouseleave",handler:nt})}),m.layerIds=A,m.boundsIds=cn(m.config,m.id),m.handlers=D;const ie=m.visible?"visible":"none";[...m.layerIds,...m.boundsIds].forEach(me=>{P.getLayer(me)&&P.setLayoutProperty(me,"visibility",ie)})}function zt(){if(!P)return;const b={type:"FeatureCollection",features:Pt(T.value??te.value).map(E=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:E}}))};P.getSource(An)?P.getSource(An).setData(b):P.addSource(An,{type:"geojson",data:b}),P.getLayer(Mn)||P.addLayer({id:Mn,type:"line",source:An,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function vo(m){if(!P||s.value)return;const b=pe[m];if(!b)return;b.visible=!b.visible;const E=b.visible?"visible":"none";[...b.layerIds,...b.boundsIds].forEach(A=>{P.getLayer(A)&&P.setLayoutProperty(A,"visibility",E)}),Bt(),b.visible||Ie(m)}function Bt(){if(!P)return;const m=[],b=[],E=[],A=[];Ce.value.forEach(ie=>{const me=pe[ie];if(!me)return;const Pe=String(me.config?.url??""),nt=/\.v(?:m)?t(?:\?|$)/i.test(Pe),ft=/\.png(?:\?|$)/i.test(Pe);nt?E.push(...me.layerIds):ft?m.push(...me.layerIds):b.push(...me.layerIds),A.push(...me.boundsIds)}),[...m,...b,...E,...A].forEach(ie=>{P.getLayer(ie)&&P.moveLayer(ie)}),P.getLayer(Mn)&&P.moveLayer(Mn),(P.getStyle?.()?.layers??[]).map(ie=>String(ie?.id??"")).filter(ie=>ie.startsWith("gl-draw-")).forEach(ie=>{P.getLayer(ie)&&P.moveLayer(ie)})}function Eo(m){if(!ve[m]||(je.value=m,!P))return;const b=Ke();if(!b)return;const E=P.getCenter?.(),A=P.getZoom?.(),D=oe?.getAll?.();P.setStyle(X(b)),P.once("style.load",()=>{if(P&&(E&&Number.isFinite(A)&&P.jumpTo({center:[E.lng,E.lat],zoom:A}),zt(),Ce.value.forEach(G=>{const ie=pe[G];ie&&bt(ie)}),Bt(),D?.features?.length&&oe))try{D.features.forEach(G=>oe.add(G)),d.value=D.features.length}catch{d.value=0}})}function qt(m){return{type:"Feature",properties:{},geometry:m}}function at(m){if(!m)return null;try{return JSON.parse(JSON.stringify(m))}catch{return null}}function dn(m){if(!m)return null;const b=at(m.geometry);return b?{...m.id!==void 0?{id:m.id}:{},type:"Feature",properties:{...m.properties??{}},geometry:b}:null}function Dt(m){if(!m)return[];const b=(D,G)=>{if(!D?.type)return[];const ie={...G??{}};return D.type==="MultiPoint"&&Array.isArray(D.coordinates)?D.coordinates.map(me=>qt({type:"Point",coordinates:me})).map(me=>({...me,properties:ie})):D.type==="MultiLineString"&&Array.isArray(D.coordinates)?D.coordinates.map(me=>qt({type:"LineString",coordinates:me})).map(me=>({...me,properties:ie})):D.type==="MultiPolygon"&&Array.isArray(D.coordinates)?D.coordinates.map(me=>qt({type:"Polygon",coordinates:me})).map(me=>({...me,properties:ie})):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?D.geometries.flatMap(me=>b(me,ie)):[{type:"Feature",properties:ie,geometry:at(D)}]},E=D=>{if(!D)return null;if(D.type==="Feature"){const G=dn(D);return G?b(G.geometry,G.properties):null}return D.geom?.type&&Array.isArray(D.geom.coordinates)?b({type:D.geom.type,coordinates:D.geom.coordinates},D.properties??{}):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?b(D,D.properties??{}):typeof D.type=="string"&&Array.isArray(D.coordinates)?b(at(D),D.properties??{}):null};if(m.type==="FeatureCollection")return(m.features??[]).flatMap(E).filter(Boolean);if(Array.isArray(m))return m.flatMap(D=>D?.type==="FeatureCollection"?Dt(D):[E(D)]).flat().filter(Boolean);const A=E(m);return A?Array.isArray(A)?A:[A]:[]}function j(m){if(!m.length)return null;if(!a.value)return at(m[0]?.geometry??null);const b=m.map(G=>at(G?.geometry)).filter(Boolean);return b.every(G=>G?.type==="Point")?{type:"MultiPoint",coordinates:b.map(G=>G.coordinates)}:b.every(G=>G?.type==="LineString")?{type:"MultiLineString",coordinates:b.map(G=>G.coordinates)}:b.every(G=>G?.type==="Polygon")?{type:"MultiPolygon",coordinates:b.map(G=>G.coordinates)}:{type:"GeometryCollection",geometries:b}}function ee(m){if(!m)return"__null__";try{return JSON.stringify(m)}catch{return"__invalid__"}}function fe(m,b){if(!Array.isArray(m)||!Array.isArray(b)||m.length<2||b.length<2)return!1;const E=1e-12;return Math.abs(Number(m[0])-Number(b[0]))<E&&Math.abs(Number(m[1])-Number(b[1]))<E}function $e(m,b){if(!Array.isArray(m)||m.length<4)return null;const A=fe(m[0],m[m.length-1])?m.slice(0,-1):m.slice();return!Number.isInteger(b)||b<0||b>=A.length||A.length<=3||(A.splice(b,1),A.length<3)?null:[...A,[...A[0]]]}function Oe(m,b){if(!Array.isArray(m)||m.length<2||!Number.isInteger(b)||b<0||b>=m.length||m.length<=2)return null;const E=m.slice();return E.splice(b,1),E.length<2?null:E}function We(m,b){const E=at(m);if(!E||!Array.isArray(b))return null;if(E.type==="LineString"){const[A]=b,D=Oe(E.coordinates,A);return D?(E.coordinates=D,E):null}if(E.type==="MultiLineString"){const[A,D]=b,G=E.coordinates?.[A],ie=Oe(G,D);return ie?(E.coordinates[A]=ie,E):null}if(E.type==="Polygon"){const[A,D]=b,G=E.coordinates?.[A],ie=$e(G,D);return ie?(E.coordinates[A]=ie,E):null}if(E.type==="MultiPolygon"){const[A,D,G]=b,ie=E.coordinates?.[A]?.[D],me=$e(ie,G);return me?(E.coordinates[A][D]=me,E):null}return null}function Re(m){return m?m.split(".").map(b=>Number(b)).filter(b=>Number.isInteger(b)&&b>=0):[]}function tt(m){return!oe||!m?null:typeof oe.get=="function"?oe.get(m)??null:oe.getAll?.()?.features?.find(E=>String(E?.id??"")===m)??null}function pt(m){const b=m?.properties?.id??m?.id;return b==null||b===""?null:String(b)}function mt(m){if(!P||!m)return null;const b=[[m.x-8,m.y-8],[m.x+8,m.y+8]],A=P.queryRenderedFeatures(b).find(D=>{const G=String(D?.properties?.meta??"");return G&&G!=="feature"?!1:!!pt(D)});return pt(A)}function kt(m,b){if(!oe||!m||!b.length)return;const E=tt(m);if(!E?.geometry)return;const A=We(E.geometry,b);if(!A)return;const D={...E,id:E.id??m,geometry:A};re=!0,he=!0;try{oe.delete(m),oe.add(D)}finally{he=!1,re=!1}Tt(),_t()}function st(m){if(!P||!oe||s.value||k.isRulerActive.value||u.value!=="edit")return;const b=m?.point;if(!b)return;const E=[[b.x-8,b.y-8],[b.x+8,b.y+8]],D=P.queryRenderedFeatures(E).find(ie=>ie?.properties?.meta==="vertex"&&ie?.properties?.parent&&ie?.properties?.coord_path);if(!D)return;m?.originalEvent?.preventDefault?.(),m?.originalEvent?.stopPropagation?.();const G=Re(String(D.properties.coord_path));G.length&&kt(String(D.properties.parent),G)}function un(m){const b=Jr(m);if(!b)return null;const[[E,A],[D,G]]=b;return{lat:(A+G)/2,lng:(E+D)/2}}function Yr(m){if(!Array.isArray(m)||m.length<3)return 0;const b=(A,D)=>{const G=A*2003750834e-2/180,ie=Math.log(Math.tan((90+D)*Math.PI/360))/(Math.PI/180);return[G,ie*2003750834e-2/180]};let E=0;for(let A=0;A<m.length-1;A+=1){const[D,G]=b(Number(m[A][0]),Number(m[A][1])),[ie,me]=b(Number(m[A+1][0]),Number(m[A+1][1]));E+=D*me-ie*G}return Math.abs(E/2)/1e6}function V0(m){if(!m?.type||!m?.coordinates)return null;if(m.type==="Polygon"){const b=m.coordinates?.[0];return Array.isArray(b)?Yr(b):null}return m.type==="MultiPolygon"?m.coordinates.reduce((b,E)=>{const A=E?.[0];return Array.isArray(A)?b+Yr(A):b},0):null}function Bo(m){if(!m){p.value=null;return}const b=un(m);if(!b){p.value=null;return}p.value={type:String(m.type??"Feature"),center:b,areaKm2:V0(m)}}function _o(m){if(!m){const A=Ve[Ve.length-1],D=at(A?.geometry??null);Ne=D,Bo(D);return}const b=Ve.find(A=>String(A?.id??"")===String(m))??null,E=at(b?.geometry??null);Ne=E,Bo(E)}function Vo(m){f.value=(m??[]).map((b,E)=>{const A=String(b?.id??`feature-${E+1}`),D=Xr(String(b?.geometry?.type??"Feature"));return{id:A,label:`${D} ${E+1}`}})}function Xr(m){switch(String(m)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(m||"Невідомо")}}function Zr(m,b){if(!Array.isArray(m)||!Array.isArray(b)||m.length!==2||b.length!==2)return!1;const E=1e-9;return Math.abs(Number(m[0])-Number(b[0]))<E&&Math.abs(Number(m[1])-Number(b[1]))<E}function Jr(m){if(!m)return null;let b=1/0,E=1/0,A=-1/0,D=-1/0;const G=ie=>{if(Array.isArray(ie)){if(ie.length>=2&&Number.isFinite(ie[0])&&Number.isFinite(ie[1])){const me=Number(ie[0]),Pe=Number(ie[1]);b=Math.min(b,me),E=Math.min(E,Pe),A=Math.max(A,me),D=Math.max(D,Pe);return}ie.forEach(G)}};return G(m.coordinates),!Number.isFinite(b)||!Number.isFinite(E)?null:[[b,E],[A,D]]}function Qr(m){if(!P||!m)return;const b=Jr(m);if(!b)return;const[[E,A],[D,G]]=b;if(E===D&&A===G){P.easeTo({center:[E,A],zoom:Math.max(O.value,14)});return}P.fitBounds(b,{padding:30,duration:250,maxZoom:18})}function So(){if(!oe){d.value=0;return}const m=oe.getAll();d.value=m?.features?.length??0}function pn(){if(!oe)return null;const b=oe.getAll?.()?.features??[],E=G=>!!G&&b.some(ie=>String(ie?.id??"")===String(G??"")),A=oe.getSelectedIds?.();if(Array.isArray(A)&&A.length>0){const G=A[0];return G!=null?String(G):null}if(E(w))return String(w);if(!b.length)return null;const D=a.value?b[b.length-1]:b[0];return D?.id!==void 0&&D?.id!==null?String(D.id):null}function Tt(){if(!oe)return;const m=oe.getAll();if(d.value=m?.features?.length??0,!m?.features?.length){Ve=[],f.value=[],Ne=null,w=null,p.value=null,he||(z="__null__",r("update:modelValue",null));return}const b=(m.features??[]).map(dn).filter(Boolean);if(Ve=b,Vo(b),w=pn(),_o(w),!he){const E=j(b);z=ee(E),r("update:modelValue",E)}}function Un(){if(!oe)return;(oe.getAll()?.features||[]).forEach(b=>oe.delete(b.id)),f.value=[],So()}function Hn(m){if(!oe)return;const b=Dt(m),E=a.value?b:b.slice(0,1);he=!0,Un(),E.forEach(G=>{try{oe.add(G)}catch{}}),he=!1,Ve=(oe.getAll?.()?.features??E).map(dn).filter(Boolean),Vo(Ve),w=null;const D=at(Ve[Ve.length-1]?.geometry??null);Ne=at(D),So(),Bo(D),D&&(Qr(D),s.value||_t())}function S0(){oe&&(he=!0,Un(),Ve.forEach(m=>{try{oe.add(m)}catch{}}),he=!1,Vo(Ve),So(),_o(w))}function Kt(){if(oe){try{oe.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""}}function qn(m){if(s.value||!oe)return;k.isRulerActive.value&&k.closeRuler(),se=!0,Kt(),u.value=m;const b=m==="marker"?"draw_point":m==="polyline"?"draw_line_string":m==="rectangle"?"draw_rectangle":"draw_polygon";a.value||(he=!0,Un(),he=!1);try{oe.changeMode(b)}catch{u.value=""}finally{requestAnimationFrame(()=>{se=!1})}}function _t(m){if(s.value||!oe||!oe.getAll()?.features?.length)return;const E=m||pn();if(E)try{oe.changeMode("direct_select",{featureId:E}),w=E,_o(w),u.value="edit"}catch{u.value=""}}function $0(m){s.value||!oe||!m||_t(m)}function N0(){if(!(s.value||!oe)){if(a.value){const m=pn();if(m)try{N=!0,oe.delete(m),N=!1,Tt();const b=pn();b?_t(b):Kt();return}catch{N=!1}}Kt(),Un(),Ve=[],f.value=[],w=null,z="__null__",p.value=null,r("update:modelValue",null)}}function A0(){s.value||!Ne||Qr(Ne)}function M0(m){if(!P||!le)return;const b=[m[1],m[0]];be||(be=new le.Marker({color:"#2563eb"})),be.setLngLat(b).addTo(P),P.easeTo({center:b,zoom:13,duration:250})}function F0(){s.value||J.value?.click()}function D0(){s.value||(F.value=!F.value)}function el(m){if(!F.value)return;const b=de.value;b&&!b.contains(m.target)&&(F.value=!1)}function T0(){F.value=!1,F0()}function L0(){s.value||(ne.value=[],F.value=!1,Y.value=!0)}function I0(){Y.value=!1,ne.value=[]}function O0(){if(s.value||!oe)return;const m=Ad(W.value.coordinates??"",W.value.format||"decimal",W.value.order||"lat-lon");if(!m.ok){ne.value=m.errors,R0(m.errors);return}ne.value=[],Hn({type:"Polygon",coordinates:[m.ring]}),Tt(),Y.value=!1,m.wasClosedAutomatically&&ye.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function R0(m){if(!m.length)return;const b=5;m.slice(0,b).forEach(E=>{const A=E.line>0?`Рядок ${E.line}`:"Загальна помилка";ye.notify({type:"warning",title:"Імпорт координат",message:`${A} — ${E.message}`})}),m.length>b&&ye.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${m.length-b}`})}function P0(m){if(s.value||!oe)return;F.value=!1;const b=m.target,E=b.files?.[0];if(!E)return;const A=new FileReader;A.onload=()=>{try{const D=JSON.parse(String(A.result));if(!Dt(D).length){ye.notify({type:"warning",title:"Імпорт файлу",message:"Файл не містить коректний GeoJSON-обʼєкт."});return}Hn(D),Tt()}catch{ye.notify({type:"error",title:"Імпорт файлу",message:"Не вдалося прочитати файл. Перевірте формат GeoJSON/JSON."})}finally{b.value=""}},A.onerror=()=>{ye.notify({type:"error",title:"Імпорт файлу",message:"Помилка читання файлу."}),b.value=""},A.readAsText(E)}function z0(){if(s.value||!oe)return;const m=oe.getAll(),b=new Blob([JSON.stringify(m,null,2)],{type:"application/json"}),E=URL.createObjectURL(b),A=document.createElement("a");A.href=E,A.download="data.geojson",A.click(),URL.revokeObjectURL(E)}return e.onMounted(async()=>{if(window.addEventListener("click",el,!0),!i.value)return;const m=await U();le=m.maplibregl,ue=m.MapboxDraw;const b=Ke();b&&(P=new le.Map({container:i.value,style:X(b),center:[M.value[0],M.value[1]],zoom:O.value,attributionControl:!1}),y.value=P,P.addControl(new le.NavigationControl({showCompass:!0}),"bottom-right"),P.on("load",()=>{if(!(!ue||!P)){if(oe=new ue({displayControlsDefault:!1,modes:{...ue.modes,draw_rectangle:Le()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:Ae}),P.addControl(oe),P.on("click",E=>{if(k.isRulerActive.value){const D=E?.lngLat;if(!D)return;h.value?.addPoint?.({lat:D.lat,lng:D.lng});return}if(!oe||s.value||u.value!=="edit")return;const A=mt(E?.point);!A||A===w||requestAnimationFrame(()=>{!oe||s.value||_t(A)})}),P.on("draw.create",()=>{if(oe&&!k.isRulerActive.value){if(!a.value){const E=oe.getAll();if(E.features.length>1){const A=E.features[E.features.length-1];he=!0,E.features.slice(0,-1).forEach(D=>oe.delete(D.id)),he=!1,A&&(he=!0,oe.add(A),he=!1)}}Tt(),_t()}}),P.on("draw.update",E=>{if(I||k.isRulerActive.value)return;const A=Array.isArray(E?.features)?E.features:[],D=E?.action==="move"&&A.length>0&&A.every(G=>G?.geometry?.type==="Point");if(E?.action==="move"){if(D){Tt();return}if(I=!0,S0(),I=!1,u.value==="edit"){const G=pn(),ie=G?tt(G):oe?.getAll?.()?.features?.[0];if(ie?.id)try{oe.changeMode("direct_select",{featureId:ie.id}),w=String(ie.id)}catch{u.value=""}}return}Tt()}),P.on("draw.delete",()=>{re||N||k.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle"||(Tt(),oe?.getAll?.()?.features?.length||(w=null),u.value="",Kt())}),P.on("draw.selectionchange",E=>{if(!oe||I||k.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle")return;const A=E?.features?.[0]?.id!==void 0&&E?.features?.[0]?.id!==null?String(E.features[0].id):null;if(!s.value&&A){if(u.value==="edit"&&w===A)return;requestAnimationFrame(()=>{!oe||s.value||_t(A)});return}const D=oe.getSelectedIds?.(),G=Array.isArray(D)&&D.length>0?String(D[0]):null;if(!s.value&&G){if(u.value==="edit"&&w===G)return;requestAnimationFrame(()=>{!oe||s.value||_t(G)});return}try{oe.changeMode("simple_select",{featureIds:[]})}catch{}}),Q.value!==void 0){const E=Q.value;Q.value=void 0,requestAnimationFrame(()=>{oe&&Hn(E)})}zt(),Ce.value.forEach(E=>{const A=pe[E];A&&bt(A)}),Bt()}}),P.on("contextmenu",st),P.on("zoomend",()=>{P&&(O.value=P.getZoom())}))}),e.onUnmounted(()=>{k.isRulerActive.value&&k.closeRuler(),window.removeEventListener("click",el,!0),Object.values(pe).forEach(m=>{P&&Ft(m)}),Ie(),be?.remove&&be.remove(),be=null,P?.remove&&P.remove(),P=null,oe=null,y.value=null}),e.watch(()=>o.modelValue,m=>{if(!oe){Q.value=m;return}const b=j((a.value?Dt(m):Dt(m).slice(0,1))||[]),E=ee(b);if(z&&E===z){z=null;return}z=null,Hn(m)},{deep:!0}),e.watch(()=>V.value,m=>{const b=Array.isArray(m)?m:[],E=[],A=new Set;b.forEach((D,G)=>{if(!D)return;const ie=dt(D,G);E.push(ie),A.add(ie);const me={...D,id:ie},Pe=pe[ie],nt=Pe?.visible??!!me.visible;Pe&&P&&Ft(Pe),pe[ie]={id:ie,config:me,visible:nt,sourceId:`vs-ov-src-${ie}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(pe).forEach(D=>{if(A.has(D))return;const G=pe[D];G&&P&&Ft(G),delete pe[D]}),Ce.value=E,P&&(Ce.value.forEach(D=>{const G=pe[D];G&&bt(G)}),Bt())},{immediate:!0,deep:!0}),e.watch(()=>T.value,()=>{P&&(zt(),Ce.value.forEach(m=>{const b=pe[m];b&&bt(b)}),Bt())},{deep:!0}),e.watch(()=>R.value,async m=>{if(te.value=[],!m){P&&(zt(),Ce.value.forEach(b=>{const E=pe[b];E&&bt(E)}),Bt());return}try{const b=await fetch(`https://data.gki.com.ua/api-user/atu/${m}`);if(!b?.ok)return;const A=(await b.json())?.geometry?.coordinates;Array.isArray(A)&&A.length&&(te.value=A)}catch(b){console.error("Failed to fetch KATOTTG bounds",b)}finally{if(!P)return;zt(),Ce.value.forEach(b=>{const E=pe[b];E&&bt(E)}),Bt()}},{immediate:!0}),e.watch(()=>_.value,m=>{if(!Array.isArray(m)||m.length!==2)return;const b=[Number(m[0]),Number(m[1])];if(Zr(M.value,b)||(M.value=[...b],!P))return;const E=P.getCenter?.();E&&Zr([E.lng,E.lat],M.value)||P.easeTo({center:[M.value[0],M.value[1]]})},{deep:!0}),e.watch(()=>$.value,m=>{typeof m=="number"&&(O.value=m,P&&P.setZoom(m))}),e.watch(s,m=>{m&&Kt()}),e.watch(d,m=>{if(m>0){s.value||_t();return}se||Kt()}),e.watch(c,()=>{setTimeout(()=>{P?.resize&&P.resize()},50)}),(m,b)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!c.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:c.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:i,class:"w-full h-[calc(100%-28px)]"},null,512),Z.value.search||Z.value.import||Z.value.export?(e.openBlock(),e.createElementBlock("div",Wu,[Z.value.search?(e.openBlock(),e.createBlock(Zd,{key:0,onGoToCoordinates:M0})):e.createCommentVNode("",!0),Z.value.import||Z.value.export?(e.openBlock(),e.createElementBlock("div",Gu,[e.createElementVNode("div",Yu,[Z.value.import?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:de,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:D0,disabled:s.value},[b[8]||(b[8]=e.createTextVNode(" Імпорт ",-1)),e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":F.value}])},null,8,["class"])],8,Xu),F.value?(e.openBlock(),e.createElementBlock("div",Zu,[Z.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:T0}," З файлу ")):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:L0}," З координат ")])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),Z.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:z0,disabled:s.value||d.value===0}," Експорт ",8,Ju)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:J,type:"file",onChange:P0,accept:".json,.geojson",class:"hidden",disabled:s.value},null,40,Qu)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(ye.VsModal),{visible:Y.value,"onUpdate:visible":b[1]||(b[1]=E=>Y.value=E),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(rt,{schema:ce,values:W.value,"onUpdate:values":b[0]||(b[0]=E=>W.value=E)},null,8,["values"]),e.createElementVNode("div",ep,[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:I0}," Скасувати "),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:O0,disabled:s.value}," Побудувати ",8,tp)])]),_:1},8,["visible"]),e.createElementVNode("div",np,[e.createElementVNode("div",op,[Z.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="marker"}]),title:"Point",onClick:b[2]||(b[2]=E=>qn("marker")),disabled:s.value},[e.createVNode(e.unref(q.MapPin),{class:"h-4 w-4"})],10,rp)):e.createCommentVNode("",!0),Z.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polyline"}]),title:"Line",onClick:b[3]||(b[3]=E=>qn("polyline")),disabled:s.value},[e.createVNode(gd)],10,lp)):e.createCommentVNode("",!0),Z.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polygon"}]),title:"Polygon",onClick:b[4]||(b[4]=E=>qn("polygon")),disabled:s.value},[e.createVNode(xd)],10,ap)):e.createCommentVNode("",!0),Z.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="rectangle"}]),title:"Rectangle",onClick:b[5]||(b[5]=E=>qn("rectangle")),disabled:s.value},[e.createVNode(Ed)],10,sp)):e.createCommentVNode("",!0),Z.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(k).isRulerActive.value}]),title:"Ruler",onClick:g},[e.createVNode(e.unref(q.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:b[6]||(b[6]=E=>c.value=!c.value),title:"Full Screen"},[e.createVNode(e.unref(q.Maximize),{class:"h-4 w-4"})])])]),Z.value.ruler&&e.unref(k).isRulerActive.value?(e.openBlock(),e.createBlock(Hu,{key:1,ref_key:"rulerPanelRefEl",ref:h,onClose:b[7]||(b[7]=E=>e.unref(k).closeRuler()),onTabChange:e.unref(k).onRulerTabChange,onPointsChange:e.unref(k).onRulerPointsChange,onShapeClosedChange:e.unref(k).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),Z.value.ruler&&e.unref(k).isRulerActive.value&&e.unref(k).hasRulerPoints.value?(e.openBlock(),e.createBlock(qu,{key:2,map:y.value,points:e.unref(k).rulerPoints.value,"is-shape-closed":e.unref(k).rulerShapeClosed.value,"label-mode":e.unref(k).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),De.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(Me.value)},[e.createElementVNode("div",ip,[e.createElementVNode("dl",cp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(De.value,E=>(e.openBlock(),e.createElementBlock("div",{key:`${E.key}-${E.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",dp,e.toDisplayString(E.key),1),e.createElementVNode("dd",up,e.toDisplayString(E.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",pp,[e.createElementVNode("div",mp,[e.createVNode($d,{basemaps:e.unref(ve),onOnLayerChange:Eo},null,8,["basemaps"]),ke.value.length?(e.openBlock(),e.createElementBlock("div",fp,[b[9]||(b[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",hp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ke.value,E=>(e.openBlock(),e.createElementBlock("label",{key:E.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:E.visible,disabled:s.value,onChange:A=>vo(E.id)},null,40,gp),e.createElementVNode("span",yp,e.toDisplayString(E.config.title||E.config.name||E.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",bp,[f.value.length||p.value?(e.openBlock(),e.createElementBlock("div",kp,[e.createElementVNode("div",xp,[e.createElementVNode("div",wp,[b[10]||(b[10]=e.createTextVNode(" Тип: ",-1)),f.value.length<=1?(e.openBlock(),e.createElementBlock("span",Cp,e.toDisplayString(p.value?Xr(p.value.type):f.value[0]?.label||"—"),1)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(f.value,(E,A)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:E.id},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["font-bold underline-offset-2",E.id===e.unref(w)?"text-blue-700 underline":"text-gray-700 hover:text-blue-700 hover:underline"]),onClick:D=>$0(E.id),disabled:s.value},e.toDisplayString(E.label),11,vp),A<f.value.length-1?(e.openBlock(),e.createElementBlock("span",Ep,", ")):e.createCommentVNode("",!0)],64))),128))])]),e.createElementVNode("div",Bp,[e.createElementVNode("div",_p,[b[11]||(b[11]=e.createTextVNode(" Центр: ",-1)),p.value?(e.openBlock(),e.createElementBlock("b",Vp,e.toDisplayString(p.value.center.lng.toFixed(5))+", "+e.toDisplayString(p.value.center.lat.toFixed(5)),1)):(e.openBlock(),e.createElementBlock("b",Sp,"—"))]),p.value&&p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",$p,[b[12]||(b[12]=e.createTextVNode(" Площа: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",Np,[...b[13]||(b[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:A0,disabled:s.value},[e.createVNode(e.unref(q.ZoomIn),{class:"h-3 w-3"})],8,Ap),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:N0,disabled:s.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Mp)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-893cf482"]]),Fp=["data-focus"],Dp={class:"flex items-center"},Tp={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},Lp=["onClick","aria-label"],Ip={key:0,class:"absolute text-gray-500 truncate pl-2"},Op={class:"flex-1 min-w-[2px]"},Rp=["placeholder"],Pp={class:"flex items-center shrink-0"},zp=["disabled"],ar=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(n,{emit:t}){const o=n,r=t;Ge(o.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),c=e.ref(!1),i=e.ref(""),d=e.useModel(n,"modelValue"),u=e.computed(()=>o.placeholder||"Add tag…"),p=e.computed(()=>d.value?.length===0&&i.value===""),f=e.computed(()=>!o.disabled&&d.value?.length>0),y=e.computed(()=>o.disabled),h=async()=>{y.value||await e.nextTick(()=>s.value?.focus())},k=K=>{const L=K.trim();L!==""&&(!d.value||!Array.isArray(d.value)?d.value=[L]:o.unique?d.value.includes(L)||(d.value=[...d.value,L]):d.value=[...d.value,L],i.value="")},g=()=>{const K=i.value;K.trim()!==""&&k(K),i.value=""},v=K=>{const L=d.value.slice();L.splice(K,1),r("update:modelValue",L)},x=()=>{r("update:modelValue",[])},C=()=>{y.value||(c.value=!0)},S=()=>{c.value=!1,!y.value&&g()},H=K=>{const{key:L}=K;L==="Enter"?(K.preventDefault(),g()):L==="Backspace"&&i.value===""&&d.value.length>0&&v(d.value.length-1)};return(K,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",o.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",c.value?"border-blue-500 ring-1 ring-blue-500":"",y.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":c.value?"true":"false",onClick:h},[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,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",Dp,[e.createElementVNode("div",Tp,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($=>v(_),["stop"]),"aria-label":`Remove ${B}`},[e.createVNode(e.unref(q.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Lp)]))),128)),p.value?(e.openBlock(),e.createElementBlock("div",Ip,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Op,[y.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=>i.value=B),onFocus:C,onBlur:S,onKeydown:H,placeholder:d.value&&d.value.length?"":void 0},null,40,Rp)),[[e.vModelText,i.value]])])],512),e.createElementVNode("div",Pp,[f.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:y.value,onClick:e.withModifiers(x,["stop"])},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,zp)):e.createCommentVNode("",!0)])],10,Fp)],2)],512))}}),jp={class:"relative flex gap-1 bg-white w-full"},Up=["disabled","placeholder"],sr=Be(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const t=e.inject("values"),o=n,r=e.useModel(n,"modelValue");function l(s){const c={а:"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(i=>c[i]||i).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[o.parent||""]?.toString(),c=l(s);r.value=c.toString()};return(s,c)=>(e.openBlock(),e.createElementBlock("div",jp,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:n.disabled,placeholder:n.placeholder,"onUpdate:modelValue":c[0]||(c[0]=i=>r.value=i),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,Up),[[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-cb7b2b74"]]),Hp={class:"relative flex gap-1 bg-white w-full"},qp=["disabled","placeholder"],Kp=["disabled"],Wp={key:0},Gp={key:1},ir=Be(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(n){const t=n,o=e.useModel(n,"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}`},c=async()=>{if(!a.value||r.value)return;const d=s();if(d){r.value=!0;try{const p=await(await fetch(d)).text();o.value=p}finally{r.value=!1}}},i=()=>{l.value&&(o.value||c())};return e.onMounted(()=>{i()}),e.watch(()=>[t.table,t.code,t.init],()=>{i()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",Hp,[e.withDirectives(e.createElementVNode("input",{disabled:n.disabled,placeholder:n.placeholder,"onUpdate:modelValue":u[0]||(u[0]=p=>o.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,qp),[[e.vModelText,o.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||n.disabled||!a.value,onClick:c},[r.value?(e.openBlock(),e.createElementBlock("span",Gp,"...")):(e.openBlock(),e.createElementBlock("span",Wp,"Gen"))],8,Kp)]))}}),[["__scopeId","data-v-8f88fb66"]]),Yp={class:"w-full"},Xp={ref:"sortableContainer",class:"flex flex-col gap-1"},Zp=["onDragstart","onDrop"],Jp={class:"cursor-move",type:"button"},Qp={class:"w-1/3"},em={class:"w-2/3"},tm=["onClick"],nm={key:0,class:"text-[14px] text-gray-700"},om={class:"mt-2 w-full flex items-center"},rm=["disabled"],cr=Be(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(n,{emit:t}){const o=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,r=e.inject("values"),l=n,a=t,s=l.addButtonText??"Додати",c=l.ignore??[],i=e.ref([]),d=e.ref(null);(()=>{const g=l.parent&&r?.value?.[l.parent]||l.modelValue||{};i.value=Object.entries(g).filter(([v])=>!c.includes(v)).map(([v,x])=>({id:o("key-value-"),key:v,value:x}))})();function p(g){d.value=g}function f(g){if(d.value===null||d.value===g)return;const v=i.value.splice(d.value,1)[0];i.value.splice(g,0,v),d.value=null}const y=e.computed(()=>i.value.some(g=>g.key&&!g.value||!g.key&&g.value)),h=()=>{i.value.push({id:o("key-value-"),key:"",value:""})},k=g=>{i.value=i.value.filter(v=>v.id!==g)};return e.watch(i,g=>{const v={};g.forEach(C=>{C.key&&C.value!==void 0&&(v[C.key]=C.value)});const x={};c.length&&c.forEach(C=>{x[C]=l.parent?r?.value?.[l.parent]?.[C]:void 0}),r?.value&&l.parent&&(r.value[l.parent]={...x,...v}),a("update:modelValue",v)},{deep:!0}),(g,v)=>(e.openBlock(),e.createElementBlock("div",Yp,[e.createElementVNode("div",Xp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(x,C)=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===C}]),draggable:"true",onDragstart:S=>p(C),onDragover:v[0]||(v[0]=e.withModifiers(()=>{},["prevent"])),onDrop:S=>f(C)},[e.createElementVNode("button",Jp,[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",Qp,[e.createVNode(jt,{modelValue:x.key,"onUpdate:modelValue":S=>x.key=S,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",em,[e.createVNode(jt,{modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:S=>k(x.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(q.X),{class:"h-4 w-4"})],8,tm)],42,Zp))),128))],512),i.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",nm," Дані для відображення відсутні ")),e.createElementVNode("div",om,[e.createElementVNode("button",{type:"button",onClick:h,disabled:y.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(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(s)),1)],8,rm)])]))}}),[["__scopeId","data-v-ac321a0f"]]),lm={class:"w-full"},am={ref:"sortableContainer",class:"flex flex-col gap-1"},sm=["onDragstart","onDrop"],im=["disabled"],cm={class:"flex-1"},dm=["onClick","disabled"],um={key:0,class:"text-[14px] text-gray-700"},pm={class:"mt-2 w-full flex items-center"},mm=["disabled"],dr=Be(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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),c=e.computed(()=>t.addButtonText??"Додати");let i=!1;const d=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,u=g=>{const v=g??o.value??[];r.value=v.map((x,C)=>({id:r.value[C]?.id??d("text-array"),value:x??""}))};u(),e.watch(()=>o.value,g=>{if(i){i=!1;return}u(g||[])},{deep:!0}),e.watch(r,g=>{i=!0,o.value=g.map(v=>v.value).filter(v=>v!=null&&v!=="")},{deep:!0});const p=e.computed(()=>a.value||r.value.some(g=>!g.value));function f(){p.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function y(g){a.value||(r.value=r.value.filter(v=>v.id!==g))}function h(g){a.value||(l.value=g)}function k(g){if(a.value||l.value===null||l.value===g)return;const v=[...r.value],[x]=v.splice(l.value,1);v.splice(g,0,x),r.value=v,l.value=null}return(g,v)=>(e.openBlock(),e.createElementBlock("div",lm,[e.createElementVNode("div",am,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(x,C)=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":l.value===C}]),draggable:"true",onDragstart:S=>h(C),onDragover:v[0]||(v[0]=e.withModifiers(()=>{},["prevent"])),onDrop:S=>k(C)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})],8,im),e.createElementVNode("div",cm,[n.inputType==="text"?(e.openBlock(),e.createBlock(jt,{key:0,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),n.inputType==="tel"?(e.openBlock(),e.createBlock(Jn,{key:1,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),n.inputType==="email"?(e.openBlock(),e.createBlock(Zn,{key:2,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),n.inputType==="mask"?(e.openBlock(),e.createBlock(hn,{key:3,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,mask:n.mask,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:S=>y(x.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(q.X),{class:"h-4 w-4"})],8,dm)],42,sm))),128))],512),r.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",um," Дані для відображення відсутні ")),e.createElementVNode("div",pm,[e.createElementVNode("button",{type:"button",onClick:f,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(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(c.value),1)],8,mm)])]))}}),[["__scopeId","data-v-972a598a"]]),fm={class:"flex items-center gap-2 w-full"},hm=["disabled"],gm=["disabled"],ur=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(n,{emit:t}){const o=n,{inputClass:r}=Ge(o.style),l=t,a=e.computed({get:()=>o.modelValue||"#000000",set:c=>l("update:modelValue",c)}),s=e.computed(()=>!!o.disabled);return(c,i)=>(e.openBlock(),e.createElementBlock("div",fm,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":i[0]||(i[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]",[n.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,hm),[[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":i[1]||(i[1]=d=>a.value=d),disabled:s.value},null,8,gm),[[e.vModelText,a.value]])]))}}),ym={class:"flex items-center gap-2 w-full"},bm=["min","max","step","disabled"],km=["value","min","max","step","disabled"],pr=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(n,{emit:t}){const o=n,{inputClass:r}=Ge(o.style),l=t,a=u=>{const p=Number(u),f=Number(o.min),y=Number(o.max);return Number.isNaN(p)?f:Math.min(y,Math.max(f,p))},s=e.computed({get:()=>a(o.modelValue??o.min),set:u=>l("update:modelValue",a(u))}),c=u=>{const p=u.target,f=a(p.value);p.value=String(f),l("update:modelValue",f)},i=u=>{Number(o.min)>=0&&u.key==="-"&&u.preventDefault()},d=e.computed(()=>!!o.disabled);return(u,p)=>(e.openBlock(),e.createElementBlock("div",ym,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":p[0]||(p[0]=f=>s.value=f),min:n.min,max:n.max,step:n.step,disabled:d.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[n.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")])},null,10,bm),[[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:n.min,max:n.max,step:n.step,onInput:c,onKeydown:i,disabled:d.value},null,40,km)]))}}),xm=["placeholder","disabled","name"],wm=["type","value","onInput","placeholder","disabled"],Cm=["onClick"],mr=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(n){const t=n,o=e.ref(t.count),r=e.computed(()=>t.limit),{inputClass:l}=Ge(t.style),a=e.useModel(n,"modelValue"),s=e.computed(()=>!!t.disabled),c=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const k=a.value?.length??0;k<o.value&&(a.value=[...a.value??[],...Array(o.value-k)])});const i=e.ref({}),d=e.ref({});function u(k,g){k&&(i.value[g]=k)}async function p(k,g){if(!k||t.inputType!=="mask")return;const{default:v}=await Promise.resolve().then(()=>Pn);d.value[g]&&d.value[g].destroy(),d.value[g]=v(k,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[g].on("accept",()=>{const x=[...a.value||[]];x[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=x}),d.value[g].on("complete",()=>{const x=[...a.value||[]];x[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=x}),a.value?.[g]&&(d.value[g].value=a.value[g])}function f(k,g){if(s.value)return;const v=k.target.value??null,x=[...a.value];x[g]=t.inputType==="text"?v:Number(v),a.value=x}function y(){o.value+=1;const k=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,k],t.inputType==="mask"&&setTimeout(()=>{const g=o.value-1;i.value[g]&&p(i.value[g],g)},0)}function h(k){if(o.value>1){d.value[k]&&(d.value[k].destroy(),delete d.value[k]),o.value-=1,a.value=a.value.filter((v,x)=>x!==k);const g={};Object.keys(d.value).forEach(v=>{const x=parseInt(v,10);x>k?g[x-1]=d.value[x]:x<k&&(g[x]=d.value[x])}),d.value=g}}return e.onMounted(()=>{if(t.inputType==="mask")for(let k=0;k<o.value;k+=1)i.value[k]&&p(i.value[k],k)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(k=>{k&&k.destroy()})}),e.watch(()=>t.mask,k=>{t.inputType==="mask"&&Object.values(d.value).forEach(g=>{g&&g.updateOptions({mask:k,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,k=>{t.inputType==="mask"&&k&&k.forEach((g,v)=>{d.value[v]&&d.value[v].value!==g&&(d.value[v].value=g||"")})},{deep:!0}),(k,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(o.value,v=>(e.openBlock(),e.createElementBlock("div",{key:v,class:"flex items-center gap-2 w-full"},[n.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:x=>u(x,v-1),placeholder:n.placeholder,disabled:n.disabled,name:`${n.name}[${v-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,xm)):(e.openBlock(),e.createElementBlock("input",{key:1,type:n.inputType,value:a.value?.[v-1],onInput:x=>f(x,v-1),placeholder:c.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":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,wm)),!n.disabled&&v===o.value&&n.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(y,["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(q.Plus),{class:"h-4 w-4"})])):e.createCommentVNode("",!0),!n.disabled&&o.value>1&&n.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(x=>h(v-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(q.X),{class:"h-4 w-4"})],8,Cm)):e.createCommentVNode("",!0)]))),128))],2))}}),vm={class:"flex gap-1 w-full"},Em=["aria-expanded","data-focus"],Bm=["placeholder","disabled","readonly"],_m={class:"max-h-full"},Vm=["onClick","disabled"],Sm={key:0,class:"px-3 py-2 text-sm text-stone-500"},$m=["disabled"],Nm={class:"flex flex-col gap-1"},Am=["onDragstart","onDrop"],Mm=["disabled"],Fm=["title"],Dm=["disabled","onClick","aria-label"],Tm={key:0,class:"text-xs text-stone-500"},Fn=Be(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(n,{emit:t}){const o=n,r=t,l=e.useModel(n,"modelValue"),a=e.ref([]),s=e.ref(o.options??[]),c=e.ref({}),i=e.ref({}),d=e.ref({keyword:"",parent:null}),u=e.ref(""),p=e.ref(!1),f=e.ref(null),y=e.ref(null),h=e.ref(null),k=e.ref(null),g=e.ref(null),v=e.ref({});let x=!1,C=!1;const S=e.inject("values"),H=e.computed(()=>!!o.disabled),K=e.computed(()=>o.placeholder??"Оберіть значення"),L=e.computed(()=>o.search!==!1),B=e.computed(()=>{const w=o.parent??o.parentValue;return w?String(w):""}),_=e.computed(()=>B.value?S?.value?.[B.value]??null:null),$=w=>w==null?"__null__":String(w),R=w=>{if(!w)return"";const N=w.label??w.text??w.name??w.ua??w.en;return N?String(N):w.id!==void 0&&w.id!==null?String(w.id):""},V=w=>{const N=$(w);return i.value[N]||(i.value[N]=`array-select-${N}-${Math.random().toString(36).slice(2,8)}`),i.value[N]},T=e.computed(()=>new Set(a.value.map(w=>$(w.id)))),M=e.computed(()=>{const w=T.value;let N=[...s.value];if(!o.data&&u.value.trim()){const I=u.value.toLowerCase();N=N.filter(se=>R(se).toLowerCase().includes(I))}return N.filter(I=>!w.has($(I.id)))}),O=()=>{if(!o.data)return"";const w=o.prefix??"api",N=o.api??`/${w}/suggest/${o.data}`;return`${o.host??""}${N}`},Q=()=>{a.value.length&&(x=!0,a.value=a.value.map(w=>({...w,text:c.value[$(w.id)]??w.text})))},J=w=>{const N=$(w.id),I=R(w);I&&(c.value[N]=I)},de=w=>{s.value=w?[...w]:[],w?.forEach(J),Q()},te=w=>{if(!w.length)return;const N=new Map(s.value.map(I=>[$(I.id),I]));w.forEach(I=>{const se=$(I.id);N.set(se,I),J(I)}),s.value=Array.from(N.values()),Q()},F=async(w="")=>{if(!o.data)return[];const N=O();if(!N)return[];const I=new URLSearchParams;I.set("json","1"),w&&I.set("key",w),o.start===1&&I.set("start","1"),_.value!==null&&_.value!==void 0&&_.value!==""&&I.set("parent",String(_.value));try{return(await(await fetch(`${N}?${I.toString()}`)).json())?.data??[]}catch{return[]}},Y=async w=>{if(!o.data||!w.length)return[];const N=O();if(!N)return[];const I=Array.from(new Set(w.map(be=>$(be)))),se=new URLSearchParams;se.set("json","1"),se.set("val",I.join(",")),o.start===1&&se.set("start","1"),_.value!==null&&_.value!==void 0&&_.value!==""&&se.set("parent",String(_.value));try{const Ae=(await(await fetch(`${N}?${se.toString()}`)).json())?.data??[];return te(Ae),Ae}catch{return[]}},ne=async w=>{if(w==null||w==="")return null;const N=$(w),I=s.value.find(be=>$(be.id)===N);if(I)return I;const[se]=await Y([w]);return se??null},W=async(w="",{force:N=!1}={})=>{if(!o.data)return;const I=_.value??null;if(!N&&d.value.keyword===w&&d.value.parent===I&&s.value.length>0)return;d.value={keyword:w,parent:I};const be=await F(w);de(be)},he=((w,N=200)=>{let I;return(...se)=>{I&&clearTimeout(I),I=setTimeout(()=>w(...se),N)}})(async w=>{o.data&&await W(w,{force:!0})},250),re=e.ref(null),pe=()=>{if(!h.value)return;const w=h.value.getBoundingClientRect(),N=window.innerHeight??document.documentElement.clientHeight,I=window.innerWidth??document.documentElement.clientWidth,se=8,be=8,Le=o.maxHeight??280,Ae=N-w.bottom-be-se,Ke=w.top-be-se,dt=Ae>=Ke,ut=Math.max(I-se*2,0);let{width:Ie}=w;ut>0&&Ie>ut&&(Ie=ut);let{left:lt}=w;lt+Ie+se>I&&(lt=I-Ie-se),lt=Math.max(lt,se);const Pt=Math.min(Le,Math.max(dt?Ae:Ke,50));v.value={position:"fixed",left:`${lt}px`,width:`${Ie}px`,maxHeight:`${Pt}px`,transform:dt?"none":"translateY(-100%)",top:dt?`${w.bottom+be}px`:`${w.top-be}px`}},Ce=async(w="click")=>{H.value||p.value||(re.value=w,await W(u.value.trim()),p.value=!0,await e.nextTick(),pe(),g.value?.focus())},ke=()=>{p.value=!1,re.value=null,e.nextTick(()=>{g.value?.blur()})},Se=async w=>{if(w.stopPropagation(),!H.value){if(p.value){if(re.value==="focus"){re.value=null;return}ke();return}await Ce("click")}},De=w=>{w.key==="Escape"&&ke()},Me=w=>{if(!p.value)return;const N=w.target;k.value?.contains(N)||ke()},Te=w=>{const N=w.target;y.value?.contains(N)||k.value?.contains(N)||ke()},Z=w=>{if(w.key==="Escape"){w.preventDefault(),ke();return}if(w.key==="Enter"){w.preventDefault();const N=M.value[0];N&&ae(N)}},ae=w=>{if(!w)return;const N=$(w.id);if(T.value.has(N))return;J(w);const I={id:w.id,text:R(w)||String(w.id??""),key:V(w.id)};a.value=[...a.value,I],xe(w),u.value="",e.nextTick(()=>{g.value?.focus()})},xe=w=>{const N=a.value.map(I=>I.id);r("value-selected",{name:o.name,value:N,option:w})},ve=w=>{if(H.value)return;const N=a.value.filter(I=>$(I.id)!==$(w));a.value=N},{isOpenAdd:Fe,addData:je,addSchema:U,addForm:X,addTitle:le,addOption:ue,onAddValue:P}=Go({props:o,fetchOptionByValue:ne,optionsList:s,selectedOption:e.ref(null),modelValue:l,onCreated:async(w,N)=>{const I=w??await ne(N),se=I?.id??N;T.value.has($(se))||(I&&J(I),a.value=[...a.value,{id:se,text:I?R(I):String(se),key:V(se)}],xe(I??null))}}),oe=w=>{H.value||(f.value=w)},Ve=w=>{if(H.value||f.value===null||f.value===w)return;const N=[...a.value],[I]=N.splice(f.value,1);N.splice(w,0,I),f.value=null,a.value=N},Ne=async()=>{const N=(Array.isArray(l.value)?[...l.value]:[]).filter(se=>se!=null);if(o.data&&N.length){const se=N.filter(be=>!c.value[$(be)]);se.length&&await Y(se)}const I=N.map(se=>({id:se,text:c.value[$(se)]??String(se),key:V(se)}));x=!0,a.value=I};e.watch(a,w=>{if(x){x=!1;return}const N=w.map(I=>I.id);C=!0,l.value=N,r("change",N)},{deep:!0}),e.watch(l,()=>{if(C){C=!1;return}Ne()},{deep:!0}),e.watch(u,w=>{!o.data||!p.value||he(w.trim())}),e.watch(H,w=>{w&&ke()}),e.watch(()=>o.options,async w=>{o.data||(de(w??[]),await Ne())},{immediate:!0,deep:!0}),e.watch(()=>o.data,async w=>{w&&(await W(u.value.trim()),await Ne())},{immediate:!0});const z=e.ref(!1);return e.watch(_,async()=>{if(o.data){if(!z.value){z.value=!0;return}a.value=[],await W(u.value.trim()),await Ne()}}),e.onMounted(async()=>{document.addEventListener("click",Te,!0),window.addEventListener("keydown",De),window.addEventListener("scroll",Me,!0),await Ne()}),e.onUnmounted(()=>{document.removeEventListener("click",Te,!0),window.removeEventListener("keydown",De),window.removeEventListener("scroll",Me,!0)}),(w,N)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(ye.VsModal),{visible:e.unref(Fe),"onUpdate:visible":N[1]||(N[1]=I=>e.isRef(Fe)?Fe.value=I:null),class:"z-[1000]",title:e.unref(le),buttonText:"Додати",onDone:e.unref(ue)},{default:e.withCtx(()=>[e.createVNode(rt,{schema:e.unref(U),modelValue:e.unref(je),"onUpdate:modelValue":N[0]||(N[0]=I=>e.isRef(je)?je.value=I:null),ref_key:"addForm",ref:X},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),e.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:y},[e.createElementVNode("div",vm,[e.createElementVNode("div",{class:"relative flex-1",onClick:N[4]||(N[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:h,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)]":"",H.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:Se},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":N[2]||(N[2]=I=>u.value=I),placeholder:K.value,disabled:H.value,readonly:!L.value,onFocus:N[3]||(N[3]=()=>Ce("focus")),onKeydown:Z,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,Bm),[[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(q.ChevronDown),{class:"h-4 w-4"})],2)],10,Em),(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:k,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(v.value)},[e.createElementVNode("div",_m,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,I=>(e.openBlock(),e.createElementBlock("button",{key:$(I.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(se=>ae(I),["stop"]),disabled:H.value},e.toDisplayString(R(I)),9,Vm))),128)),M.value.length===0?(e.openBlock(),e.createElementBlock("p",Sm," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),o.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:N[5]||(N[5]=(...I)=>e.unref(P)&&e.unref(P)(...I)),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:H.value,type:"button"},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),N[8]||(N[8]=e.createElementVNode("span",null,"Додати",-1))],8,$m)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Nm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(I,se)=>(e.openBlock(),e.createElementBlock("div",{key:I.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":f.value===se}]),draggable:"true",onDragstart:be=>oe(se),onDragover:N[6]||(N[6]=e.withModifiers(()=>{},["prevent"])),onDrop:be=>Ve(se),onDragend:N[7]||(N[7]=be=>f.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:H.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})],8,Mm),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:I.text},e.toDisplayString(I.text),9,Fm),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:H.value,onClick:e.withModifiers(be=>ve(I.id),["stop"]),"aria-label":`Видалити ${I.text}`},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,Dm)],42,Am))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",Tm,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-9f0cb9d4"]]),Lm={class:"flex items-center gap-2 w-full"},Im={class:"relative flex-1"},Om=["placeholder","disabled","onKeydown"],Rm=["disabled"],Pm={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},zm={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},jm={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},Um=["onClick"],Hm={key:0,class:"p-4 text-sm text-gray-500"},fr=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(n,{emit:t}){const o=/{{\s*([^}]+?)\s*}}/g,r=n,l=t,{inputClass:a}=Ge(r.style),s=e.useModel(n,"modelValue"),c=e.computed({get:()=>s.value,set:L=>{s.value=L}}),i=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 f=e.computed(()=>r.placeholder??""),y=e.computed(()=>!!r.disabled),h=L=>{if(!L)return null;if(Array.isArray(L))return L;if(typeof L=="string"){const B=L.split(",").map(_=>_.trim()).filter(Boolean);return B.length!==4?null:B.map(Number)}return null},k=e.computed(()=>{const L=h(r.bbox);if(!L||L.length!==4)return null;const B=L.map(Number);return B.some(_=>Number.isNaN(_))?null:B}),g=e.computed(()=>{const L=k.value;if(!L)return"";const[B,_,$,R]=L;return`${B},${Math.max(_,R)},${$},${Math.min(_,R)}`});e.computed(()=>g.value?"1":"0");const v=e.inject("values");function x(){!y.value&&c.value.trim()&&C()}async function C(){const L=(c.value||"").trim();if(!L)return;let B=L;if(r.includes?.length&&v?.value){const $=r.includes.map(R=>v.value?.[R]).filter(Boolean);$.length&&(B=`${$.join(", ")}, ${L}`)}const _=K(B);if(_){i.value=!0;try{const R=await(await fetch(_)).json();d.value=Array.isArray(R)?R:[],u.value=!0}catch($){console.error("Address search error:",$)}finally{i.value=!1}}}function S(){u.value=!u.value}function H(L){if(!L)return;u.value=!1;const B=parseFloat(L.lat),$={type:"Point",coordinates:[parseFloat(L.lon),B]};r.geom&&v?.value&&(v.value[r.geom]=$),l("update:geom",$)}function K(L){if(!r.api)return"";const B={value:encodeURIComponent(L),bbox:k.value?k.value.join(","):""};return r.api.replace(o,(_,$)=>B[$.trim()]??"")}return(L,B)=>(e.openBlock(),e.createElementBlock("div",Lm,[e.createElementVNode("div",Im,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":B[0]||(B[0]=_=>c.value=_),placeholder:f.value,disabled:y.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(x,["prevent"]),["enter"])},null,42,Om),[[e.vModelText,c.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:S,title:"Show search results"},[e.createVNode(e.unref(q.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:C,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:i.value||!c.value?.trim()},[i.value?(e.openBlock(),e.createBlock(e.unref(q.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(q.Search),{key:0,class:"h-4 w-4"}))],8,Rm),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[u.value?(e.openBlock(),e.createElementBlock("div",Pm,[e.createElementVNode("div",zm,[e.createElementVNode("div",jm,[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]=_=>u.value=!1),title:"Close"},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(_,$)=>(e.openBlock(),e.createElementBlock("li",{key:$,onClick:R=>H(_),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(_.display_name),9,Um))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Hm," Не знайдено результатів "))])])):e.createCommentVNode("",!0)]))]))}}),qm={class:"vs-datalist space-y-3"},Km={class:"space-y-3"},Wm=["onClick","disabled"],Gm={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Ym=["disabled"],Xm=Be(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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.computed(()=>Array.isArray(o.value)?o.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(g=>({...g,disabled:t.disabled||g.disabled}))??[]),s=e.computed(()=>a.value.map(g=>k(g))),c=e.computed(()=>a.value.reduce((v,x)=>{const C=Number(x?.col??12);return v+(Number.isFinite(C)&&C>0?C:12)},0)>12),i=e.computed(()=>t.disabled?!1:t.maxItems?r.value.length<t.maxItems:!0),d=e.computed(()=>t.disabled||r.value.length<=(t.minItems||0));e.watch(()=>r.value.length,()=>{u(),p()},{immediate:!0}),e.watch(()=>t.schema,p,{immediate:!0,deep:!0});function u(){const g=r.value.length;l.value.length<g?l.value=[...l.value,...Array.from({length:g-l.value.length},()=>io())]:l.value.length>g&&l.value.splice(g)}function p(){if(!t.minItems||r.value.length>=t.minItems)return;const g=t.minItems-r.value.length,v=Array.from({length:g},f);o.value=[...r.value,...v]}function f(){const g={};return a.value.forEach(v=>{g[v.name]=v?.default??null}),g}function y(){i.value&&(o.value=[...r.value,f()],u())}function h(g){d.value||(o.value=r.value.filter((v,x)=>x!==g),u(),p())}function k(g){return{...g}}return(g,v)=>(e.openBlock(),e.createElementBlock("div",qm,[e.createElementVNode("div",Km,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(x,C)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[C],class:e.normalizeClass(["flex items-center gap-3 rounded-lg transition-colors",{"border border-gray-300 p-2":c.value}])},[e.createVNode(rt,{schema:s.value,layout:"inline",navigation:!1,values:r.value[C],"onUpdate:values":S=>r.value[C]=S,"form-id":l.value[C]},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:S=>h(C),disabled:d.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Wm)],2))),128)),r.value.length===0?(e.openBlock(),e.createElementBlock("div",Gm,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:y,disabled:!i.value},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Ym)]))}}),[["__scopeId","data-v-8df8e72a"]]),Zm={class:"vs-dataform space-y-4"},Jm=["draggable","onDragstart","onDragover","onDragenter","onDrop"],Qm={class:"flex items-center gap-2"},ef=["onClick"],tf={class:"text-sm font-medium text-gray-700"},nf={class:"flex items-center gap-2"},of=["title","onClick","disabled"],rf=["title","onClick","disabled"],lf={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},af=["disabled"],sf=Be(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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),c=e.ref(null),i=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),u=e.computed(()=>t.emptyLabel??"Ще немає груп"),p=e.computed(()=>t.schema?.map(W=>({...W,disabled:t.disabled||W.disabled}))??[]),f=e.computed(()=>p.value.map(W=>_(W))),y=e.computed(()=>t.view==="accordion"),h=e.computed(()=>!!(t.collapsible||y.value)),k=e.computed(()=>t.draggable!==!1),g=e.computed(()=>t.disabled?!1:t.maxGroups?o.value.length<t.maxGroups:!0),v=e.computed(()=>t.disabled||o.value.length<=(t.minGroups||0));e.watch(()=>o.value.length,()=>{x(),C(),S()},{immediate:!0}),e.watch(()=>t.schema,S,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{C()},{immediate:!0});function x(){const W=o.value.length;r.value.length<W?r.value=[...r.value,...Array.from({length:W-r.value.length},()=>io())]:r.value.length>W&&r.value.splice(W)}function C(){const W=o.value.length;y.value?W===0?a.value=-1:a.value>=W?a.value=W-1:a.value<0&&(a.value=0):l.value.length<W?l.value=[...l.value,...Array.from({length:W-l.value.length},()=>!1)]:l.value.length>W&&l.value.splice(W)}function S(){if(!t.minGroups||o.value.length>=t.minGroups)return;const W=t.minGroups-o.value.length,ce=Array.from({length:W},H);o.value=[...o.value,...ce],C()}function H(){const W={};return p.value.forEach(ce=>{W[ce.name]=ce?.default??null}),W}function K(){g.value&&(o.value=[...o.value,H()],x(),C())}function L(W){v.value||(o.value=o.value.filter((ce,he)=>he!==W),x(),y.value?a.value>=o.value.length&&(a.value=o.value.length-1):l.value.splice(W,1),S())}function B(W){if(t.disabled)return;const ce=JSON.parse(JSON.stringify(o.value[W]??{}));o.value=[...o.value.slice(0,W+1),ce,...o.value.slice(W+1)],x(),y.value?a.value>W&&(a.value+=1):l.value.splice(W+1,0,l.value[W]??!1)}function _(W){return{...W}}function $(W){return y.value?a.value===-1&&W===0?!1:a.value!==W:!!l.value[W]}function R(W){if(h.value){if(y.value){a.value=W;return}l.value[W]=!l.value[W]}}function V(W,ce){if(!k.value||t.disabled){ce.preventDefault();return}s.value=W,c.value=W,i.value={groups:JSON.parse(JSON.stringify(o.value)),keys:[...r.value],states:[...l.value]},ce.dataTransfer?.setData("text/plain",String(W)),ce.dataTransfer?.setDragImage?.(ce.currentTarget,0,0)}function T(W,ce){!k.value||t.disabled||s.value!==null&&te(W,ce)}function M(W,ce){te(W,ce)}function O(W){!k.value||t.disabled||ne()}function Q(){i.value&&de(),s.value=null,c.value=null,i.value=null}function J(W,ce){const he=[...o.value],[re]=he.splice(W,1);he.splice(ce,0,re),o.value=he;const pe=[...r.value],[Ce]=pe.splice(W,1);if(pe.splice(ce,0,Ce),r.value=pe,y.value)a.value===W&&(a.value=ce);else{const ke=[...l.value],[Se]=ke.splice(W,1);ke.splice(ce,0,Se),l.value=ke}}function de(){i.value&&(o.value=i.value.groups,r.value=i.value.keys,l.value=i.value.states,i.value=null,c.value=null)}function te(W,ce){if(s.value===null)return;const he=F(W,ce);c.value=he,Y(he)}function F(W,ce){if(!ce?.currentTarget)return W;const he=ce.currentTarget.getBoundingClientRect(),pe=ce.clientY-he.top>he.height/2?W+1:W;return Math.max(0,Math.min(pe,o.value.length))}function Y(W){const ce=s.value;if(ce===null)return;let he=W;if(he>o.value.length&&(he=o.value.length),he===ce||he===ce+1)return;const re=he>ce?he-1:he;J(ce,re),s.value=re,c.value=he>ce?re+1:re}function ne(){i.value=null,s.value=null,c.value=null}return(W,ce)=>(e.openBlock(),e.createElementBlock("div",Zm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(he,re)=>(e.openBlock(),e.createElementBlock("div",{key:r.value[re],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":$(re)?"pt-6 px-6":"p-6"]]),draggable:k.value&&!t.disabled,onDragstart:pe=>V(re,pe),onDragend:Q,onDragover:e.withModifiers(pe=>T(re,pe),["prevent"]),onDragenter:e.withModifiers(pe=>M(re,pe),["prevent"]),onDrop:e.withModifiers(pe=>O(),["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"&&!$(re)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",Qm,[k.value?(e.openBlock(),e.createBlock(e.unref(q.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:pe=>R(re)},[e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",$(re)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,ef)):e.createCommentVNode("",!0),e.createElementVNode("div",tf,e.toDisplayString(`${d.value} (${re+1})`),1)]),e.createElementVNode("div",nf,[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:pe=>B(re),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(q.Copy),{class:"h-4 w-4"})],8,of),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:pe=>L(re),disabled:v.value,draggable:"false"},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,rf)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(rt,{class:"vs-dataform__form",schema:f.value,layout:"inline",navigation:!1,values:o.value[re],"onUpdate:values":pe=>o.value[re]=pe,"form-id":r.value[re],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!$(re)]])],42,Jm))),128)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",lf,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:K,disabled:!g.value},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,af)]))}}),[["__scopeId","data-v-accd044e"]]),Dn="__vs_form_monaco_loader__",Rt="__vs_form_monaco_script_loader__",Tn="__vs_form_monaco_editor_loader__",co=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(n,{expose:t}){const o=n,r=e.useModel(n,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof o.height=="number"?`${o.height}px`:o.height||"280px");let s=null,c=null,i=!1;const d=()=>{if(c)return Promise.resolve(c);if(typeof window>"u")return Promise.resolve(null);const h=window;if(h.monaco?.editor?.create)return c=h.monaco,Promise.resolve(c);if(h[Dn])return h[Dn];const g=(async()=>{const v=S=>{if(Array.from(document.styleSheets||[]).some(L=>L?.href?.includes(S)))return;const K=document.createElement("link");K.rel="stylesheet",K.href=S,document.head.appendChild(K)},x=S=>{if(h[Rt]?.[S])return h[Rt][S];h[Rt]||={};const H=Array.from(document.scripts).find(K=>K.src===S);return H?(h[Rt][S]=new Promise((K,L)=>{const B=H.readyState;if(H.dataset.loaded==="true"||B==="loaded"||B==="complete"){K();return}H.addEventListener("load",()=>{H.dataset.loaded="true",K()},{once:!0}),H.addEventListener("error",_=>L(_),{once:!0})}),h[Rt][S]):(h[Rt][S]=new Promise((K,L)=>{const B=document.createElement("script");B.src=S,B.async=!0,B.onload=()=>{B.dataset.loaded="true",K()},B.onerror=_=>L(_),document.body.appendChild(B)}),h[Rt][S])},C="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return v(`${C}/editor/editor.main.min.css`),await x(`${C}/loader.min.js`),h[Tn]||(h[Tn]=new Promise((S,H)=>{window.require.config({paths:{vs:C}}),window.require(["vs/editor/editor.main"],()=>{c=window.monaco,h.monaco=c,S(c)},K=>H(K))}).catch(S=>{throw delete h[Tn],S})),h[Tn]})().catch(v=>{throw delete h[Dn],v});return h[Dn]=g,g},u=()=>{!l.value||!c||(s&&(s.dispose(),s=null),s=c.editor.create(l.value,{value:r.value||"",language:o.syntax,theme:o.theme,automaticLayout:!0,minimap:{enabled:!!o.minimap},readOnly:!!o.disabled}),s.onDidChangeModelContent(()=>{i||(r.value=s.getValue())}))},p=()=>{s?.focus()},f=()=>s,y=()=>c;return e.watch(()=>r.value,h=>{if(!s)return;const k=s.getValue();h!==k&&(i=!0,s.setValue(h||""),i=!1)}),e.watch(()=>o.syntax,h=>{!s||!c||c.editor.setModelLanguage(s.getModel(),h||"xml")}),e.watch(()=>o.theme,h=>{c&&c.editor.setTheme(h||"vs-light")}),e.watch(()=>o.disabled,h=>{s&&s.updateOptions({readOnly:!!h})}),e.watch(()=>o.minimap,h=>{s&&s.updateOptions({minimap:{enabled:!!h}})}),e.onMounted(async()=>{try{const h=await d();if(!h||!h.editor)return;c=h,u()}catch(h){console.error("Failed to load Monaco editor",h)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:p,getEditor:f,getMonaco:y}),(h,k)=>(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))}}),hr={VsInputText:jt,VsInputRadio:Qn,VsInputInlineSelect:_n,"vs-input-text":jt,"vs-input-password":El,"vs-input-textarea":Xo,"vs-input-richtext":Zo,"vs-input-mask":hn,"vs-input-number":No,"vs-input-radio":Qn,"vs-input-select":so,"vs-input-inline-select":_n,"inline-select":_n,"vs-input-switcher":Yn,"vs-input-static":Xn,"vs-input-container":Wo,"vs-input-date":zo,"vs-input-checkbox":Fo,"vs-input-file":Ho,"vs-input-file2":ao,file2:ao,File2:ao,"vs-input-html":Xn,"vs-input-email":Zn,"vs-input-tel":Jn,"vs-input-datatable":Jo,"vs-input-map":lr,"vs-input-file-list":qo,"vs-input-tags":ar,"vs-input-slug":sr,"vs-input-codegen":ir,"vs-input-key-value":cr,"vs-input-text[]":dr,"vs-input-range":pr,"vs-input-color":ur,"vs-input-native-select":so,VsInputArraySelect:Fn,"vs-input-array":mr,"vs-input-array-select":Fn,"array-select":Fn,"vs-input-address":fr,"vs-input-datalist":Xm,"vs-input-dataform":sf,"vs-input-monaco":co},cf=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(n){const t=n,o=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){ye.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!o)return;for(const[c,i]of Object.entries(t.set))o.value[c]=s.result[i]}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(n.button),1))}}),df={class:"flex flex-col gap-1 w-full"},uf={class:"w-full"},pf=["disabled"],mf=["innerHTML"],ff=2e3,hf=10,gr=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(n,{emit:t}){const o=n,r=e.useModel(n,"modelValue"),l=t,a=e.computed(()=>Cl[`${o.layout}`]),s=["label","placeholder","info","description","text","html"],c=e.ref($()),i=e.computed(()=>L(o.item,c.value)),d=e.computed(()=>{const V={...i.value??{}},T=o.item?.name;return T&&p?.value?.[T]&&Object.assign(V,p.value[T]),V.__locale=c.value,V}),u=e.computed(()=>hr?.[`vs-input-${o.item.type}`]),p=e.inject("field-props"),f=e.computed(()=>{const V=e.unref(u);if(!V)return new Set;const T=V.props??V.__vccOpts?.props;if(!T)return new Set;const M=Array.isArray(T)?T:Object.keys(T);return new Set(M)}),h=[...["min","max","step"],"api","set","mask"],k=e.computed(()=>{const V={...i.value??{}},T=o.item?.name;T&&p?.value?.[T]&&Object.assign(V,p.value[T]);const M=f.value;let O;return M.size?O=Object.fromEntries(Object.entries(V).filter(([Q])=>M.has(Q))):O=V,h.forEach(Q=>{const J=V[Q];J!=null&&(O[Q]=J)}),O}),g=V=>{const T=typeof V=="object"&&V!==null?V:{value:V};l("value-selected",{...T,name:T.name??o.item?.name})},v=/{{\s*([^}]+?)\s*}}/g,x=e.inject("values"),C=e.ref(!1),S=e.computed(()=>{const V=o.item?.api,T=o.item?.type?.toLowerCase();return typeof V=="string"&&V.trim().length>0&&(T==="text"||T==="mask")});function H(V,T){if(!(V==null||!T))return T.split(".").reduce((M,O)=>M?.[O.trim()],V)}async function K(){const V=String(r.value??"").trim();if(!V)return;const T=(o.item?.api??"").trim();if(!T)return;const M=T.replace(v,(O,Q)=>Q.trim()==="value"?encodeURIComponent(V):"");C.value=!0;try{let O=await fetch(M),Q=0;for(;O.status===202&&Q<hf;)Q+=1,await new Promise(Y=>{setTimeout(Y,ff)}),O=await fetch(M);if(O.status===202){ye.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!O.ok){ye.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const J=await O.json(),de=J?.result!==void 0?J.result:J,te=o.item?.set;if(!te||!x?.value)return;const F=o.item?.name;Object.entries(te).forEach(([Y,ne])=>{if(!Y)return;let W=ne;F&&W.startsWith(`${F}.`)&&(W=W.slice(F.length+1));const ce=H(de,W);x.value[Y]=ce??null})}catch(O){console.error("API lookup error:",O),ye.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{C.value=!1}}e.onMounted(()=>{c.value=$(),window.addEventListener("storage",R)}),e.onUnmounted(()=>{window.removeEventListener("storage",R)});function L(V,T){if(!V)return{};const M={...V};return s.forEach(O=>{const Q=_(V,O,T);Q!=null&&(M[O]=Q)}),Array.isArray(V.options)&&(M.options=V.options.map(O=>B(O,T))),M}function B(V,T){if(!V)return V;const M={...V},O=_(V,"label",T),Q=_(V,"text",T);return O!=null&&(M.label=O),Q!=null?M.text=Q:O!=null&&(M.text=O),M}function _(V,T,M){const O=`${T}:${M}`;if(V?.[O]!=null)return V[O];if(T==="label"&&V?.[M]!=null)return V[M];if(V?.[T]!=null)return V[T];if(T==="label"){if(V?.ua!=null)return V.ua;if(V?.en!=null)return V.en}if(T==="text"||T==="html"){if(V?.ua!=null)return V.ua;if(V?.en!=null)return V.en}return null}function $(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function R(){c.value=$()}return(V,T)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:d.value.ua,error:o.error||"",item:d.value,columns:o.columns,label:d.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${o.item.type}-component`])},[e.createElementVNode("div",df,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":S.value}])},[e.createElementVNode("div",uf,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value),e.mergeProps(k.value,{modelValue:r.value,"onUpdate:modelValue":T[0]||(T[0]=M=>r.value=M),onValueSelected:g}),null,16,["modelValue"]))]),S.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:C.value||!r.value?.toString().trim(),onClick:K},[C.value?(e.openBlock(),e.createBlock(e.unref(q.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(q.Search),{key:0,class:"h-4 w-4"}))],8,pf)):e.createCommentVNode("",!0)],2),d.value.description&&o.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:d.value.description},null,8,mf)):e.createCommentVNode("",!0)]),d.value.behavior?.api&&d.value.behavior?.button?(e.openBlock(),e.createBlock(cf,e.mergeProps({key:0},d.value.behavior,{value:r.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),gf={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},yf={class:"vs-compact-form-navigation__rail mt-[6px]"},bf=["onClick"],kf=Be(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(n,{expose:t}){const o=n,r=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!o.enabled),c=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"]),i=e.computed(()=>{const R=o.width;if(R==null)return{};const V=typeof R=="number"?`${R}px`:`${R}`;return{width:V,minWidth:V}});let d=null,u=0,p=0,f=null,y=null,h=null;const k=()=>_(),g=()=>x();e.watch(()=>o.target,async R=>{if(K(),!R){f=null,r.value=[],l.value="";return}f=R,s.value&&(await e.nextTick(),H(R),x())},{immediate:!0}),e.watch(()=>o.scrollContainer,R=>{if(!s.value){y=R??null;return}v(R??null),e.nextTick(()=>x())},{immediate:!0}),e.onMounted(()=>{o.scrollContainer||v(null),x()}),e.onBeforeUnmount(()=>{K(),v(null,!0),f=null,typeof window<"u"&&(u&&window.cancelAnimationFrame(u),p&&window.cancelAnimationFrame(p))});function v(R,V=!1){if(h&&(h(),h=null),V){y=null;return}if(y=R??null,typeof window>"u")return;const T=R??window,M=window;T.addEventListener("scroll",k,{passive:!0}),M.addEventListener("resize",g),h=()=>{T.removeEventListener("scroll",k),M.removeEventListener("resize",g)}}function x(){if(!s.value||!f)return;u&&typeof window<"u"&&window.cancelAnimationFrame(u);const R=()=>{C(),u=0};typeof window>"u"?R():u=window.requestAnimationFrame(R)}function C(){if(!s.value||!f)return;const R=Array.from(f.querySelectorAll("h1, h2")),V=new Set,T=[];R.forEach((M,O)=>{const Q=M.textContent?.trim()??"";if(!Q)return;let J=(M.getAttribute("id")??"").trim();J||(J=S(Q)||`heading-${O+1}`);let de=J,te=1;for(;V.has(de);)de=`${J}-${te+=1}`;M.id!==de&&Object.assign(M,{id:de}),V.add(de),T.push({id:de,text:Q,level:M.tagName.toLowerCase()==="h1"?1:2})}),r.value=T,T.length||(l.value=""),B()}function S(R){return R.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function H(R){!R||!s.value||typeof MutationObserver>"u"||(K(),d=new MutationObserver(()=>x()),d.observe(R,{childList:!0,subtree:!0}))}function K(){d&&(d.disconnect(),d=null)}function L(R){const V=y;if(!V)return typeof window>"u"?R.offsetTop:R.getBoundingClientRect().top+window.scrollY;const T=R.getBoundingClientRect(),M=V.getBoundingClientRect();return T.top-M.top+V.scrollTop}function B(){if(!s.value||!r.value.length)return;const R=y,V=(R?R.scrollTop:null)||(typeof window<"u"?window.scrollY:0),T=(R?R.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),M=V+T;let O=null;for(let J=0;J<r.value.length;J+=1){const de=r.value[J],te=document.getElementById(de.id);if(te){const F=L(te);F+te.offsetHeight>V&&F<M&&(O=de.id)}}!O&&a.value&&(O=a.value),O&&(a.value=O);const Q=R?R.scrollHeight-R.clientHeight:document.documentElement.scrollHeight-window.innerHeight;V+5>=Q&&(O=r.value[r.value.length-1].id),O&&(l.value=O)}function _(){s.value&&(p&&window.cancelAnimationFrame(p),p=window.requestAnimationFrame(()=>{B(),p=0}))}function $(R){if(!s.value)return;const V=document.getElementById(R);if(!V)return;const T=y,M=Math.max(0,L(V));T?T.scrollTo({top:M,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:M,behavior:"smooth"})}return t({refresh:x}),(R,V)=>s.value&&r.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(c.value),style:e.normalizeStyle(i.value)},[e.createElementVNode("h2",gf,e.toDisplayString(n.title),1),e.createElementVNode("div",yf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,T=>(e.openBlock(),e.createElementBlock("div",{key:T.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",T.level===2?"vs-compact-form-navigation__item--nested":"",T.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:M=>$(T.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",T.level===2?"pl-[15px]":"pl-[18px]",T.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(T.text),1)],10,bf)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-b3e16a91"]]),ct={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:n=>`Мінімальна довжина — ${n} символів`,maxlength:n=>`Максимальна довжина — ${n} символів`,min:n=>`Значення має бути не менше ${n}`,max:n=>`Значення має бути не більше ${n}`},xf=n=>typeof n=="string"?n.trim()?!1:ct.required:Array.isArray(n)?n.map(o=>typeof o=="string"?o.trim():o).filter(o=>o!=null&&o!=="").length?!1:ct.required:typeof n=="number"?Number?.isNaN(n)?ct?.required:!1:n?!1:ct.required,wf=n=>{const t=/^[\p{L}\p{N}!#$%&'*+/=?^_`{|}~.-]+@(?:[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?\.)+[\p{L}\p{N}](?:[\p{L}\p{N}-]{0,61}[\p{L}\p{N}])?$/u;return n?t.test(n)?!1:ct.email:!1},Cf=(n,t)=>{if(!n)return!1;const o=String(n).trim();if(!/^\+[1-9]\d{1,14}$/.test(o))return ct.tel;const a=(typeof t?.digits=="number"&&Number.isFinite(t.digits)&&t.digits>0?t.digits:St(wt))||St(wt);return o.length-1!==a?ct.tel:!1},yr=n=>n==null?0:typeof n=="string"?n.trim().length:Array.isArray(n)?n.length:typeof n=="number"?n.toString().length:String(n).length,vf=(n,t)=>{if(n==null)return!1;const o=Number(t?.value??t?.length);return Number.isFinite(o)&&yr(n)<o?t?.message||ct.minlength(o):!1},Ef=(n,t)=>{if(n==null||n==="")return!1;const o=Number(t?.value??t?.length);return Number.isFinite(o)&&yr(n)>o?t?.message||ct.maxlength(o):!1},br=n=>{if(typeof n=="number")return n;if(typeof n=="string"){const t=n.trim().replace(",",".");return t?Number(t):Number.NaN}return Number(n)},Bf=(n,t)=>{if(n==null||n==="")return!1;const o=Number(t?.value);if(!Number.isFinite(o))return!1;const r=br(n);return Number.isFinite(r)&&r<o?t?.message||ct.min(o):!1},_f=(n,t)=>{if(n==null||n==="")return!1;const o=Number(t?.value);if(!Number.isFinite(o))return!1;const r=br(n);return Number.isFinite(r)&&r>o?t?.message||ct.max(o):!1},Vf=(n,t)=>{const o=t.pattern??t.regexp,r=typeof o=="string"?new RegExp(o):o;if(Array.isArray(n)){const l=n.filter(Boolean);return l.length===0||l.every(a=>r.test(a))?!1:t.message}return!r.test(n)&&n?t.message:!1},Sf=(n,t)=>!1,$f=(n,t)=>{switch(typeof t=="string"?t:t.type){case"required":return xf(n);case"email":return wf(n);case"tel":return Cf(n,typeof t=="object"?t:void 0);case"regexp":return Vf(n,t);case"minlength":return vf(n,t);case"maxlength":return Ef(n,t);case"min":return Bf(n,t);case"max":return _f(n,t);case"custom":return Sf();default:return!1}},Nf={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file",inlineselect:"inline-select"};function kr(n){const t=n?.toLowerCase();return Nf[t]||t}function uo(n,t=!1){if(Array.isArray(n)){const r=[];return n.forEach(l=>{const a={...l};if(a.name=(l.name||l.id||l.key||"").toString(),a.type=kr(l.type),a.label=l.label||l.ua,a.rules=l.rules||l.validators,a.type==="email"&&!a.rules&&(a.rules=["email"]),a.type==="tel"&&!a.rules){const s=a.mask||wt,c=St(s)||St(wt);a.rules=[{type:"tel",digits:c}]}l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=uo(a.schema,a.disabled)),r.push(a)}),r}const o=[];return Object.entries(n).forEach(r=>{const l={name:r[0],...r[1],type:kr(r[1].type),label:r[1].label||r[1].ua,rules:r[1].rules||r[1].validators,disabled:r[1].disabled??t};if(l.type==="email"&&!l.rules&&(l.rules=["email"]),l.type==="tel"&&!l.rules){const a=l.mask||wt,s=St(a)||St(wt);l.rules=[{type:"tel",digits:s}]}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=uo(l.schema,l.disabled)),o.push(l)}),o}function Af(n,t,o=!1){const r=e.computed(()=>uo((Array.isArray(t),t),typeof o=="boolean"?o:o.value)),l=e.ref({});function a(d){return Ko(n?.value,d?.conditions)}const s=(d=r.value,u=!0)=>(d.forEach(p=>{const f=[],y=Number(p?.minlength),h=Number(p?.maxlength),k=Number(p?.min),g=Number(p?.max);!Number.isNaN(y)&&Number.isFinite(y)&&f.push({type:"minlength",value:y}),!Number.isNaN(h)&&Number.isFinite(h)&&f.push({type:"maxlength",value:h}),!Number.isNaN(k)&&Number.isFinite(k)&&f.push({type:"min",value:k}),!Number.isNaN(g)&&Number.isFinite(g)&&f.push({type:"max",value:g});const v=[...f,...p.rules||[]];if(v.length){if(!a(p)){delete l.value[p.name];return}let x=!1,C=null;v.forEach(S=>{const H=$f(n.value[p.name],S);H&&(x=!0,!C&&typeof H=="string"&&(C=H))}),x&&C?l.value[p.name]=C:delete l.value[p.name]}p.schema&&s(p.schema,!1)}),u&&Object.values(l.value).some(Boolean)?l.value:null),c=e.computed(()=>r.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{n.value={},l.value={}},visibleSchema:c}}const Mf={class:"flex w-full h-full min-h-0 gap-6"},Ff={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(n,{expose:t,emit:o}){const r=o,l=n,a=e.useModel(n,"form"),s=e.useModel(n,"modelValue"),c=e.useModel(n,"values"),i=e.computed({get:()=>c.value??s.value,set:O=>{s.value=O,c.value=O}}),{errors:d,validate:u,reset:p,visibleSchema:f}=Af(i,l.schema,e.toRef(l,"disabled")),y=e.ref(null),h=e.ref(null),k=e.ref({}),g=e.computed(()=>l.navigation),v=e.computed(()=>l.navWidth),x=e.computed(()=>l.style?.columns),C=Object.freeze({container:12,label:3}),S=e.computed(()=>l.columns??x.value??C),H=e.computed(()=>l.columns!=null||x.value!=null),K=e.computed(()=>H.value?"horizontal":l.layout),L=O=>O?.columns?"horizontal":K.value,B=O=>O?.columns??S.value,_=e.computed(()=>{const O={},Q=J=>{if(!J)return;(Array.isArray(J)?J.map((te,F)=>({key:String(F),entry:te})):typeof J=="object"?Object.entries(J).map(([te,F])=>({key:te,entry:F})):[]).forEach(({key:te,entry:F})=>{if(!F||typeof F!="object")return;const Y=F.name?String(F.name):te;Y&&(O[Y]={...F,name:Y}),Array.isArray(F.schema)&&Q(F.schema)})};return Q(l.schema),O}),$=()=>{!l.formId&&i.value&&delete i.value.id,r("update:modelValue",i.value),u(),r("handle-submit",i.value)},R=O=>{r("value-selected",O)};t({validate:u,reset:p,errors:d}),e.onMounted(()=>{a.value={value:i.value,errors:d.value,reset:p,validate:u,formId:l.formId}});function V(O,Q){if(O===Q)return!0;if(typeof O!="object"||typeof Q!="object"||!O||!Q)return!1;const J=Object.keys(O),de=Object.keys(Q);return J.length!==de.length?!1:J.every(te=>O[te]===Q[te])}function T(O){return Array.isArray(O)?[...O]:O&&typeof O=="object"?{...O}:O}function M(O){Array.isArray(O)&&O.forEach(Q=>{if(!Q)return;const J=Q.name,de=Q.default!==void 0;J&&de&&i.value[J]===void 0&&(i.value[J]=T(Q.default)),Array.isArray(Q.schema)&&M(Q.schema)})}return e.watch(f,O=>{M(O)},{immediate:!0,deep:!0}),e.provide("form",a),e.provide("values",i),e.provide("field-props",k),e.provide("schema-by-name",_),(O,Q)=>(e.openBlock(),e.createElementBlock("div",Mf,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:h},[e.createElementVNode("form",{ref_key:"formRef",ref:y,onSubmit:e.withModifiers($,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",K.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f),(J,de)=>(e.openBlock(),e.createElementBlock("div",{key:J.name,class:e.normalizeClass(L(J)==="horizontal"?"col-span-12":`col-span-${J.col||12}`)},[e.createVNode(gr,{style:e.normalizeStyle(n.style),item:J,layout:L(J),columns:B(J),"model-value":i.value[J.name],"onUpdate:modelValue":te=>{if(J.name==="id"&&!n.formId)return;const F=i.value[J.name];V(F,te)||(i.value[J.name]=te)},error:e.unref(d)[J.name],onValueSelected:R},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),L(J)==="settings"&&de+1!==e.unref(f).length?(e.openBlock(),e.createElementBlock("div",Ff)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode(kf,{target:y.value,"scroll-container":h.value,enabled:g.value,width:v.value},null,8,["target","scroll-container","enabled","width"])]))}}),Df={class:"relative"},Tf={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},Lf={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"},If={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Of={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Rf={class:"p-4 mim-h-0 h-full overflow-auto"},xr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(n,{emit:t}){const o=n,r=t,l=e.ref(o.schema),a=e.ref(o.defaultValue?JSON.parse(JSON.stringify(o.defaultValue)):{}),s=e.ref({}),c=e.ref(o.token||""),i=e.ref(o.token||""),d=e.ref(o.mode),u=()=>{const g=o.method?.trim().toUpperCase();return g==="GET"||g==="POST"||g==="PUT"?g:d.value==="add"?"POST":"PUT"},p=()=>{ye.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},f=g=>{const v={};g.id!==void 0&&g.id!==null&&(v.id=g.id,i.value=g.id.toString()),g.obj&&typeof g.obj=="object"&&Object.assign(v,g.obj),Object.keys(v).length&&(a.value={...a.value,...v})},y=async g=>{if(console.log(g),g.ok){await g.json().catch(()=>({})),p(),r("save",a.value);return}const v=await g.json().catch(()=>({})),x=v.message||v.error;if(g.status===400){ye.notify({type:"warning",title:"Помилка валідації",message:x||"Некоректні дані (400)"});return}if(g.status===500){ye.notify({type:"error",title:"Серверна помилка",message:x||"Виникла помилка на сервері (500)"});return}ye.notify({type:"error",title:"Помилка",message:`Статус: ${g.status}`})};async function h(){const g=s.value.validate();if(g){ye.notify({type:"warning",title:"Помилка валідації",message:Object.entries(g).map(([x,C])=>`${x}: ${C}`).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 he=!1,re=!1;const pe=e.reactive({}),Ce=e.ref([]),ke=e.computed(()=>Ce.value.map(m=>pe[m]).filter(Boolean)),Se=e.ref(null),De=e.computed(()=>Se.value?.entries??[]),Me=e.computed(()=>{if(Se.value)return{left:`${Se.value.point.x+12}px`,top:`${Se.value.point.y+12}px`}}),Te=e.computed(()=>{if(Array.isArray(o.tools)&&o.tools.length)return o.tools;const m=l?.tools;return Array.isArray(m)?m.map(b=>String(b)):typeof m=="string"?m.split(",").map(b=>b.trim()).filter(Boolean):[]}),Z=e.computed(()=>{const m={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Te.value.length)return{...m,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const b=new Set(Te.value.map(E=>E.toLowerCase()));return{search:b.has("search"),import:b.has("import"),export:b.has("export"),point:b.has("point"),line:b.has("line"),polygon:b.has("polygon"),rectangle:b.has("rectangle"),ruler:b.has("ruler")}});function ae(m){if(typeof m!="string"||!m.trim())return"";if(/^https?:\/\//i.test(m))return m;const b=window?.location?.origin??"",E=m.replace(/^\/+/,"");return E?b?`${b}/${E}`:`/${E}`:b}function xe(){const m=Array.isArray(C.basemaps)&&C.basemaps.length?C.basemaps:x.basemaps;if(Array.isArray(m)&&m.length){const E=m.map((A,D)=>{const G=String(A?.key??A?.id??A?.name??`b${D}`),ie=ae(String(A?.url??""));if(!ie)return null;const me=typeof A?.preview=="string"&&A.preview?ae(A.preview):"";return[G,{...A,url:ie,preview:me}]}).filter(A=>Array.isArray(A)&&A.length===2).reduce((A,[D,G])=>(A[D]=G,A),{});if(Object.keys(E).length)return E}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 ve=xe(),Fe=Object.keys(ve),je=e.ref(Fe.length?Fe[0]:"");async function U(){if(typeof window>"u")return null;const m=window;if(m[Nn])return m[Nn];const b=G=>{if(Array.from(document.styleSheets).some(Pe=>Pe?.href?.includes(G)))return;const me=document.createElement("link");me.rel="stylesheet",me.href=G,document.head.appendChild(me)},E=async()=>{const G=new Function("u","return import(u)"),ie=await G("https://esm.sh/maplibre-gl@3.6.2"),me=ie?.default??ie;if(!me)throw new Error("maplibre esm fallback failed");window.maplibregl=me,window.mapboxgl=me;const Pe=await G("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),nt=Pe?.default??Pe;if(!nt)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=nt},D=(async()=>{b("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),b("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await E();const G=window.maplibregl,ie=window.MapboxDraw;if(!G)throw new Error("maplibregl not available after load");if(!ie)throw new Error("MapboxDraw not available after load");return{maplibregl:G,MapboxDraw:ie}})().catch(G=>{throw delete m[Nn],G});return m[Nn]=D,D}function X(m){return{version:8,sources:{rasterSource:{type:"raster",tiles:[m],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let le=null,ue=null,P=null,oe=null,Ve=[],Ne=null,z=null,w=null,N=!1,I=!1,se=!1,be=null;function Le(){return{onSetup(){const m=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(m),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:m,startPoint:null,hasCoordinates:!1}},onMouseMove(m,b){if(!m.startPoint)return;const[E,A]=m.startPoint,D=b.lngLat.lng,G=b.lngLat.lat;m.rectangle.setCoordinates([[[E,A],[D,A],[D,G],[E,G],[E,A]]])},onClick(m,b){if(!m.startPoint){m.startPoint=[b.lngLat.lng,b.lngLat.lat],m.hasCoordinates=!0,m.rectangle.setCoordinates([[[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat],[b.lngLat.lng,b.lngLat.lat]]]);return}const[E,A]=m.startPoint,D=b.lngLat.lng,G=b.lngLat.lat;return Math.abs(E-D)>0&&Math.abs(A-G)>0?(m.rectangle.setCoordinates([[[E,A],[D,A],[D,G],[E,G],[E,A]]]),this.map.fire("draw.create",{features:[m.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[m.rectangle.id]})):(this.deleteFeature([m.rectangle.id],{silent:!0}),m.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(m){this.deleteFeature([m.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(m,b,E){const A=b.properties.id===m.rectangle.id;A&&!m.hasCoordinates||(b.properties.active=A?"true":"false",E(b))}}}const Ae=[{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 Ke(){const m=je.value;return!m||!ve[m]?.url?"":ve[m].url}function dt(m,b){return m?.id?String(m.id):m?.url?`${m.url}-${b}`:`layer-${b}`}function ut(m){const b=String(m?.url??"").trim();if(!b)return"";if(/^https?:\/\//i.test(b))return b;const E=window.location?.origin??"",A=b.replace(/^\/+/,"");return`${E}/${A}`}function Ie(m){m&&Se.value?.layerId!==m||(Se.value=null)}function lt(m,b={}){return m.popup===!1?[]:Array.isArray(m.popup)?m.popup.length?m.popup.map(E=>{const A=E?.field||E?.name;if(!A)return null;const D=b[A];return D==null||D===""?null:{key:E.label||A,value:String(D)}}).filter(Boolean):[]:Object.entries(b).slice(0,5).map(([E,A])=>({key:E,value:A==null?"—":String(A)}))}function Pt(m){if(!Array.isArray(m))return[];const b=A=>Array.isArray(A)&&A.length>=2&&Number.isFinite(Number(A[0]))&&Number.isFinite(Number(A[1])),E=A=>{if(!A.length)return A;const D=A[0],G=A[A.length-1];return!G||D[0]!==G[0]||D[1]!==G[1]?[...A,D]:A};if(m.length&&b(m[0])){const A=m.map(D=>[Number(D[0]),Number(D[1])]).filter(b);return A.length?[E(A)]:[]}return m.length&&Array.isArray(m[0])&&b(m[0][0])?m.map(D=>Array.isArray(D)?D.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(D=>D.length).map(E):m.length&&Array.isArray(m[0])&&Array.isArray(m[0][0])&&b(m[0][0][0])?m.flatMap(D=>Array.isArray(D)?D:[]).map(D=>Array.isArray(D)?D.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(D=>D.length).map(E):[]}function jn(m){const b=m.style??{},E=b.color??"#3b82f6";if(!b.colorAttr||!b.colorSet)return E;const A=Object.keys(b.colorSet);if(!A.length)return E;const D=["match",["to-string",["get",b.colorAttr]]];return A.forEach(G=>{D.push(String(G),b.colorSet?.[G]??E)}),D.push(E),D}function Ft(m){if(!P)return;m.handlers.forEach(E=>{try{P.off(E.type,E.layerId,E.handler)}catch{}}),m.handlers=[],[...m.layerIds,...m.boundsIds].forEach(E=>{P.getLayer(E)&&P.removeLayer(E)}),P.getSource(m.sourceId)&&P.removeSource(m.sourceId);const b=`vs-ov-bounds-src-${m.id}`;P.getSource(b)&&P.removeSource(b),Ie(m.id)}function cn(m,b){if(!P)return[];const E=`vs-ov-bounds-src-${b}`,A=`vs-ov-bounds-line-${b}`,D=m.bounds??T.value??te.value,G=Pt(D);if(!G.length)return[];const ie={type:"FeatureCollection",features:G.map(me=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:me}}))};return P.getSource(E)&&P.removeSource(E),P.addSource(E,{type:"geojson",data:ie}),P.addLayer({id:A,type:"line",source:E,paint:{"line-color":m.style?.stroke??m.style?.color??"#2563eb","line-width":m.style?.width??2,"line-opacity":m.style?.opacity??.8,"line-dasharray":[2,2]}}),[A]}function bt(m){if(!P)return;Ft(m);const b=m.config,E=ut(b);if(!E)return;const A=[],D=[];if(/\.v(?:m)?t(?:\?|$)/i.test(E)||/\.pbf(?:\?|$)/i.test(E)){const me=b.sourceLayer||b.layer||b.service_layer||b.dataset?.layer||b.id;P.addSource(m.sourceId,{type:"vector",tiles:[E]});const Pe=String(b.style?.type??"polygon").toLowerCase(),nt=jn(b),ft=b.style?.opacity??.5;if(Pe==="point"){const xt=`vs-ov-point-${m.id}`;P.addLayer({id:xt,type:"circle",source:m.sourceId,"source-layer":me,paint:{"circle-color":nt,"circle-radius":5,"circle-opacity":ft}}),A.push(xt)}else if(Pe==="polyline"||Pe==="line"){const xt=`vs-ov-line-${m.id}`;P.addLayer({id:xt,type:"line",source:m.sourceId,"source-layer":me,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":nt,"line-width":b.style?.width??2,"line-opacity":ft}}),A.push(xt)}else{const xt=`vs-ov-fill-${m.id}`,mn=`vs-ov-border-${m.id}`;P.addLayer({id:xt,type:"fill",source:m.sourceId,"source-layer":me,paint:{"fill-color":nt,"fill-opacity":ft}}),P.addLayer({id:mn,type:"line",source:m.sourceId,"source-layer":me,paint:{"line-color":b.style?.stroke??b.style?.color??"#2563eb","line-width":b.style?.width??1,"line-opacity":ft}}),A.push(xt,mn)}}else{P.addSource(m.sourceId,{type:"raster",tiles:[E],tileSize:256});const me=`vs-ov-raster-${m.id}`;P.addLayer({id:me,type:"raster",source:m.sourceId,paint:{"raster-opacity":b.style?.opacity??1}}),A.push(me)}A.forEach(me=>{const Pe=ft=>{if(!ft?.features?.length){Ie(m.id);return}const xt=ft.features[0]?.properties??{},mn=lt(m.config,xt);if(!mn.length){Ie(m.id);return}Se.value={layerId:m.id,entries:mn,point:{x:ft.point.x,y:ft.point.y}}},nt=()=>Ie(m.id);P.on("mousemove",me,Pe),P.on("mouseleave",me,nt),D.push({layerId:me,type:"mousemove",handler:Pe},{layerId:me,type:"mouseleave",handler:nt})}),m.layerIds=A,m.boundsIds=cn(m.config,m.id),m.handlers=D;const ie=m.visible?"visible":"none";[...m.layerIds,...m.boundsIds].forEach(me=>{P.getLayer(me)&&P.setLayoutProperty(me,"visibility",ie)})}function zt(){if(!P)return;const b={type:"FeatureCollection",features:Pt(T.value??te.value).map(E=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:E}}))};P.getSource(An)?P.getSource(An).setData(b):P.addSource(An,{type:"geojson",data:b}),P.getLayer(Mn)||P.addLayer({id:Mn,type:"line",source:An,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function vo(m){if(!P||s.value)return;const b=pe[m];if(!b)return;b.visible=!b.visible;const E=b.visible?"visible":"none";[...b.layerIds,...b.boundsIds].forEach(A=>{P.getLayer(A)&&P.setLayoutProperty(A,"visibility",E)}),Bt(),b.visible||Ie(m)}function Bt(){if(!P)return;const m=[],b=[],E=[],A=[];Ce.value.forEach(ie=>{const me=pe[ie];if(!me)return;const Pe=String(me.config?.url??""),nt=/\.v(?:m)?t(?:\?|$)/i.test(Pe),ft=/\.png(?:\?|$)/i.test(Pe);nt?E.push(...me.layerIds):ft?m.push(...me.layerIds):b.push(...me.layerIds),A.push(...me.boundsIds)}),[...m,...b,...E,...A].forEach(ie=>{P.getLayer(ie)&&P.moveLayer(ie)}),P.getLayer(Mn)&&P.moveLayer(Mn),(P.getStyle?.()?.layers??[]).map(ie=>String(ie?.id??"")).filter(ie=>ie.startsWith("gl-draw-")).forEach(ie=>{P.getLayer(ie)&&P.moveLayer(ie)})}function Eo(m){if(!ve[m]||(je.value=m,!P))return;const b=Ke();if(!b)return;const E=P.getCenter?.(),A=P.getZoom?.(),D=oe?.getAll?.();P.setStyle(X(b)),P.once("style.load",()=>{if(P&&(E&&Number.isFinite(A)&&P.jumpTo({center:[E.lng,E.lat],zoom:A}),zt(),Ce.value.forEach(G=>{const ie=pe[G];ie&&bt(ie)}),Bt(),D?.features?.length&&oe))try{D.features.forEach(G=>oe.add(G)),d.value=D.features.length}catch{d.value=0}})}function qt(m){return{type:"Feature",properties:{},geometry:m}}function at(m){if(!m)return null;try{return JSON.parse(JSON.stringify(m))}catch{return null}}function dn(m){if(!m)return null;const b=at(m.geometry);return b?{...m.id!==void 0?{id:m.id}:{},type:"Feature",properties:{...m.properties??{}},geometry:b}:null}function Dt(m){if(!m)return[];const b=(D,G)=>{if(!D?.type)return[];const ie={...G??{}};return D.type==="MultiPoint"&&Array.isArray(D.coordinates)?D.coordinates.map(me=>qt({type:"Point",coordinates:me})).map(me=>({...me,properties:ie})):D.type==="MultiLineString"&&Array.isArray(D.coordinates)?D.coordinates.map(me=>qt({type:"LineString",coordinates:me})).map(me=>({...me,properties:ie})):D.type==="MultiPolygon"&&Array.isArray(D.coordinates)?D.coordinates.map(me=>qt({type:"Polygon",coordinates:me})).map(me=>({...me,properties:ie})):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?D.geometries.flatMap(me=>b(me,ie)):[{type:"Feature",properties:ie,geometry:at(D)}]},E=D=>{if(!D)return null;if(D.type==="Feature"){const G=dn(D);return G?b(G.geometry,G.properties):null}return D.geom?.type&&Array.isArray(D.geom.coordinates)?b({type:D.geom.type,coordinates:D.geom.coordinates},D.properties??{}):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?b(D,D.properties??{}):typeof D.type=="string"&&Array.isArray(D.coordinates)?b(at(D),D.properties??{}):null};if(m.type==="FeatureCollection")return(m.features??[]).flatMap(E).filter(Boolean);if(Array.isArray(m))return m.flatMap(D=>D?.type==="FeatureCollection"?Dt(D):[E(D)]).flat().filter(Boolean);const A=E(m);return A?Array.isArray(A)?A:[A]:[]}function j(m){if(!m.length)return null;if(!a.value)return at(m[0]?.geometry??null);const b=m.map(G=>at(G?.geometry)).filter(Boolean);return b.every(G=>G?.type==="Point")?{type:"MultiPoint",coordinates:b.map(G=>G.coordinates)}:b.every(G=>G?.type==="LineString")?{type:"MultiLineString",coordinates:b.map(G=>G.coordinates)}:b.every(G=>G?.type==="Polygon")?{type:"MultiPolygon",coordinates:b.map(G=>G.coordinates)}:{type:"GeometryCollection",geometries:b}}function ee(m){if(!m)return"__null__";try{return JSON.stringify(m)}catch{return"__invalid__"}}function fe(m,b){if(!Array.isArray(m)||!Array.isArray(b)||m.length<2||b.length<2)return!1;const E=1e-12;return Math.abs(Number(m[0])-Number(b[0]))<E&&Math.abs(Number(m[1])-Number(b[1]))<E}function $e(m,b){if(!Array.isArray(m)||m.length<4)return null;const A=fe(m[0],m[m.length-1])?m.slice(0,-1):m.slice();return!Number.isInteger(b)||b<0||b>=A.length||A.length<=3||(A.splice(b,1),A.length<3)?null:[...A,[...A[0]]]}function Oe(m,b){if(!Array.isArray(m)||m.length<2||!Number.isInteger(b)||b<0||b>=m.length||m.length<=2)return null;const E=m.slice();return E.splice(b,1),E.length<2?null:E}function We(m,b){const E=at(m);if(!E||!Array.isArray(b))return null;if(E.type==="LineString"){const[A]=b,D=Oe(E.coordinates,A);return D?(E.coordinates=D,E):null}if(E.type==="MultiLineString"){const[A,D]=b,G=E.coordinates?.[A],ie=Oe(G,D);return ie?(E.coordinates[A]=ie,E):null}if(E.type==="Polygon"){const[A,D]=b,G=E.coordinates?.[A],ie=$e(G,D);return ie?(E.coordinates[A]=ie,E):null}if(E.type==="MultiPolygon"){const[A,D,G]=b,ie=E.coordinates?.[A]?.[D],me=$e(ie,G);return me?(E.coordinates[A][D]=me,E):null}return null}function Re(m){return m?m.split(".").map(b=>Number(b)).filter(b=>Number.isInteger(b)&&b>=0):[]}function tt(m){return!oe||!m?null:typeof oe.get=="function"?oe.get(m)??null:oe.getAll?.()?.features?.find(E=>String(E?.id??"")===m)??null}function pt(m){const b=m?.properties?.id??m?.id;return b==null||b===""?null:String(b)}function mt(m){if(!P||!m)return null;const b=[[m.x-8,m.y-8],[m.x+8,m.y+8]],A=P.queryRenderedFeatures(b).find(D=>{const G=String(D?.properties?.meta??"");return G&&G!=="feature"?!1:!!pt(D)});return pt(A)}function kt(m,b){if(!oe||!m||!b.length)return;const E=tt(m);if(!E?.geometry)return;const A=We(E.geometry,b);if(!A)return;const D={...E,id:E.id??m,geometry:A};re=!0,he=!0;try{oe.delete(m),oe.add(D)}finally{he=!1,re=!1}Tt(),_t()}function st(m){if(!P||!oe||s.value||k.isRulerActive.value||u.value!=="edit")return;const b=m?.point;if(!b)return;const E=[[b.x-8,b.y-8],[b.x+8,b.y+8]],D=P.queryRenderedFeatures(E).find(ie=>ie?.properties?.meta==="vertex"&&ie?.properties?.parent&&ie?.properties?.coord_path);if(!D)return;m?.originalEvent?.preventDefault?.(),m?.originalEvent?.stopPropagation?.();const G=Re(String(D.properties.coord_path));G.length&&kt(String(D.properties.parent),G)}function un(m){const b=Jr(m);if(!b)return null;const[[E,A],[D,G]]=b;return{lat:(A+G)/2,lng:(E+D)/2}}function Yr(m){if(!Array.isArray(m)||m.length<3)return 0;const b=(A,D)=>{const G=A*2003750834e-2/180,ie=Math.log(Math.tan((90+D)*Math.PI/360))/(Math.PI/180);return[G,ie*2003750834e-2/180]};let E=0;for(let A=0;A<m.length-1;A+=1){const[D,G]=b(Number(m[A][0]),Number(m[A][1])),[ie,me]=b(Number(m[A+1][0]),Number(m[A+1][1]));E+=D*me-ie*G}return Math.abs(E/2)/1e6}function V0(m){if(!m?.type||!m?.coordinates)return null;if(m.type==="Polygon"){const b=m.coordinates?.[0];return Array.isArray(b)?Yr(b):null}return m.type==="MultiPolygon"?m.coordinates.reduce((b,E)=>{const A=E?.[0];return Array.isArray(A)?b+Yr(A):b},0):null}function Bo(m){if(!m){p.value=null;return}const b=un(m);if(!b){p.value=null;return}p.value={type:String(m.type??"Feature"),center:b,areaKm2:V0(m)}}function _o(m){if(!m){const A=Ve[Ve.length-1],D=at(A?.geometry??null);Ne=D,Bo(D);return}const b=Ve.find(A=>String(A?.id??"")===String(m))??null,E=at(b?.geometry??null);Ne=E,Bo(E)}function Vo(m){f.value=(m??[]).map((b,E)=>{const A=String(b?.id??`feature-${E+1}`),D=Xr(String(b?.geometry?.type??"Feature"));return{id:A,label:`${D} ${E+1}`}})}function Xr(m){switch(String(m)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(m||"Невідомо")}}function Zr(m,b){if(!Array.isArray(m)||!Array.isArray(b)||m.length!==2||b.length!==2)return!1;const E=1e-9;return Math.abs(Number(m[0])-Number(b[0]))<E&&Math.abs(Number(m[1])-Number(b[1]))<E}function Jr(m){if(!m)return null;let b=1/0,E=1/0,A=-1/0,D=-1/0;const G=ie=>{if(Array.isArray(ie)){if(ie.length>=2&&Number.isFinite(ie[0])&&Number.isFinite(ie[1])){const me=Number(ie[0]),Pe=Number(ie[1]);b=Math.min(b,me),E=Math.min(E,Pe),A=Math.max(A,me),D=Math.max(D,Pe);return}ie.forEach(G)}};return G(m.coordinates),!Number.isFinite(b)||!Number.isFinite(E)?null:[[b,E],[A,D]]}function Qr(m){if(!P||!m)return;const b=Jr(m);if(!b)return;const[[E,A],[D,G]]=b;if(E===D&&A===G){P.easeTo({center:[E,A],zoom:Math.max(O.value,14)});return}P.fitBounds(b,{padding:30,duration:250,maxZoom:18})}function So(){if(!oe){d.value=0;return}const m=oe.getAll();d.value=m?.features?.length??0}function pn(){if(!oe)return null;const b=oe.getAll?.()?.features??[],E=G=>!!G&&b.some(ie=>String(ie?.id??"")===String(G??"")),A=oe.getSelectedIds?.();if(Array.isArray(A)&&A.length>0){const G=A[0];return G!=null?String(G):null}if(E(w))return String(w);if(!b.length)return null;const D=a.value?b[b.length-1]:b[0];return D?.id!==void 0&&D?.id!==null?String(D.id):null}function Tt(){if(!oe)return;const m=oe.getAll();if(d.value=m?.features?.length??0,!m?.features?.length){Ve=[],f.value=[],Ne=null,w=null,p.value=null,he||(z="__null__",r("update:modelValue",null));return}const b=(m.features??[]).map(dn).filter(Boolean);if(Ve=b,Vo(b),w=pn(),_o(w),!he){const E=j(b);z=ee(E),r("update:modelValue",E)}}function Un(){if(!oe)return;(oe.getAll()?.features||[]).forEach(b=>oe.delete(b.id)),f.value=[],So()}function Hn(m){if(!oe)return;const b=Dt(m),E=a.value?b:b.slice(0,1);he=!0,Un(),E.forEach(G=>{try{oe.add(G)}catch{}}),he=!1,Ve=(oe.getAll?.()?.features??E).map(dn).filter(Boolean),Vo(Ve),w=null;const D=at(Ve[Ve.length-1]?.geometry??null);Ne=at(D),So(),Bo(D),D&&(Qr(D),s.value||_t())}function S0(){oe&&(he=!0,Un(),Ve.forEach(m=>{try{oe.add(m)}catch{}}),he=!1,Vo(Ve),So(),_o(w))}function Kt(){if(oe){try{oe.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""}}function qn(m){if(s.value||!oe)return;k.isRulerActive.value&&k.closeRuler(),se=!0,Kt(),u.value=m;const b=m==="marker"?"draw_point":m==="polyline"?"draw_line_string":m==="rectangle"?"draw_rectangle":"draw_polygon";a.value||(he=!0,Un(),he=!1);try{oe.changeMode(b)}catch{u.value=""}finally{requestAnimationFrame(()=>{se=!1})}}function _t(m){if(s.value||!oe||!oe.getAll()?.features?.length)return;const E=m||pn();if(E)try{oe.changeMode("direct_select",{featureId:E}),w=E,_o(w),u.value="edit"}catch{u.value=""}}function $0(m){s.value||!oe||!m||_t(m)}function N0(){if(!(s.value||!oe)){if(a.value){const m=pn();if(m)try{N=!0,oe.delete(m),N=!1,Tt();const b=pn();b?_t(b):Kt();return}catch{N=!1}}Kt(),Un(),Ve=[],f.value=[],w=null,z="__null__",p.value=null,r("update:modelValue",null)}}function A0(){s.value||!Ne||Qr(Ne)}function M0(m){if(!P||!le)return;const b=[m[1],m[0]];be||(be=new le.Marker({color:"#2563eb"})),be.setLngLat(b).addTo(P),P.easeTo({center:b,zoom:13,duration:250})}function F0(){s.value||J.value?.click()}function D0(){s.value||(F.value=!F.value)}function el(m){if(!F.value)return;const b=de.value;b&&!b.contains(m.target)&&(F.value=!1)}function T0(){F.value=!1,F0()}function L0(){s.value||(ne.value=[],F.value=!1,Y.value=!0)}function I0(){Y.value=!1,ne.value=[]}function O0(){if(s.value||!oe)return;const m=Ad(W.value.coordinates??"",W.value.format||"decimal",W.value.order||"lat-lon");if(!m.ok){ne.value=m.errors,R0(m.errors);return}ne.value=[],Hn({type:"Polygon",coordinates:[m.ring]}),Tt(),Y.value=!1,m.wasClosedAutomatically&&ye.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function R0(m){if(!m.length)return;const b=5;m.slice(0,b).forEach(E=>{const A=E.line>0?`Рядок ${E.line}`:"Загальна помилка";ye.notify({type:"warning",title:"Імпорт координат",message:`${A} — ${E.message}`})}),m.length>b&&ye.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${m.length-b}`})}function P0(m){if(s.value||!oe)return;F.value=!1;const b=m.target,E=b.files?.[0];if(!E)return;const A=new FileReader;A.onload=()=>{try{const D=JSON.parse(String(A.result));if(!Dt(D).length){ye.notify({type:"warning",title:"Імпорт файлу",message:"Файл не містить коректний GeoJSON-обʼєкт."});return}Hn(D),Tt()}catch{ye.notify({type:"error",title:"Імпорт файлу",message:"Не вдалося прочитати файл. Перевірте формат GeoJSON/JSON."})}finally{b.value=""}},A.onerror=()=>{ye.notify({type:"error",title:"Імпорт файлу",message:"Помилка читання файлу."}),b.value=""},A.readAsText(E)}function z0(){if(s.value||!oe)return;const m=oe.getAll(),b=new Blob([JSON.stringify(m,null,2)],{type:"application/json"}),E=URL.createObjectURL(b),A=document.createElement("a");A.href=E,A.download="data.geojson",A.click(),URL.revokeObjectURL(E)}return e.onMounted(async()=>{if(window.addEventListener("click",el,!0),!i.value)return;const m=await U();le=m.maplibregl,ue=m.MapboxDraw;const b=Ke();b&&(P=new le.Map({container:i.value,style:X(b),center:[M.value[0],M.value[1]],zoom:O.value,attributionControl:!1}),y.value=P,P.addControl(new le.NavigationControl({showCompass:!0}),"bottom-right"),P.on("load",()=>{if(!(!ue||!P)){if(oe=new ue({displayControlsDefault:!1,modes:{...ue.modes,draw_rectangle:Le()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:Ae}),P.addControl(oe),P.on("click",E=>{if(k.isRulerActive.value){const D=E?.lngLat;if(!D)return;h.value?.addPoint?.({lat:D.lat,lng:D.lng});return}if(!oe||s.value||u.value!=="edit")return;const A=mt(E?.point);!A||A===w||requestAnimationFrame(()=>{!oe||s.value||_t(A)})}),P.on("draw.create",()=>{if(oe&&!k.isRulerActive.value){if(!a.value){const E=oe.getAll();if(E.features.length>1){const A=E.features[E.features.length-1];he=!0,E.features.slice(0,-1).forEach(D=>oe.delete(D.id)),he=!1,A&&(he=!0,oe.add(A),he=!1)}}Tt(),_t()}}),P.on("draw.update",E=>{if(I||k.isRulerActive.value)return;const A=Array.isArray(E?.features)?E.features:[],D=E?.action==="move"&&A.length>0&&A.every(G=>G?.geometry?.type==="Point");if(E?.action==="move"){if(D){Tt();return}if(I=!0,S0(),I=!1,u.value==="edit"){const G=pn(),ie=G?tt(G):oe?.getAll?.()?.features?.[0];if(ie?.id)try{oe.changeMode("direct_select",{featureId:ie.id}),w=String(ie.id)}catch{u.value=""}}return}Tt()}),P.on("draw.delete",()=>{re||N||k.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle"||(Tt(),oe?.getAll?.()?.features?.length||(w=null),u.value="",Kt())}),P.on("draw.selectionchange",E=>{if(!oe||I||k.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle")return;const A=E?.features?.[0]?.id!==void 0&&E?.features?.[0]?.id!==null?String(E.features[0].id):null;if(!s.value&&A){if(u.value==="edit"&&w===A)return;requestAnimationFrame(()=>{!oe||s.value||_t(A)});return}const D=oe.getSelectedIds?.(),G=Array.isArray(D)&&D.length>0?String(D[0]):null;if(!s.value&&G){if(u.value==="edit"&&w===G)return;requestAnimationFrame(()=>{!oe||s.value||_t(G)});return}try{oe.changeMode("simple_select",{featureIds:[]})}catch{}}),Q.value!==void 0){const E=Q.value;Q.value=void 0,requestAnimationFrame(()=>{oe&&Hn(E)})}zt(),Ce.value.forEach(E=>{const A=pe[E];A&&bt(A)}),Bt()}}),P.on("contextmenu",st),P.on("zoomend",()=>{P&&(O.value=P.getZoom())}))}),e.onUnmounted(()=>{k.isRulerActive.value&&k.closeRuler(),window.removeEventListener("click",el,!0),Object.values(pe).forEach(m=>{P&&Ft(m)}),Ie(),be?.remove&&be.remove(),be=null,P?.remove&&P.remove(),P=null,oe=null,y.value=null}),e.watch(()=>o.modelValue,m=>{if(!oe){Q.value=m;return}const b=j((a.value?Dt(m):Dt(m).slice(0,1))||[]),E=ee(b);if(z&&E===z){z=null;return}z=null,Hn(m)},{deep:!0}),e.watch(()=>V.value,m=>{const b=Array.isArray(m)?m:[],E=[],A=new Set;b.forEach((D,G)=>{if(!D)return;const ie=dt(D,G);E.push(ie),A.add(ie);const me={...D,id:ie},Pe=pe[ie],nt=Pe?.visible??!!me.visible;Pe&&P&&Ft(Pe),pe[ie]={id:ie,config:me,visible:nt,sourceId:`vs-ov-src-${ie}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(pe).forEach(D=>{if(A.has(D))return;const G=pe[D];G&&P&&Ft(G),delete pe[D]}),Ce.value=E,P&&(Ce.value.forEach(D=>{const G=pe[D];G&&bt(G)}),Bt())},{immediate:!0,deep:!0}),e.watch(()=>T.value,()=>{P&&(zt(),Ce.value.forEach(m=>{const b=pe[m];b&&bt(b)}),Bt())},{deep:!0}),e.watch(()=>R.value,async m=>{if(te.value=[],!m){P&&(zt(),Ce.value.forEach(b=>{const E=pe[b];E&&bt(E)}),Bt());return}try{const b=await fetch(`https://data.gki.com.ua/api-user/atu/${m}`);if(!b?.ok)return;const A=(await b.json())?.geometry?.coordinates;Array.isArray(A)&&A.length&&(te.value=A)}catch(b){console.error("Failed to fetch KATOTTG bounds",b)}finally{if(!P)return;zt(),Ce.value.forEach(b=>{const E=pe[b];E&&bt(E)}),Bt()}},{immediate:!0}),e.watch(()=>_.value,m=>{if(!Array.isArray(m)||m.length!==2)return;const b=[Number(m[0]),Number(m[1])];if(Zr(M.value,b)||(M.value=[...b],!P))return;const E=P.getCenter?.();E&&Zr([E.lng,E.lat],M.value)||P.easeTo({center:[M.value[0],M.value[1]]})},{deep:!0}),e.watch(()=>$.value,m=>{typeof m=="number"&&(O.value=m,P&&P.setZoom(m))}),e.watch(s,m=>{m&&Kt()}),e.watch(d,m=>{if(m>0){s.value||_t();return}se||Kt()}),e.watch(c,()=>{setTimeout(()=>{P?.resize&&P.resize()},50)}),(m,b)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!c.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:c.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:i,class:"w-full h-[calc(100%-28px)]"},null,512),Z.value.search||Z.value.import||Z.value.export?(e.openBlock(),e.createElementBlock("div",Wu,[Z.value.search?(e.openBlock(),e.createBlock(Zd,{key:0,onGoToCoordinates:M0})):e.createCommentVNode("",!0),Z.value.import||Z.value.export?(e.openBlock(),e.createElementBlock("div",Gu,[e.createElementVNode("div",Yu,[Z.value.import?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:de,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:D0,disabled:s.value},[b[8]||(b[8]=e.createTextVNode(" Імпорт ",-1)),e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":F.value}])},null,8,["class"])],8,Xu),F.value?(e.openBlock(),e.createElementBlock("div",Zu,[Z.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:T0}," З файлу ")):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:L0}," З координат ")])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),Z.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:z0,disabled:s.value||d.value===0}," Експорт ",8,Ju)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:J,type:"file",onChange:P0,accept:".json,.geojson",class:"hidden",disabled:s.value},null,40,Qu)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(ye.VsModal),{visible:Y.value,"onUpdate:visible":b[1]||(b[1]=E=>Y.value=E),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(rt,{schema:ce,values:W.value,"onUpdate:values":b[0]||(b[0]=E=>W.value=E)},null,8,["values"]),e.createElementVNode("div",ep,[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:I0}," Скасувати "),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:O0,disabled:s.value}," Побудувати ",8,tp)])]),_:1},8,["visible"]),e.createElementVNode("div",np,[e.createElementVNode("div",op,[Z.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="marker"}]),title:"Point",onClick:b[2]||(b[2]=E=>qn("marker")),disabled:s.value},[e.createVNode(e.unref(q.MapPin),{class:"h-4 w-4"})],10,rp)):e.createCommentVNode("",!0),Z.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polyline"}]),title:"Line",onClick:b[3]||(b[3]=E=>qn("polyline")),disabled:s.value},[e.createVNode(gd)],10,lp)):e.createCommentVNode("",!0),Z.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polygon"}]),title:"Polygon",onClick:b[4]||(b[4]=E=>qn("polygon")),disabled:s.value},[e.createVNode(xd)],10,ap)):e.createCommentVNode("",!0),Z.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="rectangle"}]),title:"Rectangle",onClick:b[5]||(b[5]=E=>qn("rectangle")),disabled:s.value},[e.createVNode(Ed)],10,sp)):e.createCommentVNode("",!0),Z.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(k).isRulerActive.value}]),title:"Ruler",onClick:g},[e.createVNode(e.unref(q.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:b[6]||(b[6]=E=>c.value=!c.value),title:"Full Screen"},[e.createVNode(e.unref(q.Maximize),{class:"h-4 w-4"})])])]),Z.value.ruler&&e.unref(k).isRulerActive.value?(e.openBlock(),e.createBlock(Hu,{key:1,ref_key:"rulerPanelRefEl",ref:h,onClose:b[7]||(b[7]=E=>e.unref(k).closeRuler()),onTabChange:e.unref(k).onRulerTabChange,onPointsChange:e.unref(k).onRulerPointsChange,onShapeClosedChange:e.unref(k).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),Z.value.ruler&&e.unref(k).isRulerActive.value&&e.unref(k).hasRulerPoints.value?(e.openBlock(),e.createBlock(qu,{key:2,map:y.value,points:e.unref(k).rulerPoints.value,"is-shape-closed":e.unref(k).rulerShapeClosed.value,"label-mode":e.unref(k).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),De.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(Me.value)},[e.createElementVNode("div",ip,[e.createElementVNode("dl",cp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(De.value,E=>(e.openBlock(),e.createElementBlock("div",{key:`${E.key}-${E.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",dp,e.toDisplayString(E.key),1),e.createElementVNode("dd",up,e.toDisplayString(E.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",pp,[e.createElementVNode("div",mp,[e.createVNode($d,{basemaps:e.unref(ve),onOnLayerChange:Eo},null,8,["basemaps"]),ke.value.length?(e.openBlock(),e.createElementBlock("div",fp,[b[9]||(b[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",hp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(ke.value,E=>(e.openBlock(),e.createElementBlock("label",{key:E.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:E.visible,disabled:s.value,onChange:A=>vo(E.id)},null,40,gp),e.createElementVNode("span",yp,e.toDisplayString(E.config.title||E.config.name||E.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",bp,[f.value.length||p.value?(e.openBlock(),e.createElementBlock("div",kp,[e.createElementVNode("div",xp,[e.createElementVNode("div",wp,[b[10]||(b[10]=e.createTextVNode(" Тип: ",-1)),f.value.length<=1?(e.openBlock(),e.createElementBlock("span",Cp,e.toDisplayString(p.value?Xr(p.value.type):f.value[0]?.label||"—"),1)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(f.value,(E,A)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:E.id},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["font-bold underline-offset-2",E.id===e.unref(w)?"text-blue-700 underline":"text-gray-700 hover:text-blue-700 hover:underline"]),onClick:D=>$0(E.id),disabled:s.value},e.toDisplayString(E.label),11,vp),A<f.value.length-1?(e.openBlock(),e.createElementBlock("span",Ep,", ")):e.createCommentVNode("",!0)],64))),128))])]),e.createElementVNode("div",Bp,[e.createElementVNode("div",_p,[b[11]||(b[11]=e.createTextVNode(" Центр: ",-1)),p.value?(e.openBlock(),e.createElementBlock("b",Vp,e.toDisplayString(p.value.center.lng.toFixed(5))+", "+e.toDisplayString(p.value.center.lat.toFixed(5)),1)):(e.openBlock(),e.createElementBlock("b",Sp,"—"))]),p.value&&p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",$p,[b[12]||(b[12]=e.createTextVNode(" Площа: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",Np,[...b[13]||(b[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:A0,disabled:s.value},[e.createVNode(e.unref(q.ZoomIn),{class:"h-3 w-3"})],8,Ap),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:N0,disabled:s.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Mp)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-893cf482"]]),Fp=["data-focus"],Dp={class:"flex items-center"},Tp={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},Lp=["onClick","aria-label"],Ip={key:0,class:"absolute text-gray-500 truncate pl-2"},Op={class:"flex-1 min-w-[2px]"},Rp=["placeholder"],Pp={class:"flex items-center shrink-0"},zp=["disabled"],ar=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(n,{emit:t}){const o=n,r=t;Ge(o.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),c=e.ref(!1),i=e.ref(""),d=e.useModel(n,"modelValue"),u=e.computed(()=>o.placeholder||"Add tag…"),p=e.computed(()=>d.value?.length===0&&i.value===""),f=e.computed(()=>!o.disabled&&d.value?.length>0),y=e.computed(()=>o.disabled),h=async()=>{y.value||await e.nextTick(()=>s.value?.focus())},k=K=>{const L=K.trim();L!==""&&(!d.value||!Array.isArray(d.value)?d.value=[L]:o.unique?d.value.includes(L)||(d.value=[...d.value,L]):d.value=[...d.value,L],i.value="")},g=()=>{const K=i.value;K.trim()!==""&&k(K),i.value=""},v=K=>{const L=d.value.slice();L.splice(K,1),r("update:modelValue",L)},x=()=>{r("update:modelValue",[])},C=()=>{y.value||(c.value=!0)},S=()=>{c.value=!1,!y.value&&g()},H=K=>{const{key:L}=K;L==="Enter"?(K.preventDefault(),g()):L==="Backspace"&&i.value===""&&d.value.length>0&&v(d.value.length-1)};return(K,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",o.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",c.value?"border-blue-500 ring-1 ring-blue-500":"",y.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":c.value?"true":"false",onClick:h},[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,_)=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",Dp,[e.createElementVNode("div",Tp,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($=>v(_),["stop"]),"aria-label":`Remove ${B}`},[e.createVNode(e.unref(q.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Lp)]))),128)),p.value?(e.openBlock(),e.createElementBlock("div",Ip,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Op,[y.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=>i.value=B),onFocus:C,onBlur:S,onKeydown:H,placeholder:d.value&&d.value.length?"":void 0},null,40,Rp)),[[e.vModelText,i.value]])])],512),e.createElementVNode("div",Pp,[f.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:y.value,onClick:e.withModifiers(x,["stop"])},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,zp)):e.createCommentVNode("",!0)])],10,Fp)],2)],512))}}),jp={class:"relative flex gap-1 bg-white w-full"},Up=["disabled","placeholder"],sr=Be(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(n){const t=e.inject("values"),o=n,r=e.useModel(n,"modelValue");function l(s){const c={а:"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(i=>c[i]||i).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[o.parent||""]?.toString(),c=l(s);r.value=c.toString()};return(s,c)=>(e.openBlock(),e.createElementBlock("div",jp,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:n.disabled,placeholder:n.placeholder,"onUpdate:modelValue":c[0]||(c[0]=i=>r.value=i),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,Up),[[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-cb7b2b74"]]),Hp={class:"relative flex gap-1 bg-white w-full"},qp=["disabled","placeholder"],Kp=["disabled"],Wp={key:0},Gp={key:1},ir=Be(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(n){const t=n,o=e.useModel(n,"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}`},c=async()=>{if(!a.value||r.value)return;const d=s();if(d){r.value=!0;try{const p=await(await fetch(d)).text();o.value=p}finally{r.value=!1}}},i=()=>{l.value&&(o.value||c())};return e.onMounted(()=>{i()}),e.watch(()=>[t.table,t.code,t.init],()=>{i()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",Hp,[e.withDirectives(e.createElementVNode("input",{disabled:n.disabled,placeholder:n.placeholder,"onUpdate:modelValue":u[0]||(u[0]=p=>o.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,qp),[[e.vModelText,o.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||n.disabled||!a.value,onClick:c},[r.value?(e.openBlock(),e.createElementBlock("span",Gp,"...")):(e.openBlock(),e.createElementBlock("span",Wp,"Gen"))],8,Kp)]))}}),[["__scopeId","data-v-8f88fb66"]]),Yp={class:"w-full"},Xp={ref:"sortableContainer",class:"flex flex-col gap-1"},Zp=["onDragstart","onDrop"],Jp={class:"cursor-move",type:"button"},Qp={class:"w-1/3"},em={class:"w-2/3"},tm=["onClick"],nm={key:0,class:"text-[14px] text-gray-700"},om={class:"mt-2 w-full flex items-center"},rm=["disabled"],cr=Be(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(n,{emit:t}){const o=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,r=e.inject("values"),l=n,a=t,s=l.addButtonText??"Додати",c=l.ignore??[],i=e.ref([]),d=e.ref(null);(()=>{const g=l.parent&&r?.value?.[l.parent]||l.modelValue||{};i.value=Object.entries(g).filter(([v])=>!c.includes(v)).map(([v,x])=>({id:o("key-value-"),key:v,value:x}))})();function p(g){d.value=g}function f(g){if(d.value===null||d.value===g)return;const v=i.value.splice(d.value,1)[0];i.value.splice(g,0,v),d.value=null}const y=e.computed(()=>i.value.some(g=>g.key&&!g.value||!g.key&&g.value)),h=()=>{i.value.push({id:o("key-value-"),key:"",value:""})},k=g=>{i.value=i.value.filter(v=>v.id!==g)};return e.watch(i,g=>{const v={};g.forEach(C=>{C.key&&C.value!==void 0&&(v[C.key]=C.value)});const x={};c.length&&c.forEach(C=>{x[C]=l.parent?r?.value?.[l.parent]?.[C]:void 0}),r?.value&&l.parent&&(r.value[l.parent]={...x,...v}),a("update:modelValue",v)},{deep:!0}),(g,v)=>(e.openBlock(),e.createElementBlock("div",Yp,[e.createElementVNode("div",Xp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(x,C)=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===C}]),draggable:"true",onDragstart:S=>p(C),onDragover:v[0]||(v[0]=e.withModifiers(()=>{},["prevent"])),onDrop:S=>f(C)},[e.createElementVNode("button",Jp,[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",Qp,[e.createVNode(jt,{modelValue:x.key,"onUpdate:modelValue":S=>x.key=S,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",em,[e.createVNode(jt,{modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:S=>k(x.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(q.X),{class:"h-4 w-4"})],8,tm)],42,Zp))),128))],512),i.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",nm," Дані для відображення відсутні ")),e.createElementVNode("div",om,[e.createElementVNode("button",{type:"button",onClick:h,disabled:y.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(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(e.unref(s)),1)],8,rm)])]))}}),[["__scopeId","data-v-ac321a0f"]]),lm={class:"w-full"},am={ref:"sortableContainer",class:"flex flex-col gap-1"},sm=["onDragstart","onDrop"],im=["disabled"],cm={class:"flex-1"},dm=["onClick","disabled"],um={key:0,class:"text-[14px] text-gray-700"},pm={class:"mt-2 w-full flex items-center"},mm=["disabled"],dr=Be(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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),c=e.computed(()=>t.addButtonText??"Додати");let i=!1;const d=g=>`${g}-${Math.random().toString(36).substring(2,15)}`,u=g=>{const v=g??o.value??[];r.value=v.map((x,C)=>({id:r.value[C]?.id??d("text-array"),value:x??""}))};u(),e.watch(()=>o.value,g=>{if(i){i=!1;return}u(g||[])},{deep:!0}),e.watch(r,g=>{i=!0,o.value=g.map(v=>v.value).filter(v=>v!=null&&v!=="")},{deep:!0});const p=e.computed(()=>a.value||r.value.some(g=>!g.value));function f(){p.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function y(g){a.value||(r.value=r.value.filter(v=>v.id!==g))}function h(g){a.value||(l.value=g)}function k(g){if(a.value||l.value===null||l.value===g)return;const v=[...r.value],[x]=v.splice(l.value,1);v.splice(g,0,x),r.value=v,l.value=null}return(g,v)=>(e.openBlock(),e.createElementBlock("div",lm,[e.createElementVNode("div",am,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(x,C)=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":l.value===C}]),draggable:"true",onDragstart:S=>h(C),onDragover:v[0]||(v[0]=e.withModifiers(()=>{},["prevent"])),onDrop:S=>k(C)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})],8,im),e.createElementVNode("div",cm,[n.inputType==="text"?(e.openBlock(),e.createBlock(jt,{key:0,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),n.inputType==="tel"?(e.openBlock(),e.createBlock(Jn,{key:1,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),n.inputType==="email"?(e.openBlock(),e.createBlock(Zn,{key:2,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),n.inputType==="mask"?(e.openBlock(),e.createBlock(hn,{key:3,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,mask:n.mask,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:S=>y(x.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(q.X),{class:"h-4 w-4"})],8,dm)],42,sm))),128))],512),r.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",um," Дані для відображення відсутні ")),e.createElementVNode("div",pm,[e.createElementVNode("button",{type:"button",onClick:f,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(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(c.value),1)],8,mm)])]))}}),[["__scopeId","data-v-972a598a"]]),fm={class:"flex items-center gap-2 w-full"},hm=["disabled"],gm=["disabled"],ur=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(n,{emit:t}){const o=n,{inputClass:r}=Ge(o.style),l=t,a=e.computed({get:()=>o.modelValue||"#000000",set:c=>l("update:modelValue",c)}),s=e.computed(()=>!!o.disabled);return(c,i)=>(e.openBlock(),e.createElementBlock("div",fm,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":i[0]||(i[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]",[n.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,hm),[[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":i[1]||(i[1]=d=>a.value=d),disabled:s.value},null,8,gm),[[e.vModelText,a.value]])]))}}),ym={class:"flex items-center gap-2 w-full"},bm=["min","max","step","disabled"],km=["value","min","max","step","disabled"],pr=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(n,{emit:t}){const o=n,{inputClass:r}=Ge(o.style),l=t,a=u=>{const p=Number(u),f=Number(o.min),y=Number(o.max);return Number.isNaN(p)?f:Math.min(y,Math.max(f,p))},s=e.computed({get:()=>a(o.modelValue??o.min),set:u=>l("update:modelValue",a(u))}),c=u=>{const p=u.target,f=a(p.value);p.value=String(f),l("update:modelValue",f)},i=u=>{Number(o.min)>=0&&u.key==="-"&&u.preventDefault()},d=e.computed(()=>!!o.disabled);return(u,p)=>(e.openBlock(),e.createElementBlock("div",ym,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":p[0]||(p[0]=f=>s.value=f),min:n.min,max:n.max,step:n.step,disabled:d.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[n.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")])},null,10,bm),[[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:n.min,max:n.max,step:n.step,onInput:c,onKeydown:i,disabled:d.value},null,40,km)]))}}),xm=["placeholder","disabled","name"],wm=["type","value","onInput","placeholder","disabled"],Cm=["onClick"],mr=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(n){const t=n,o=e.ref(t.count),r=e.computed(()=>t.limit),{inputClass:l}=Ge(t.style),a=e.useModel(n,"modelValue"),s=e.computed(()=>!!t.disabled),c=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const k=a.value?.length??0;k<o.value&&(a.value=[...a.value??[],...Array(o.value-k)])});const i=e.ref({}),d=e.ref({});function u(k,g){k&&(i.value[g]=k)}async function p(k,g){if(!k||t.inputType!=="mask")return;const{default:v}=await Promise.resolve().then(()=>Pn);d.value[g]&&d.value[g].destroy(),d.value[g]=v(k,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[g].on("accept",()=>{const x=[...a.value||[]];x[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=x}),d.value[g].on("complete",()=>{const x=[...a.value||[]];x[g]=t.unmask?d.value[g].unmaskedValue:d.value[g].value,a.value=x}),a.value?.[g]&&(d.value[g].value=a.value[g])}function f(k,g){if(s.value)return;const v=k.target.value??null,x=[...a.value];x[g]=t.inputType==="text"?v:Number(v),a.value=x}function y(){o.value+=1;const k=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,k],t.inputType==="mask"&&setTimeout(()=>{const g=o.value-1;i.value[g]&&p(i.value[g],g)},0)}function h(k){if(o.value>1){d.value[k]&&(d.value[k].destroy(),delete d.value[k]),o.value-=1,a.value=a.value.filter((v,x)=>x!==k);const g={};Object.keys(d.value).forEach(v=>{const x=parseInt(v,10);x>k?g[x-1]=d.value[x]:x<k&&(g[x]=d.value[x])}),d.value=g}}return e.onMounted(()=>{if(t.inputType==="mask")for(let k=0;k<o.value;k+=1)i.value[k]&&p(i.value[k],k)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(k=>{k&&k.destroy()})}),e.watch(()=>t.mask,k=>{t.inputType==="mask"&&Object.values(d.value).forEach(g=>{g&&g.updateOptions({mask:k,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,k=>{t.inputType==="mask"&&k&&k.forEach((g,v)=>{d.value[v]&&d.value[v].value!==g&&(d.value[v].value=g||"")})},{deep:!0}),(k,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(o.value,v=>(e.openBlock(),e.createElementBlock("div",{key:v,class:"flex items-center gap-2 w-full"},[n.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:x=>u(x,v-1),placeholder:n.placeholder,disabled:n.disabled,name:`${n.name}[${v-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,xm)):(e.openBlock(),e.createElementBlock("input",{key:1,type:n.inputType,value:a.value?.[v-1],onInput:x=>f(x,v-1),placeholder:c.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":n.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,wm)),!n.disabled&&v===o.value&&n.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(y,["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(q.Plus),{class:"h-4 w-4"})])):e.createCommentVNode("",!0),!n.disabled&&o.value>1&&n.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(x=>h(v-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(q.X),{class:"h-4 w-4"})],8,Cm)):e.createCommentVNode("",!0)]))),128))],2))}}),vm={class:"flex gap-1 w-full"},Em=["aria-expanded","data-focus"],Bm=["placeholder","disabled","readonly"],_m={class:"max-h-full"},Vm=["onClick","disabled"],Sm={key:0,class:"px-3 py-2 text-sm text-stone-500"},$m=["disabled"],Nm={class:"flex flex-col gap-1"},Am=["onDragstart","onDrop"],Mm=["disabled"],Fm=["title"],Dm=["disabled","onClick","aria-label"],Tm={key:0,class:"text-xs text-stone-500"},Fn=Be(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(n,{emit:t}){const o=n,r=t,l=e.useModel(n,"modelValue"),a=e.ref([]),s=e.ref(o.options??[]),c=e.ref({}),i=e.ref({}),d=e.ref({keyword:"",parent:null}),u=e.ref(""),p=e.ref(!1),f=e.ref(null),y=e.ref(null),h=e.ref(null),k=e.ref(null),g=e.ref(null),v=e.ref({});let x=!1,C=!1;const S=e.inject("values"),H=e.computed(()=>!!o.disabled),K=e.computed(()=>o.placeholder??"Оберіть значення"),L=e.computed(()=>o.search!==!1),B=e.computed(()=>{const w=o.parent??o.parentValue;return w?String(w):""}),_=e.computed(()=>B.value?S?.value?.[B.value]??null:null),$=w=>w==null?"__null__":String(w),R=w=>{if(!w)return"";const N=w.label??w.text??w.name??w.ua??w.en;return N?String(N):w.id!==void 0&&w.id!==null?String(w.id):""},V=w=>{const N=$(w);return i.value[N]||(i.value[N]=`array-select-${N}-${Math.random().toString(36).slice(2,8)}`),i.value[N]},T=e.computed(()=>new Set(a.value.map(w=>$(w.id)))),M=e.computed(()=>{const w=T.value;let N=[...s.value];if(!o.data&&u.value.trim()){const I=u.value.toLowerCase();N=N.filter(se=>R(se).toLowerCase().includes(I))}return N.filter(I=>!w.has($(I.id)))}),O=()=>{if(!o.data)return"";const w=o.prefix??"api",N=o.api??`/${w}/suggest/${o.data}`;return`${o.host??""}${N}`},Q=()=>{a.value.length&&(x=!0,a.value=a.value.map(w=>({...w,text:c.value[$(w.id)]??w.text})))},J=w=>{const N=$(w.id),I=R(w);I&&(c.value[N]=I)},de=w=>{s.value=w?[...w]:[],w?.forEach(J),Q()},te=w=>{if(!w.length)return;const N=new Map(s.value.map(I=>[$(I.id),I]));w.forEach(I=>{const se=$(I.id);N.set(se,I),J(I)}),s.value=Array.from(N.values()),Q()},F=async(w="")=>{if(!o.data)return[];const N=O();if(!N)return[];const I=new URLSearchParams;I.set("json","1"),w&&I.set("key",w),o.start===1&&I.set("start","1"),_.value!==null&&_.value!==void 0&&_.value!==""&&I.set("parent",String(_.value));try{return(await(await fetch(`${N}?${I.toString()}`)).json())?.data??[]}catch{return[]}},Y=async w=>{if(!o.data||!w.length)return[];const N=O();if(!N)return[];const I=Array.from(new Set(w.map(be=>$(be)))),se=new URLSearchParams;se.set("json","1"),se.set("val",I.join(",")),o.start===1&&se.set("start","1"),_.value!==null&&_.value!==void 0&&_.value!==""&&se.set("parent",String(_.value));try{const Ae=(await(await fetch(`${N}?${se.toString()}`)).json())?.data??[];return te(Ae),Ae}catch{return[]}},ne=async w=>{if(w==null||w==="")return null;const N=$(w),I=s.value.find(be=>$(be.id)===N);if(I)return I;const[se]=await Y([w]);return se??null},W=async(w="",{force:N=!1}={})=>{if(!o.data)return;const I=_.value??null;if(!N&&d.value.keyword===w&&d.value.parent===I&&s.value.length>0)return;d.value={keyword:w,parent:I};const be=await F(w);de(be)},he=((w,N=200)=>{let I;return(...se)=>{I&&clearTimeout(I),I=setTimeout(()=>w(...se),N)}})(async w=>{o.data&&await W(w,{force:!0})},250),re=e.ref(null),pe=()=>{if(!h.value)return;const w=h.value.getBoundingClientRect(),N=window.innerHeight??document.documentElement.clientHeight,I=window.innerWidth??document.documentElement.clientWidth,se=8,be=8,Le=o.maxHeight??280,Ae=N-w.bottom-be-se,Ke=w.top-be-se,dt=Ae>=Ke,ut=Math.max(I-se*2,0);let{width:Ie}=w;ut>0&&Ie>ut&&(Ie=ut);let{left:lt}=w;lt+Ie+se>I&&(lt=I-Ie-se),lt=Math.max(lt,se);const Pt=Math.min(Le,Math.max(dt?Ae:Ke,50));v.value={position:"fixed",left:`${lt}px`,width:`${Ie}px`,maxHeight:`${Pt}px`,transform:dt?"none":"translateY(-100%)",top:dt?`${w.bottom+be}px`:`${w.top-be}px`}},Ce=async(w="click")=>{H.value||p.value||(re.value=w,await W(u.value.trim()),p.value=!0,await e.nextTick(),pe(),g.value?.focus())},ke=()=>{p.value=!1,re.value=null,e.nextTick(()=>{g.value?.blur()})},Se=async w=>{if(w.stopPropagation(),!H.value){if(p.value){if(re.value==="focus"){re.value=null;return}ke();return}await Ce("click")}},De=w=>{w.key==="Escape"&&ke()},Me=w=>{if(!p.value)return;const N=w.target;k.value?.contains(N)||ke()},Te=w=>{const N=w.target;y.value?.contains(N)||k.value?.contains(N)||ke()},Z=w=>{if(w.key==="Escape"){w.preventDefault(),ke();return}if(w.key==="Enter"){w.preventDefault();const N=M.value[0];N&&ae(N)}},ae=w=>{if(!w)return;const N=$(w.id);if(T.value.has(N))return;J(w);const I={id:w.id,text:R(w)||String(w.id??""),key:V(w.id)};a.value=[...a.value,I],xe(w),u.value="",e.nextTick(()=>{g.value?.focus()})},xe=w=>{const N=a.value.map(I=>I.id);r("value-selected",{name:o.name,value:N,option:w})},ve=w=>{if(H.value)return;const N=a.value.filter(I=>$(I.id)!==$(w));a.value=N},{isOpenAdd:Fe,addData:je,addSchema:U,addForm:X,addTitle:le,addOption:ue,onAddValue:P}=Go({props:o,fetchOptionByValue:ne,optionsList:s,selectedOption:e.ref(null),modelValue:l,onCreated:async(w,N)=>{const I=w??await ne(N),se=I?.id??N;T.value.has($(se))||(I&&J(I),a.value=[...a.value,{id:se,text:I?R(I):String(se),key:V(se)}],xe(I??null))}}),oe=w=>{H.value||(f.value=w)},Ve=w=>{if(H.value||f.value===null||f.value===w)return;const N=[...a.value],[I]=N.splice(f.value,1);N.splice(w,0,I),f.value=null,a.value=N},Ne=async()=>{const N=(Array.isArray(l.value)?[...l.value]:[]).filter(se=>se!=null);if(o.data&&N.length){const se=N.filter(be=>!c.value[$(be)]);se.length&&await Y(se)}const I=N.map(se=>({id:se,text:c.value[$(se)]??String(se),key:V(se)}));x=!0,a.value=I};e.watch(a,w=>{if(x){x=!1;return}const N=w.map(I=>I.id);C=!0,l.value=N,r("change",N)},{deep:!0}),e.watch(l,()=>{if(C){C=!1;return}Ne()},{deep:!0}),e.watch(u,w=>{!o.data||!p.value||he(w.trim())}),e.watch(H,w=>{w&&ke()}),e.watch(()=>o.options,async w=>{o.data||(de(w??[]),await Ne())},{immediate:!0,deep:!0}),e.watch(()=>o.data,async w=>{w&&(await W(u.value.trim()),await Ne())},{immediate:!0});const z=e.ref(!1);return e.watch(_,async()=>{if(o.data){if(!z.value){z.value=!0;return}a.value=[],await W(u.value.trim()),await Ne()}}),e.onMounted(async()=>{document.addEventListener("click",Te,!0),window.addEventListener("keydown",De),window.addEventListener("scroll",Me,!0),await Ne()}),e.onUnmounted(()=>{document.removeEventListener("click",Te,!0),window.removeEventListener("keydown",De),window.removeEventListener("scroll",Me,!0)}),(w,N)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(ye.VsModal),{visible:e.unref(Fe),"onUpdate:visible":N[1]||(N[1]=I=>e.isRef(Fe)?Fe.value=I:null),class:"z-[1000]",title:e.unref(le),buttonText:"Додати",onDone:e.unref(ue)},{default:e.withCtx(()=>[e.createVNode(rt,{schema:e.unref(U),modelValue:e.unref(je),"onUpdate:modelValue":N[0]||(N[0]=I=>e.isRef(je)?je.value=I:null),ref_key:"addForm",ref:X},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),e.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:y},[e.createElementVNode("div",vm,[e.createElementVNode("div",{class:"relative flex-1",onClick:N[4]||(N[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:h,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)]":"",H.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:Se},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:g,"onUpdate:modelValue":N[2]||(N[2]=I=>u.value=I),placeholder:K.value,disabled:H.value,readonly:!L.value,onFocus:N[3]||(N[3]=()=>Ce("focus")),onKeydown:Z,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,Bm),[[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(q.ChevronDown),{class:"h-4 w-4"})],2)],10,Em),(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:k,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(v.value)},[e.createElementVNode("div",_m,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,I=>(e.openBlock(),e.createElementBlock("button",{key:$(I.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(se=>ae(I),["stop"]),disabled:H.value},e.toDisplayString(R(I)),9,Vm))),128)),M.value.length===0?(e.openBlock(),e.createElementBlock("p",Sm," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),o.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:N[5]||(N[5]=(...I)=>e.unref(P)&&e.unref(P)(...I)),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:H.value,type:"button"},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),N[8]||(N[8]=e.createElementVNode("span",null,"Додати",-1))],8,$m)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Nm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(I,se)=>(e.openBlock(),e.createElementBlock("div",{key:I.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":f.value===se}]),draggable:"true",onDragstart:be=>oe(se),onDragover:N[6]||(N[6]=e.withModifiers(()=>{},["prevent"])),onDrop:be=>Ve(se),onDragend:N[7]||(N[7]=be=>f.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:H.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})],8,Mm),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:I.text},e.toDisplayString(I.text),9,Fm),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:H.value,onClick:e.withModifiers(be=>ve(I.id),["stop"]),"aria-label":`Видалити ${I.text}`},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,Dm)],42,Am))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",Tm,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-9f0cb9d4"]]),Lm={class:"flex items-center gap-2 w-full"},Im={class:"relative flex-1"},Om=["placeholder","disabled","onKeydown"],Rm=["disabled"],Pm={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},zm={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},jm={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},Um=["onClick"],Hm={key:0,class:"p-4 text-sm text-gray-500"},fr=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(n,{emit:t}){const o=/{{\s*([^}]+?)\s*}}/g,r=n,l=t,{inputClass:a}=Ge(r.style),s=e.useModel(n,"modelValue"),c=e.computed({get:()=>s.value,set:L=>{s.value=L}}),i=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 f=e.computed(()=>r.placeholder??""),y=e.computed(()=>!!r.disabled),h=L=>{if(!L)return null;if(Array.isArray(L))return L;if(typeof L=="string"){const B=L.split(",").map(_=>_.trim()).filter(Boolean);return B.length!==4?null:B.map(Number)}return null},k=e.computed(()=>{const L=h(r.bbox);if(!L||L.length!==4)return null;const B=L.map(Number);return B.some(_=>Number.isNaN(_))?null:B}),g=e.computed(()=>{const L=k.value;if(!L)return"";const[B,_,$,R]=L;return`${B},${Math.max(_,R)},${$},${Math.min(_,R)}`});e.computed(()=>g.value?"1":"0");const v=e.inject("values");function x(){!y.value&&c.value.trim()&&C()}async function C(){const L=(c.value||"").trim();if(!L)return;let B=L;if(r.includes?.length&&v?.value){const $=r.includes.map(R=>v.value?.[R]).filter(Boolean);$.length&&(B=`${$.join(", ")}, ${L}`)}const _=K(B);if(_){i.value=!0;try{const R=await(await fetch(_)).json();d.value=Array.isArray(R)?R:[],u.value=!0}catch($){console.error("Address search error:",$)}finally{i.value=!1}}}function S(){u.value=!u.value}function H(L){if(!L)return;u.value=!1;const B=parseFloat(L.lat),$={type:"Point",coordinates:[parseFloat(L.lon),B]};r.geom&&v?.value&&(v.value[r.geom]=$),l("update:geom",$)}function K(L){if(!r.api)return"";const B={value:encodeURIComponent(L),bbox:k.value?k.value.join(","):""};return r.api.replace(o,(_,$)=>B[$.trim()]??"")}return(L,B)=>(e.openBlock(),e.createElementBlock("div",Lm,[e.createElementVNode("div",Im,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":B[0]||(B[0]=_=>c.value=_),placeholder:f.value,disabled:y.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(x,["prevent"]),["enter"])},null,42,Om),[[e.vModelText,c.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:S,title:"Show search results"},[e.createVNode(e.unref(q.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:C,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:i.value||!c.value?.trim()},[i.value?(e.openBlock(),e.createBlock(e.unref(q.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(q.Search),{key:0,class:"h-4 w-4"}))],8,Rm),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[u.value?(e.openBlock(),e.createElementBlock("div",Pm,[e.createElementVNode("div",zm,[e.createElementVNode("div",jm,[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]=_=>u.value=!1),title:"Close"},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(_,$)=>(e.openBlock(),e.createElementBlock("li",{key:$,onClick:R=>H(_),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(_.display_name),9,Um))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Hm," Не знайдено результатів "))])])):e.createCommentVNode("",!0)]))]))}}),qm={class:"vs-datalist space-y-3"},Km={class:"space-y-3"},Wm=["onClick","disabled"],Gm={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Ym=["disabled"],Xm=Be(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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.computed(()=>Array.isArray(o.value)?o.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(g=>({...g,disabled:t.disabled||g.disabled}))??[]),s=e.computed(()=>a.value.map(g=>k(g))),c=e.computed(()=>a.value.reduce((v,x)=>{const C=Number(x?.col??12);return v+(Number.isFinite(C)&&C>0?C:12)},0)>12),i=e.computed(()=>t.disabled?!1:t.maxItems?r.value.length<t.maxItems:!0),d=e.computed(()=>t.disabled||r.value.length<=(t.minItems||0));e.watch(()=>r.value.length,()=>{u(),p()},{immediate:!0}),e.watch(()=>t.schema,p,{immediate:!0,deep:!0});function u(){const g=r.value.length;l.value.length<g?l.value=[...l.value,...Array.from({length:g-l.value.length},()=>io())]:l.value.length>g&&l.value.splice(g)}function p(){if(!t.minItems||r.value.length>=t.minItems)return;const g=t.minItems-r.value.length,v=Array.from({length:g},f);o.value=[...r.value,...v]}function f(){const g={};return a.value.forEach(v=>{g[v.name]=v?.default??null}),g}function y(){i.value&&(o.value=[...r.value,f()],u())}function h(g){d.value||(o.value=r.value.filter((v,x)=>x!==g),u(),p())}function k(g){return{...g}}return(g,v)=>(e.openBlock(),e.createElementBlock("div",qm,[e.createElementVNode("div",Km,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(x,C)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[C],class:e.normalizeClass(["flex items-center gap-3 rounded-lg transition-colors",{"border border-gray-300 p-2":c.value}])},[e.createVNode(rt,{schema:s.value,layout:"inline",navigation:!1,values:r.value[C],"onUpdate:values":S=>r.value[C]=S,"form-id":l.value[C]},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:S=>h(C),disabled:d.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Wm)],2))),128)),r.value.length===0?(e.openBlock(),e.createElementBlock("div",Gm,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:y,disabled:!i.value},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Ym)]))}}),[["__scopeId","data-v-8df8e72a"]]),Zm={class:"vs-dataform space-y-4"},Jm=["draggable","onDragstart","onDragover","onDragenter","onDrop"],Qm={class:"flex items-center gap-2"},ef=["onClick"],tf={class:"text-sm font-medium text-gray-700"},nf={class:"flex items-center gap-2"},of=["title","onClick","disabled"],rf=["title","onClick","disabled"],lf={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},af=["disabled"],sf=Be(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(n){const t=n,o=e.useModel(n,"modelValue"),r=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),c=e.ref(null),i=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),u=e.computed(()=>t.emptyLabel??"Ще немає груп"),p=e.computed(()=>t.schema?.map(W=>({...W,disabled:t.disabled||W.disabled}))??[]),f=e.computed(()=>p.value.map(W=>_(W))),y=e.computed(()=>t.view==="accordion"),h=e.computed(()=>!!(t.collapsible||y.value)),k=e.computed(()=>t.draggable!==!1),g=e.computed(()=>t.disabled?!1:t.maxGroups?o.value.length<t.maxGroups:!0),v=e.computed(()=>t.disabled||o.value.length<=(t.minGroups||0));e.watch(()=>o.value.length,()=>{x(),C(),S()},{immediate:!0}),e.watch(()=>t.schema,S,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{C()},{immediate:!0});function x(){const W=o.value.length;r.value.length<W?r.value=[...r.value,...Array.from({length:W-r.value.length},()=>io())]:r.value.length>W&&r.value.splice(W)}function C(){const W=o.value.length;y.value?W===0?a.value=-1:a.value>=W?a.value=W-1:a.value<0&&(a.value=0):l.value.length<W?l.value=[...l.value,...Array.from({length:W-l.value.length},()=>!1)]:l.value.length>W&&l.value.splice(W)}function S(){if(!t.minGroups||o.value.length>=t.minGroups)return;const W=t.minGroups-o.value.length,ce=Array.from({length:W},H);o.value=[...o.value,...ce],C()}function H(){const W={};return p.value.forEach(ce=>{W[ce.name]=ce?.default??null}),W}function K(){g.value&&(o.value=[...o.value,H()],x(),C())}function L(W){v.value||(o.value=o.value.filter((ce,he)=>he!==W),x(),y.value?a.value>=o.value.length&&(a.value=o.value.length-1):l.value.splice(W,1),S())}function B(W){if(t.disabled)return;const ce=JSON.parse(JSON.stringify(o.value[W]??{}));o.value=[...o.value.slice(0,W+1),ce,...o.value.slice(W+1)],x(),y.value?a.value>W&&(a.value+=1):l.value.splice(W+1,0,l.value[W]??!1)}function _(W){return{...W}}function $(W){return y.value?a.value===-1&&W===0?!1:a.value!==W:!!l.value[W]}function R(W){if(h.value){if(y.value){a.value=W;return}l.value[W]=!l.value[W]}}function V(W,ce){if(!k.value||t.disabled){ce.preventDefault();return}s.value=W,c.value=W,i.value={groups:JSON.parse(JSON.stringify(o.value)),keys:[...r.value],states:[...l.value]},ce.dataTransfer?.setData("text/plain",String(W)),ce.dataTransfer?.setDragImage?.(ce.currentTarget,0,0)}function T(W,ce){!k.value||t.disabled||s.value!==null&&te(W,ce)}function M(W,ce){te(W,ce)}function O(W){!k.value||t.disabled||ne()}function Q(){i.value&&de(),s.value=null,c.value=null,i.value=null}function J(W,ce){const he=[...o.value],[re]=he.splice(W,1);he.splice(ce,0,re),o.value=he;const pe=[...r.value],[Ce]=pe.splice(W,1);if(pe.splice(ce,0,Ce),r.value=pe,y.value)a.value===W&&(a.value=ce);else{const ke=[...l.value],[Se]=ke.splice(W,1);ke.splice(ce,0,Se),l.value=ke}}function de(){i.value&&(o.value=i.value.groups,r.value=i.value.keys,l.value=i.value.states,i.value=null,c.value=null)}function te(W,ce){if(s.value===null)return;const he=F(W,ce);c.value=he,Y(he)}function F(W,ce){if(!ce?.currentTarget)return W;const he=ce.currentTarget.getBoundingClientRect(),pe=ce.clientY-he.top>he.height/2?W+1:W;return Math.max(0,Math.min(pe,o.value.length))}function Y(W){const ce=s.value;if(ce===null)return;let he=W;if(he>o.value.length&&(he=o.value.length),he===ce||he===ce+1)return;const re=he>ce?he-1:he;J(ce,re),s.value=re,c.value=he>ce?re+1:re}function ne(){i.value=null,s.value=null,c.value=null}return(W,ce)=>(e.openBlock(),e.createElementBlock("div",Zm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value,(he,re)=>(e.openBlock(),e.createElementBlock("div",{key:r.value[re],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":$(re)?"pt-6 px-6":"p-6"]]),draggable:k.value&&!t.disabled,onDragstart:pe=>V(re,pe),onDragend:Q,onDragover:e.withModifiers(pe=>T(re,pe),["prevent"]),onDragenter:e.withModifiers(pe=>M(re,pe),["prevent"]),onDrop:e.withModifiers(pe=>O(),["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"&&!$(re)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",Qm,[k.value?(e.openBlock(),e.createBlock(e.unref(q.GripVertical),{key:0,class:"h-4 w-4 text-gray-400","aria-hidden":"true"})):e.createCommentVNode("",!0),h.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:pe=>R(re)},[e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",$(re)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,ef)):e.createCommentVNode("",!0),e.createElementVNode("div",tf,e.toDisplayString(`${d.value} (${re+1})`),1)]),e.createElementVNode("div",nf,[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:pe=>B(re),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(q.Copy),{class:"h-4 w-4"})],8,of),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:pe=>L(re),disabled:v.value,draggable:"false"},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,rf)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(rt,{class:"vs-dataform__form",schema:f.value,layout:"inline",navigation:!1,values:o.value[re],"onUpdate:values":pe=>o.value[re]=pe,"form-id":r.value[re],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!$(re)]])],42,Jm))),128)),o.value.length===0?(e.openBlock(),e.createElementBlock("div",lf,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:K,disabled:!g.value},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,af)]))}}),[["__scopeId","data-v-accd044e"]]),Dn="__vs_form_monaco_loader__",Rt="__vs_form_monaco_script_loader__",Tn="__vs_form_monaco_editor_loader__",co=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(n,{expose:t}){const o=n,r=e.useModel(n,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof o.height=="number"?`${o.height}px`:o.height||"280px");let s=null,c=null,i=!1;const d=()=>{if(c)return Promise.resolve(c);if(typeof window>"u")return Promise.resolve(null);const h=window;if(h.monaco?.editor?.create)return c=h.monaco,Promise.resolve(c);if(h[Dn])return h[Dn];const g=(async()=>{const v=S=>{if(Array.from(document.styleSheets||[]).some(L=>L?.href?.includes(S)))return;const K=document.createElement("link");K.rel="stylesheet",K.href=S,document.head.appendChild(K)},x=S=>{if(h[Rt]?.[S])return h[Rt][S];h[Rt]||={};const H=Array.from(document.scripts).find(K=>K.src===S);return H?(h[Rt][S]=new Promise((K,L)=>{const B=H.readyState;if(H.dataset.loaded==="true"||B==="loaded"||B==="complete"){K();return}H.addEventListener("load",()=>{H.dataset.loaded="true",K()},{once:!0}),H.addEventListener("error",_=>L(_),{once:!0})}),h[Rt][S]):(h[Rt][S]=new Promise((K,L)=>{const B=document.createElement("script");B.src=S,B.async=!0,B.onload=()=>{B.dataset.loaded="true",K()},B.onerror=_=>L(_),document.body.appendChild(B)}),h[Rt][S])},C="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return v(`${C}/editor/editor.main.min.css`),await x(`${C}/loader.min.js`),h[Tn]||(h[Tn]=new Promise((S,H)=>{window.require.config({paths:{vs:C}}),window.require(["vs/editor/editor.main"],()=>{c=window.monaco,h.monaco=c,S(c)},K=>H(K))}).catch(S=>{throw delete h[Tn],S})),h[Tn]})().catch(v=>{throw delete h[Dn],v});return h[Dn]=g,g},u=()=>{!l.value||!c||(s&&(s.dispose(),s=null),s=c.editor.create(l.value,{value:r.value||"",language:o.syntax,theme:o.theme,automaticLayout:!0,minimap:{enabled:!!o.minimap},readOnly:!!o.disabled}),s.onDidChangeModelContent(()=>{i||(r.value=s.getValue())}))},p=()=>{s?.focus()},f=()=>s,y=()=>c;return e.watch(()=>r.value,h=>{if(!s)return;const k=s.getValue();h!==k&&(i=!0,s.setValue(h||""),i=!1)}),e.watch(()=>o.syntax,h=>{!s||!c||c.editor.setModelLanguage(s.getModel(),h||"xml")}),e.watch(()=>o.theme,h=>{c&&c.editor.setTheme(h||"vs-light")}),e.watch(()=>o.disabled,h=>{s&&s.updateOptions({readOnly:!!h})}),e.watch(()=>o.minimap,h=>{s&&s.updateOptions({minimap:{enabled:!!h}})}),e.onMounted(async()=>{try{const h=await d();if(!h||!h.editor)return;c=h,u()}catch(h){console.error("Failed to load Monaco editor",h)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:p,getEditor:f,getMonaco:y}),(h,k)=>(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))}}),hr={VsInputText:jt,VsInputRadio:Qn,VsInputInlineSelect:_n,"vs-input-text":jt,"vs-input-password":El,"vs-input-textarea":Xo,"vs-input-richtext":Zo,"vs-input-mask":hn,"vs-input-number":No,"vs-input-radio":Qn,"vs-input-select":so,"vs-input-inline-select":_n,"inline-select":_n,"vs-input-switcher":Yn,"vs-input-static":Xn,"vs-input-container":Wo,"vs-input-date":zo,"vs-input-checkbox":Fo,"vs-input-file":Ho,"vs-input-file2":ao,file2:ao,File2:ao,"vs-input-html":Xn,"vs-input-email":Zn,"vs-input-tel":Jn,"vs-input-datatable":Jo,"vs-input-map":lr,"vs-input-file-list":qo,"vs-input-tags":ar,"vs-input-slug":sr,"vs-input-codegen":ir,"vs-input-key-value":cr,"vs-input-text[]":dr,"vs-input-range":pr,"vs-input-color":ur,"vs-input-native-select":so,VsInputArraySelect:Fn,"vs-input-array":mr,"vs-input-array-select":Fn,"array-select":Fn,"vs-input-address":fr,"vs-input-datalist":Xm,"vs-input-dataform":sf,"vs-input-monaco":co},cf=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(n){const t=n,o=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){ye.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!o)return;for(const[c,i]of Object.entries(t.set))o.value[c]=s.result[i]}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(n.button),1))}}),df={class:"flex flex-col gap-1 w-full"},uf={class:"w-full"},pf=["disabled"],mf=["innerHTML"],ff=2e3,hf=10,gr=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(n,{emit:t}){const o=n,r=e.useModel(n,"modelValue"),l=t,a=e.computed(()=>Cl[`${o.layout}`]),s=["label","placeholder","info","description","text","html"],c=e.ref($()),i=e.computed(()=>L(o.item,c.value)),d=e.computed(()=>{const V={...i.value??{}},T=o.item?.name;return T&&p?.value?.[T]&&Object.assign(V,p.value[T]),V.__locale=c.value,V}),u=e.computed(()=>hr?.[`vs-input-${o.item.type}`]),p=e.inject("field-props"),f=e.computed(()=>{const V=e.unref(u);if(!V)return new Set;const T=V.props??V.__vccOpts?.props;if(!T)return new Set;const M=Array.isArray(T)?T:Object.keys(T);return new Set(M)}),h=[...["min","max","step"],"api","set","mask"],k=e.computed(()=>{const V={...i.value??{}},T=o.item?.name;T&&p?.value?.[T]&&Object.assign(V,p.value[T]);const M=f.value;let O;return M.size?O=Object.fromEntries(Object.entries(V).filter(([Q])=>M.has(Q))):O=V,h.forEach(Q=>{const J=V[Q];J!=null&&(O[Q]=J)}),O}),g=V=>{const T=typeof V=="object"&&V!==null?V:{value:V};l("value-selected",{...T,name:T.name??o.item?.name})},v=/{{\s*([^}]+?)\s*}}/g,x=e.inject("values"),C=e.ref(!1),S=e.computed(()=>{const V=o.item?.api,T=o.item?.type?.toLowerCase();return typeof V=="string"&&V.trim().length>0&&(T==="text"||T==="mask")});function H(V,T){if(!(V==null||!T))return T.split(".").reduce((M,O)=>M?.[O.trim()],V)}async function K(){const V=String(r.value??"").trim();if(!V)return;const T=(o.item?.api??"").trim();if(!T)return;const M=T.replace(v,(O,Q)=>Q.trim()==="value"?encodeURIComponent(V):"");C.value=!0;try{let O=await fetch(M),Q=0;for(;O.status===202&&Q<hf;)Q+=1,await new Promise(Y=>{setTimeout(Y,ff)}),O=await fetch(M);if(O.status===202){ye.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!O.ok){ye.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const J=await O.json(),de=J?.result!==void 0?J.result:J,te=o.item?.set;if(!te||!x?.value)return;const F=o.item?.name;Object.entries(te).forEach(([Y,ne])=>{if(!Y)return;let W=ne;F&&W.startsWith(`${F}.`)&&(W=W.slice(F.length+1));const ce=H(de,W);x.value[Y]=ce??null})}catch(O){console.error("API lookup error:",O),ye.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{C.value=!1}}e.onMounted(()=>{c.value=$(),window.addEventListener("storage",R)}),e.onUnmounted(()=>{window.removeEventListener("storage",R)});function L(V,T){if(!V)return{};const M={...V};return s.forEach(O=>{const Q=_(V,O,T);Q!=null&&(M[O]=Q)}),Array.isArray(V.options)&&(M.options=V.options.map(O=>B(O,T))),M}function B(V,T){if(!V)return V;const M={...V},O=_(V,"label",T),Q=_(V,"text",T);return O!=null&&(M.label=O),Q!=null?M.text=Q:O!=null&&(M.text=O),M}function _(V,T,M){const O=`${T}:${M}`;if(V?.[O]!=null)return V[O];if(T==="label"&&V?.[M]!=null)return V[M];if(V?.[T]!=null)return V[T];if(T==="label"){if(V?.ua!=null)return V.ua;if(V?.en!=null)return V.en}if(T==="text"||T==="html"){if(V?.ua!=null)return V.ua;if(V?.en!=null)return V.en}return null}function $(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function R(){c.value=$()}return(V,T)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:d.value.ua,error:o.error||"",item:d.value,columns:o.columns,label:d.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${o.item.type}-component`])},[e.createElementVNode("div",df,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":S.value}])},[e.createElementVNode("div",uf,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(u.value),e.mergeProps(k.value,{modelValue:r.value,"onUpdate:modelValue":T[0]||(T[0]=M=>r.value=M),onValueSelected:g}),null,16,["modelValue"]))]),S.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:C.value||!r.value?.toString().trim(),onClick:K},[C.value?(e.openBlock(),e.createBlock(e.unref(q.LoaderCircle),{key:1,class:"h-5 w-5 animate-spin text-gray-400"})):(e.openBlock(),e.createBlock(e.unref(q.Search),{key:0,class:"h-4 w-4"}))],8,pf)):e.createCommentVNode("",!0)],2),d.value.description&&o.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:d.value.description},null,8,mf)):e.createCommentVNode("",!0)]),d.value.behavior?.api&&d.value.behavior?.button?(e.openBlock(),e.createBlock(cf,e.mergeProps({key:0},d.value.behavior,{value:r.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),gf={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},yf={class:"vs-compact-form-navigation__rail mt-[6px]"},bf=["onClick"],kf=Be(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(n,{expose:t}){const o=n,r=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!o.enabled),c=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"]),i=e.computed(()=>{const R=o.width;if(R==null)return{};const V=typeof R=="number"?`${R}px`:`${R}`;return{width:V,minWidth:V}});let d=null,u=0,p=0,f=null,y=null,h=null;const k=()=>_(),g=()=>x();e.watch(()=>o.target,async R=>{if(K(),!R){f=null,r.value=[],l.value="";return}f=R,s.value&&(await e.nextTick(),H(R),x())},{immediate:!0}),e.watch(()=>o.scrollContainer,R=>{if(!s.value){y=R??null;return}v(R??null),e.nextTick(()=>x())},{immediate:!0}),e.onMounted(()=>{o.scrollContainer||v(null),x()}),e.onBeforeUnmount(()=>{K(),v(null,!0),f=null,typeof window<"u"&&(u&&window.cancelAnimationFrame(u),p&&window.cancelAnimationFrame(p))});function v(R,V=!1){if(h&&(h(),h=null),V){y=null;return}if(y=R??null,typeof window>"u")return;const T=R??window,M=window;T.addEventListener("scroll",k,{passive:!0}),M.addEventListener("resize",g),h=()=>{T.removeEventListener("scroll",k),M.removeEventListener("resize",g)}}function x(){if(!s.value||!f)return;u&&typeof window<"u"&&window.cancelAnimationFrame(u);const R=()=>{C(),u=0};typeof window>"u"?R():u=window.requestAnimationFrame(R)}function C(){if(!s.value||!f)return;const R=Array.from(f.querySelectorAll("h1, h2")),V=new Set,T=[];R.forEach((M,O)=>{const Q=M.textContent?.trim()??"";if(!Q)return;let J=(M.getAttribute("id")??"").trim();J||(J=S(Q)||`heading-${O+1}`);let de=J,te=1;for(;V.has(de);)de=`${J}-${te+=1}`;M.id!==de&&Object.assign(M,{id:de}),V.add(de),T.push({id:de,text:Q,level:M.tagName.toLowerCase()==="h1"?1:2})}),r.value=T,T.length||(l.value=""),B()}function S(R){return R.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function H(R){!R||!s.value||typeof MutationObserver>"u"||(K(),d=new MutationObserver(()=>x()),d.observe(R,{childList:!0,subtree:!0}))}function K(){d&&(d.disconnect(),d=null)}function L(R){const V=y;if(!V)return typeof window>"u"?R.offsetTop:R.getBoundingClientRect().top+window.scrollY;const T=R.getBoundingClientRect(),M=V.getBoundingClientRect();return T.top-M.top+V.scrollTop}function B(){if(!s.value||!r.value.length)return;const R=y,V=(R?R.scrollTop:null)||(typeof window<"u"?window.scrollY:0),T=(R?R.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),M=V+T;let O=null;for(let J=0;J<r.value.length;J+=1){const de=r.value[J],te=document.getElementById(de.id);if(te){const F=L(te);F+te.offsetHeight>V&&F<M&&(O=de.id)}}!O&&a.value&&(O=a.value),O&&(a.value=O);const Q=R?R.scrollHeight-R.clientHeight:document.documentElement.scrollHeight-window.innerHeight;V+5>=Q&&(O=r.value[r.value.length-1].id),O&&(l.value=O)}function _(){s.value&&(p&&window.cancelAnimationFrame(p),p=window.requestAnimationFrame(()=>{B(),p=0}))}function $(R){if(!s.value)return;const V=document.getElementById(R);if(!V)return;const T=y,M=Math.max(0,L(V));T?T.scrollTo({top:M,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:M,behavior:"smooth"})}return t({refresh:x}),(R,V)=>s.value&&r.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(c.value),style:e.normalizeStyle(i.value)},[e.createElementVNode("h2",gf,e.toDisplayString(n.title),1),e.createElementVNode("div",yf,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,T=>(e.openBlock(),e.createElementBlock("div",{key:T.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",T.level===2?"vs-compact-form-navigation__item--nested":"",T.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:M=>$(T.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",T.level===2?"pl-[15px]":"pl-[18px]",T.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(T.text),1)],10,bf)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-b3e16a91"]]),ct={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:n=>`Мінімальна довжина — ${n} символів`,maxlength:n=>`Максимальна довжина — ${n} символів`,min:n=>`Значення має бути не менше ${n}`,max:n=>`Значення має бути не більше ${n}`},xf=n=>typeof n=="string"?n.trim()?!1:ct.required:Array.isArray(n)?n.map(o=>typeof o=="string"?o.trim():o).filter(o=>o!=null&&o!=="").length?!1:ct.required:typeof n=="number"?Number?.isNaN(n)?ct?.required:!1:n?!1:ct.required,wf=n=>{const t=/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/;return n?t.test(n)?!1:ct.email:!1},Cf=(n,t)=>{if(!n)return!1;const o=String(n).trim();if(!/^\+[1-9]\d{1,14}$/.test(o))return ct.tel;const a=(typeof t?.digits=="number"&&Number.isFinite(t.digits)&&t.digits>0?t.digits:St(wt))||St(wt);return o.length-1!==a?ct.tel:!1},yr=n=>n==null?0:typeof n=="string"?n.trim().length:Array.isArray(n)?n.length:typeof n=="number"?n.toString().length:String(n).length,vf=(n,t)=>{if(n==null)return!1;const o=Number(t?.value??t?.length);return Number.isFinite(o)&&yr(n)<o?t?.message||ct.minlength(o):!1},Ef=(n,t)=>{if(n==null||n==="")return!1;const o=Number(t?.value??t?.length);return Number.isFinite(o)&&yr(n)>o?t?.message||ct.maxlength(o):!1},br=n=>{if(typeof n=="number")return n;if(typeof n=="string"){const t=n.trim().replace(",",".");return t?Number(t):Number.NaN}return Number(n)},Bf=(n,t)=>{if(n==null||n==="")return!1;const o=Number(t?.value);if(!Number.isFinite(o))return!1;const r=br(n);return Number.isFinite(r)&&r<o?t?.message||ct.min(o):!1},_f=(n,t)=>{if(n==null||n==="")return!1;const o=Number(t?.value);if(!Number.isFinite(o))return!1;const r=br(n);return Number.isFinite(r)&&r>o?t?.message||ct.max(o):!1},Vf=(n,t)=>{const o=t.pattern??t.regexp,r=typeof o=="string"?new RegExp(o):o;if(Array.isArray(n)){const l=n.filter(Boolean);return l.length===0||l.every(a=>r.test(a))?!1:t.message}return!r.test(n)&&n?t.message:!1},Sf=(n,t)=>!1,$f=(n,t)=>{switch(typeof t=="string"?t:t.type){case"required":return xf(n);case"email":return wf(n);case"tel":return Cf(n,typeof t=="object"?t:void 0);case"regexp":return Vf(n,t);case"minlength":return vf(n,t);case"maxlength":return Ef(n,t);case"min":return Bf(n,t);case"max":return _f(n,t);case"custom":return Sf();default:return!1}},Nf={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file",inlineselect:"inline-select"};function kr(n){const t=n?.toLowerCase();return Nf[t]||t}function uo(n,t=!1){if(Array.isArray(n)){const r=[];return n.forEach(l=>{const a={...l};if(a.name=(l.name||l.id||l.key||"").toString(),a.type=kr(l.type),a.label=l.label||l.ua,a.rules=l.rules||l.validators,a.type==="email"&&!a.rules&&(a.rules=["email"]),a.type==="tel"&&!a.rules){const s=a.mask||wt,c=St(s)||St(wt);a.rules=[{type:"tel",digits:c}]}l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=uo(a.schema,a.disabled)),r.push(a)}),r}const o=[];return Object.entries(n).forEach(r=>{const l={name:r[0],...r[1],type:kr(r[1].type),label:r[1].label||r[1].ua,rules:r[1].rules||r[1].validators,disabled:r[1].disabled??t};if(l.type==="email"&&!l.rules&&(l.rules=["email"]),l.type==="tel"&&!l.rules){const a=l.mask||wt,s=St(a)||St(wt);l.rules=[{type:"tel",digits:s}]}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=uo(l.schema,l.disabled)),o.push(l)}),o}function Af(n,t,o=!1){const r=e.computed(()=>uo((Array.isArray(t),t),typeof o=="boolean"?o:o.value)),l=e.ref({});function a(d){return Ko(n?.value,d?.conditions)}const s=(d=r.value,u=!0)=>(d.forEach(p=>{const f=[],y=Number(p?.minlength),h=Number(p?.maxlength),k=Number(p?.min),g=Number(p?.max);!Number.isNaN(y)&&Number.isFinite(y)&&f.push({type:"minlength",value:y}),!Number.isNaN(h)&&Number.isFinite(h)&&f.push({type:"maxlength",value:h}),!Number.isNaN(k)&&Number.isFinite(k)&&f.push({type:"min",value:k}),!Number.isNaN(g)&&Number.isFinite(g)&&f.push({type:"max",value:g});const v=[...f,...p.rules||[]];if(v.length){if(!a(p)){delete l.value[p.name];return}let x=!1,C=null;v.forEach(S=>{const H=$f(n.value[p.name],S);H&&(x=!0,!C&&typeof H=="string"&&(C=H))}),x&&C?l.value[p.name]=C:delete l.value[p.name]}p.schema&&s(p.schema,!1)}),u&&Object.values(l.value).some(Boolean)?l.value:null),c=e.computed(()=>r.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{n.value={},l.value={}},visibleSchema:c}}const Mf={class:"flex w-full h-full min-h-0 gap-6"},Ff={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(n,{expose:t,emit:o}){const r=o,l=n,a=e.useModel(n,"form"),s=e.useModel(n,"modelValue"),c=e.useModel(n,"values"),i=e.computed({get:()=>c.value??s.value,set:O=>{s.value=O,c.value=O}}),{errors:d,validate:u,reset:p,visibleSchema:f}=Af(i,l.schema,e.toRef(l,"disabled")),y=e.ref(null),h=e.ref(null),k=e.ref({}),g=e.computed(()=>l.navigation),v=e.computed(()=>l.navWidth),x=e.computed(()=>l.style?.columns),C=Object.freeze({container:12,label:3}),S=e.computed(()=>l.columns??x.value??C),H=e.computed(()=>l.columns!=null||x.value!=null),K=e.computed(()=>H.value?"horizontal":l.layout),L=O=>O?.columns?"horizontal":K.value,B=O=>O?.columns??S.value,_=e.computed(()=>{const O={},Q=J=>{if(!J)return;(Array.isArray(J)?J.map((te,F)=>({key:String(F),entry:te})):typeof J=="object"?Object.entries(J).map(([te,F])=>({key:te,entry:F})):[]).forEach(({key:te,entry:F})=>{if(!F||typeof F!="object")return;const Y=F.name?String(F.name):te;Y&&(O[Y]={...F,name:Y}),Array.isArray(F.schema)&&Q(F.schema)})};return Q(l.schema),O}),$=()=>{!l.formId&&i.value&&delete i.value.id,r("update:modelValue",i.value),u(),r("handle-submit",i.value)},R=O=>{r("value-selected",O)};t({validate:u,reset:p,errors:d}),e.onMounted(()=>{a.value={value:i.value,errors:d.value,reset:p,validate:u,formId:l.formId}});function V(O,Q){if(O===Q)return!0;if(typeof O!="object"||typeof Q!="object"||!O||!Q)return!1;const J=Object.keys(O),de=Object.keys(Q);return J.length!==de.length?!1:J.every(te=>O[te]===Q[te])}function T(O){return Array.isArray(O)?[...O]:O&&typeof O=="object"?{...O}:O}function M(O){Array.isArray(O)&&O.forEach(Q=>{if(!Q)return;const J=Q.name,de=Q.default!==void 0;J&&de&&i.value[J]===void 0&&(i.value[J]=T(Q.default)),Array.isArray(Q.schema)&&M(Q.schema)})}return e.watch(f,O=>{M(O)},{immediate:!0,deep:!0}),e.provide("form",a),e.provide("values",i),e.provide("field-props",k),e.provide("schema-by-name",_),(O,Q)=>(e.openBlock(),e.createElementBlock("div",Mf,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:h},[e.createElementVNode("form",{ref_key:"formRef",ref:y,onSubmit:e.withModifiers($,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",K.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(f),(J,de)=>(e.openBlock(),e.createElementBlock("div",{key:J.name,class:e.normalizeClass(L(J)==="horizontal"?"col-span-12":`col-span-${J.col||12}`)},[e.createVNode(gr,{style:e.normalizeStyle(n.style),item:J,layout:L(J),columns:B(J),"model-value":i.value[J.name],"onUpdate:modelValue":te=>{if(J.name==="id"&&!n.formId)return;const F=i.value[J.name];V(F,te)||(i.value[J.name]=te)},error:e.unref(d)[J.name],onValueSelected:R},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),L(J)==="settings"&&de+1!==e.unref(f).length?(e.openBlock(),e.createElementBlock("div",Ff)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode(kf,{target:y.value,"scroll-container":h.value,enabled:g.value,width:v.value},null,8,["target","scroll-container","enabled","width"])]))}}),Df={class:"relative"},Tf={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},Lf={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"},If={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Of={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Rf={class:"p-4 mim-h-0 h-full overflow-auto"},xr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(n,{emit:t}){const o=n,r=t,l=e.ref(o.schema),a=e.ref(o.defaultValue?JSON.parse(JSON.stringify(o.defaultValue)):{}),s=e.ref({}),c=e.ref(o.token||""),i=e.ref(o.token||""),d=e.ref(o.mode),u=()=>{const g=o.method?.trim().toUpperCase();return g==="GET"||g==="POST"||g==="PUT"?g:d.value==="add"?"POST":"PUT"},p=()=>{ye.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},f=g=>{const v={};g.id!==void 0&&g.id!==null&&(v.id=g.id,i.value=g.id.toString()),g.obj&&typeof g.obj=="object"&&Object.assign(v,g.obj),Object.keys(v).length&&(a.value={...a.value,...v})},y=async g=>{if(console.log(g),g.ok){await g.json().catch(()=>({})),p(),r("save",a.value);return}const v=await g.json().catch(()=>({})),x=v.message||v.error;if(g.status===400){ye.notify({type:"warning",title:"Помилка валідації",message:x||"Некоректні дані (400)"});return}if(g.status===500){ye.notify({type:"error",title:"Серверна помилка",message:x||"Виникла помилка на сервері (500)"});return}ye.notify({type:"error",title:"Помилка",message:`Статус: ${g.status}`})};async function h(){const g=s.value.validate();if(g){ye.notify({type:"warning",title:"Помилка валідації",message:Object.entries(g).map(([x,C])=>`${x}: ${C}`).join(`
|
|
5
5
|
`)});return}d.value==="add"&&a.value&&delete a.value.id;const v=o.api?.trim();if(v){const x=u();try{const C=await fetch(v,{method:x,headers:x==="GET"?void 0:{"Content-Type":"application/json"},body:x==="GET"?void 0:JSON.stringify(a.value)});await y(C)}catch(C){ye.notify({type:"error",title:"Помилка з’єднання",message:C.message||"Не вдалося виконати запит"})}return}if(c.value)try{const x=await fetch(`/api/table/${c.value}`,{method:d.value==="add"?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.value)});await y(x)}catch(x){ye.notify({type:"error",title:"Помилка з’єднання",message:x.message||"Не вдалося виконати запит"})}else r("edit",a.value),k()}function k(){r("close")}return e.onMounted(async()=>{try{if(o.form&&!o.schema){const g=await fetch(`/api/template/form/${o.form}`);if(!g.ok){ye.notify({type:g.status>=400&&g.status<500?"warning":"error",title:"Error",message:`Error code: ${g.status}`});return}const v=await g.json();l.value=v.schema,v.id&&(i.value=v.id),v.token&&(c.value=v.token,i.value||(i.value=v.token))}else if(o.token&&!o.defaultValue){c.value=o.token;const g=await fetch(`/api/form/${c.value}`);if(!g.ok){ye.notify({type:g.status>=400&&g.status<500?"warning":"error",title:"Error",message:`Error code: ${g.status}`});return}const v=await g.json();l.value=v.schema,v.data?a.value=v.data:d.value="add",f({id:v.id,obj:v.obj})}}catch(g){ye.notify({type:"error",title:"Error",message:g.message||"Unexpected error"}),console.error(g)}}),(g,v)=>(e.openBlock(),e.createElementBlock("div",Df,[e.createElementVNode("div",Tf,[e.createElementVNode("div",Lf,[e.createElementVNode("div",If,[e.createElementVNode("h3",Of,e.toDisplayString(d.value==="add"?"Додати":"Змінити"),1),e.createElementVNode("button",{onClick:k,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"},[v[2]||(v[2]=e.createElementVNode("span",{class:"sr-only"},"Close",-1)),e.createVNode(e.unref(q.X),{class:"h-4 w-4 flex-shrink-0"})])]),e.createElementVNode("div",Rf,[l.value?(e.openBlock(),e.createBlock(rt,{key:0,schema:l.value,values:a.value,"onUpdate:values":v[0]||(v[0]=x=>a.value=x),form:s.value,"onUpdate:form":v[1]||(v[1]=x=>s.value=x),formId:i.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:k,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:h,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"}," Зберегти ")])])])]))}}),wr=Kn.form.richtext,Cr=Wn.form.richtext,po={en:{form:{richtext:wr}},uk:{form:{richtext:Cr}}},vr=(n={mode:"edit",schema:null})=>new Promise(t=>{const{close:o}=ye.modal({title:n.mode==="add"?"Додати":"Редагувати",template:"",visible:!0,size:"medium",closeClickBack:!0,content:xr,contentProps:{...n,onClose:()=>{t(null),o()},onSave:r=>{t(r),o()}}})});rt.install=function(t){t.component("VForm",rt),Object.assign(t.config.globalProperties,{$form:vr}),t.provide("form",vr),window.v3plugin||(window.v3plugin={})};function $t(n){return typeof n=="string"||n instanceof String}function Er(n){var t;return typeof n=="object"&&n!=null&&(n==null||(t=n.constructor)==null?void 0:t.name)==="Object"}function Br(n,t){return Array.isArray(t)?Br(n,(o,r)=>t.includes(r)):Object.entries(n).reduce((o,r)=>{let[l,a]=r;return t(a,l)&&(o[l]=a),o},{})}const ge={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function _r(n){switch(n){case ge.LEFT:return ge.FORCE_LEFT;case ge.RIGHT:return ge.FORCE_RIGHT;default:return n}}function mo(n){return n.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function Ln(n,t){if(t===n)return!0;const o=Array.isArray(t),r=Array.isArray(n);let l;if(o&&r){if(t.length!=n.length)return!1;for(l=0;l<t.length;l++)if(!Ln(t[l],n[l]))return!1;return!0}if(o!=r)return!1;if(t&&n&&typeof t=="object"&&typeof n=="object"){const a=t instanceof Date,s=n instanceof Date;if(a&&s)return t.getTime()==n.getTime();if(a!=s)return!1;const c=t instanceof RegExp,i=n instanceof RegExp;if(c&&i)return t.toString()==n.toString();if(c!=i)return!1;const d=Object.keys(t);for(l=0;l<d.length;l++)if(!Object.prototype.hasOwnProperty.call(n,d[l]))return!1;for(l=0;l<d.length;l++)if(!Ln(n[d[l]],t[d[l]]))return!1;return!0}else if(t&&n&&typeof t=="function"&&typeof n=="function")return t.toString()===n.toString();return!1}class Pf{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?ge.NONE:(this.oldSelection.end===this.cursorPos||this.oldSelection.start===this.cursorPos)&&this.oldSelection.end===this.oldSelection.start?ge.RIGHT:ge.LEFT}}function Ee(n,t){return new Ee.InputMask(n,t)}function Vr(n){if(n==null)throw new Error("mask property should be defined");return n instanceof RegExp?Ee.MaskedRegExp:$t(n)?Ee.MaskedPattern:n===Date?Ee.MaskedDate:n===Number?Ee.MaskedNumber:Array.isArray(n)||n===Array?Ee.MaskedDynamic:Ee.Masked&&n.prototype instanceof Ee.Masked?n:Ee.Masked&&n instanceof Ee.Masked?n.constructor:n instanceof Function?Ee.MaskedFunction:(console.warn("Mask not found for mask",n),Ee.Masked)}function Ht(n){if(!n)throw new Error("Options in not defined");if(Ee.Masked){if(n.prototype instanceof Ee.Masked)return{mask:n};const{mask:t=void 0,...o}=n instanceof Ee.Masked?{mask:n}:Er(n)&&n.mask instanceof Ee.Masked?n:{};if(t){const r=t.mask;return{...Br(t,(l,a)=>!a.startsWith("_")),mask:t.constructor,_mask:r,...o}}}return Er(n)?{...n}:{mask:n}}function ht(n){if(Ee.Masked&&n instanceof Ee.Masked)return n;const t=Ht(n),o=Vr(t.mask);if(!o)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===o&&delete t.mask,t._mask&&(t.mask=t._mask,delete t._mask),new o(t)}Ee.createMask=ht;class In{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,o){if(!(t==null||o==null||t===this.selectionStart&&o===this.selectionEnd))try{this._unsafeSelect(t,o)}catch{}}get isActive(){return!1}}Ee.MaskElement=In;const Sr=90,zf=89;class Qt extends In{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,o,r;return(t=(o=(r=this.input).getRootNode)==null?void 0:o.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===Sr&&t.shiftKey&&(t.metaKey||t.ctrlKey)||t.keyCode===zf&&t.ctrlKey))return t.preventDefault(),this._handlers.redo(t);if(this._handlers.undo&&t.keyCode===Sr&&(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={}}}Ee.HTMLMaskElement=Qt;class $r extends Qt{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,o){this.input.setSelectionRange(t,o)}get value(){return this.input.value}set value(t){this.input.value=t}}Ee.HTMLMaskElement=Qt;class fo extends Qt{get _unsafeSelectionStart(){const t=this.rootElement,o=t.getSelection&&t.getSelection(),r=o&&o.anchorOffset,l=o&&o.focusOffset;return l==null||r==null||r<l?r:l}get _unsafeSelectionEnd(){const t=this.rootElement,o=t.getSelection&&t.getSelection(),r=o&&o.anchorOffset,l=o&&o.focusOffset;return l==null||r==null||r>l?r:l}_unsafeSelect(t,o){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,o);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}}Ee.HTMLContenteditableMaskElement=fo;class On{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>On.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}}On.MAX_LENGTH=100;class Nr{constructor(t,o){this.el=t instanceof In?t:t.isContentEditable&&t.tagName!=="INPUT"&&t.tagName!=="TEXTAREA"?new fo(t):new $r(t),this.masked=ht(o),this._listeners={},this._value="",this._unmaskedValue="",this._rawInputValue="",this.history=new On,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 o;return t==null||((o=this.masked)==null?void 0:o.maskEquals(t))}get mask(){return this.masked.mask}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof Ee.Masked)&&this.masked.constructor===Vr(t)){this.masked.updateOptions({mask:t});return}const o=t instanceof Ee.Masked?t:ht({mask:t});o.unmaskedValue=this.masked.unmaskedValue,this.masked=o}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,o){const r=this._listeners[t];r&&r.forEach(l=>l(o))}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 o=this.masked.unmaskedValue,r=this.masked.value,l=this.masked.rawInputValue,a=this.displayValue,s=this.unmaskedValue!==o||this.value!==r||this._rawInputValue!==l;this._unmaskedValue=o,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:o,selection:{start:this.selectionStart,end:this.cursorPos}})}updateOptions(t){const{mask:o,...r}=t,l=!this.maskEquals(o),a=this.masked.optionsIsChanged(r);l&&(this.mask=o),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,ge.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,o){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(o),this}off(t,o){if(!this._listeners[t])return this;if(!o)return delete this._listeners[t],this;const r=this._listeners[t].indexOf(o);return r>=0&&this._listeners[t].splice(r,1),this}_onInput(t){this._inputEvent=t,this._abortUpdateCursor();const o=new Pf({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),r=this.masked.rawInputValue,l=this.masked.splice(o.startChangePos,o.removed.length,o.inserted,o.removeDirection,{input:!0,raw:!0}).offset,a=r===this.masked.rawInputValue?o.removeDirection:ge.NONE;let s=this.masked.nearestInputPos(o.startChangePos+l,a);a!==ge.NONE&&(s=this.masked.nearestInputPos(s,ge.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}}Ee.InputMask=Nr;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}}Ee.ChangeDetails=_e;class gt{constructor(t,o,r){t===void 0&&(t=""),o===void 0&&(o=0),this.value=t,this.from=o,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 o=this.value[0];return this.value=this.value.slice(1),o}shift(){if(!this.value.length)return"";const t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}class He{constructor(t){this._value="",this._update({...He.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,o){o===void 0&&(o={input:!0}),this.reset(),this.append(t,o,""),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,o){return t}totalInputPositions(t,o){return t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),Math.min(this.displayValue.length,o-t)}extractInput(t,o,r){return t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),this.displayValue.slice(t,o)}extractTail(t,o){return t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),new gt(this.extractInput(t,o),t)}appendTail(t){return $t(t)&&(t=new gt(String(t))),t.appendTo(this)}_appendCharRaw(t,o){return t?(this._value+=t,new _e({inserted:t,rawInserted:t})):new _e}_appendChar(t,o,r){o===void 0&&(o={});const l=this.state;let a;if([t,a]=this.doPrepareChar(t,o),t&&(a=a.aggregate(this._appendCharRaw(t,o)),!a.rawInserted&&this.autofix==="pad")){const s=this.state;this.state=l;let c=this.pad(o);const i=this._appendCharRaw(t,o);c=c.aggregate(i),i.rawInserted||c.equals(a)?a=c:this.state=s}if(a.inserted){let s,c=this.doValidate(o)!==!1;if(c&&r!=null){const i=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(c=d.rawInserted.length===r.toString().length,!(c&&d.inserted)&&this.overwrite==="shift"){this.state=i,s=r.state;for(let u=0;u<a.rawInserted.length;++u)r.shift();d=this.appendTail(r),c=d.rawInserted.length===r.toString().length}c&&d.inserted&&(this.state=i)}c||(a=new _e,this.state=l,r&&s&&(r.state=s))}return a}_appendPlaceholder(){return new _e}_appendEager(){return new _e}append(t,o,r){if(!$t(t))throw new Error("value should be string");const l=$t(r)?new gt(String(r)):r;o!=null&&o.tail&&(o._beforeTailState=this.state);let a;[t,a]=this.doPrepare(t,o);for(let s=0;s<t.length;++s){const c=this._appendChar(t[s],o,l);if(!c.rawInserted&&!this.doSkipInvalid(t[s],o,l))break;a.aggregate(c)}return(this.eager===!0||this.eager==="append")&&o!=null&&o.input&&t&&a.aggregate(this._appendEager()),l!=null&&(a.tailShift+=this.appendTail(l).tailShift),a}remove(t,o){return t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),this._value=this.displayValue.slice(0,t)+this.displayValue.slice(o),new _e}withValueRefresh(t){if(this._refreshing||!this._initialized)return t();this._refreshing=!0;const o=this.rawInputValue,r=this.value,l=t();return this.rawInputValue=o,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 o=this.state,r=t(this);return this.state=o,delete this._isolated,r}doSkipInvalid(t,o,r){return!!this.skipInvalid}doPrepare(t,o){return o===void 0&&(o={}),_e.normalize(this.prepare?this.prepare(t,this,o):t)}doPrepareChar(t,o){return o===void 0&&(o={}),_e.normalize(this.prepareChar?this.prepareChar(t,this,o):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,o,r,l,a){r===void 0&&(r=""),l===void 0&&(l=ge.NONE),a===void 0&&(a={input:!0});const s=t+o,c=this.extractTail(s),i=this.eager===!0||this.eager==="remove";let d;i&&(l=_r(l),d=this.extractInput(0,s,{raw:!0}));let u=t;const p=new _e;if(l!==ge.NONE&&(u=this.nearestInputPos(t,o>1&&t!==0&&!i?ge.NONE:l),p.tailShift=u-t),p.aggregate(this.remove(u)),i&&l!==ge.NONE&&d===this.rawInputValue)if(l===ge.FORCE_LEFT){let f;for(;d===this.rawInputValue&&(f=this.displayValue.length);)p.aggregate(new _e({tailShift:-1})).aggregate(this.remove(f-1))}else l===ge.FORCE_RIGHT&&c.unshift();return p.aggregate(this.append(r,a,c))}maskEquals(t){return this.mask===t}optionsIsChanged(t){return!Ln(this,t)}typedValueEquals(t){const o=this.typedValue;return t===o||He.EMPTY_VALUES.includes(t)&&He.EMPTY_VALUES.includes(o)||(this.format?this.format(t,this)===this.format(this.typedValue,this):!1)}pad(t){return new _e}}He.DEFAULTS={skipInvalid:!0},He.EMPTY_VALUES=[void 0,null,""],Ee.Masked=He;class Nt{constructor(t,o){t===void 0&&(t=[]),o===void 0&&(o=0),this.chunks=t,this.from=o}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=$t(t)?new gt(String(t)):t;const o=this.chunks[this.chunks.length-1],r=o&&(o.stop===t.stop||t.stop==null)&&t.from===o.from+o.toString().length;if(t instanceof gt)r?o.extend(t.toString()):this.chunks.push(t);else if(t instanceof Nt){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 Ee.MaskedPattern))return new gt(this.toString()).appendTo(t);const o=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 c;if(s!=null&&(!a||a.index<=s)&&((l instanceof Nt||t._stops.indexOf(s)>=0)&&o.aggregate(t._appendPlaceholder(s)),c=l instanceof Nt&&t._blocks[s]),c){const i=c.appendTail(l);o.aggregate(i);const d=l.toString().slice(i.rawInserted.length);d&&o.aggregate(t.append(d,{tail:!0}))}else o.aggregate(t.append(l.toString(),{tail:!0}))}return o}get state(){return{chunks:this.chunks.map(t=>t.state),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(t){const{chunks:o,...r}=t;Object.assign(this,r),this.chunks=o.map(l=>{const a="chunks"in l?new Nt:new gt;return a.state=l,a})}unshift(t){if(!this.chunks.length||t!=null&&this.from>=t)return"";const o=t!=null?t-this.from:t;let r=0;for(;r<this.chunks.length;){const l=this.chunks[r],a=l.unshift(o);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 o=this.chunks[t],r=o.shift();if(o.toString()){if(!r)break;--t}else this.chunks.splice(t,1);if(r)return r}return""}}class jf{constructor(t,o){this.masked=t,this._log=[];const{offset:r,index:l}=t._mapPosToBlock(o)||(o<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=((o=this.block)==null?void 0:o.displayValue.length)||0){var o;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,ge.FORCE_LEFT),this.offset!==0))return!0})}pushLeftBeforeInput(){return this._pushLeft(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,ge.LEFT),!0})}pushLeftBeforeRequired(){return this._pushLeft(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ge.LEFT),!0})}pushRightBeforeFilled(){return this._pushRight(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,ge.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,ge.NONE),!0})}pushRightBeforeRequired(){return this._pushRight(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ge.NONE),!0})}}class ho{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,o){return t===void 0&&(t=0),o===void 0&&(o=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(o),this._value||(this._isRawInput=!1),new _e}nearestInputPos(t,o){o===void 0&&(o=ge.NONE);const r=0,l=this._value.length;switch(o){case ge.LEFT:case ge.FORCE_LEFT:return r;case ge.NONE:case ge.RIGHT:case ge.FORCE_RIGHT:default:return l}}totalInputPositions(t,o){return t===void 0&&(t=0),o===void 0&&(o=this._value.length),this._isRawInput?o-t:0}extractInput(t,o,r){return t===void 0&&(t=0),o===void 0&&(o=this._value.length),r===void 0&&(r={}),r.raw&&this._isRawInput&&this._value.slice(t,o)||""}get isComplete(){return!0}get isFilled(){return!!this._value}_appendChar(t,o){if(o===void 0&&(o={}),this.isFilled)return new _e;const r=this.eager===!0||this.eager==="append",a=this.char===t&&(this.isUnmasking||o.input||o.raw)&&(!o.raw||!r)&&!o.tail,s=new _e({inserted:this.char,rawInserted:a?this.char:""});return this._value=this.char,this._isRawInput=a&&(o.raw||o.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 gt("")}appendTail(t){return $t(t)&&(t=new gt(String(t))),t.appendTo(this)}append(t,o,r){const l=this._appendChar(t[0],o);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 en{constructor(t){const{parent:o,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:c,...i}=t;this.masked=ht(i),Object.assign(this,{parent:o,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:c})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,o){return t===void 0&&(t=0),o===void 0&&(o=this.value.length),t===0&&o>=1?(this.isFilled=!1,this.masked.remove(t,o)):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,o){if(o===void 0&&(o={}),this.isFilled)return new _e;const r=this.masked.state;let l=this.masked._appendChar(t,this.currentMaskFlags(o));return l.inserted&&this.doValidate(o)===!1&&(l=new _e,this.masked.state=r),!l.inserted&&!this.isOptional&&!this.lazy&&!o.input&&(l.inserted=this.placeholderChar),l.skip=!l.inserted&&!this.isOptional,this.isFilled=!!l.inserted,l}append(t,o,r){return this.masked.append(t,this.currentMaskFlags(o),r)}_appendPlaceholder(){return this.isFilled||this.isOptional?new _e:(this.isFilled=!0,new _e({inserted:this.placeholderChar}))}_appendEager(){return new _e}extractTail(t,o){return this.masked.extractTail(t,o)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,o,r){return t===void 0&&(t=0),o===void 0&&(o=this.value.length),this.masked.extractInput(t,o,r)}nearestInputPos(t,o){o===void 0&&(o=ge.NONE);const r=0,l=this.value.length,a=Math.min(Math.max(t,r),l);switch(o){case ge.LEFT:case ge.FORCE_LEFT:return this.isComplete?a:r;case ge.RIGHT:case ge.FORCE_RIGHT:return this.isComplete?a:l;case ge.NONE:default:return a}}totalInputPositions(t,o){return t===void 0&&(t=0),o===void 0&&(o=this.value.length),this.value.slice(t,o).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 o;return{...t,_beforeTailState:(t==null||(o=t._beforeTailState)==null?void 0:o.masked)||t?._beforeTailState}}pad(t){return new _e}}en.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 Ar extends He{updateOptions(t){super.updateOptions(t)}_update(t){const o=t.mask;o&&(t.validate=r=>r.search(o)>=0),super._update(t)}}Ee.MaskedRegExp=Ar;class qe extends He{constructor(t){super({...qe.DEFAULTS,...t,definitions:Object.assign({},en.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 o=this.mask;if(!o||!t)return;let r=!1,l=!1;for(let a=0;a<o.length;++a){if(this.blocks){const d=o.slice(a),u=Object.keys(this.blocks).filter(f=>d.indexOf(f)===0);u.sort((f,y)=>y.length-f.length);const p=u[0];if(p){const{expose:f,repeat:y,...h}=Ht(this.blocks[p]),k={lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,autofix:this.autofix,...h,repeat:y,parent:this},g=y!=null?new Ee.RepeatBlock(k):ht(k);g&&(this._blocks.push(g),f&&(this.exposeBlock=g),this._maskedBlocks[p]||(this._maskedBlocks[p]=[]),this._maskedBlocks[p].push(this._blocks.length-1)),a+=p.length-1;continue}}let s=o[a],c=s in t;if(s===qe.STOP_CHAR){this._stops.push(this._blocks.length);continue}if(s==="{"||s==="}"){r=!r;continue}if(s==="["||s==="]"){l=!l;continue}if(s===qe.ESCAPE_CHAR){if(++a,s=o[a],!s)break;c=!1}const i=c?new en({isOptional:l,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...Ht(t[s]),parent:this}):new ho({char:s,eager:this.eager,isUnmasking:r});this._blocks.push(i)}}get state(){return{...super.state,_blocks:this._blocks.map(t=>t.state)}}set state(t){if(!t){this.reset();return}const{_blocks:o,...r}=t;this._blocks.forEach((l,a)=>l.state=o[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,o)=>t+=o.unmaskedValue,"")}set unmaskedValue(t){if(this.exposeBlock){const o=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.unmaskedValue=t,this.appendTail(o),this.doCommit()}else super.unmaskedValue=t}get value(){return this.exposeBlock?this.exposeBlock.value:this._blocks.reduce((t,o)=>t+=o.value,"")}set value(t){if(this.exposeBlock){const o=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.value=t,this.appendTail(o),this.doCommit()}else super.value=t}get typedValue(){return this.exposeBlock?this.exposeBlock.typedValue:super.typedValue}set typedValue(t){if(this.exposeBlock){const o=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.typedValue=t,this.appendTail(o),this.doCommit()}else super.typedValue=t}get displayValue(){return this._blocks.reduce((t,o)=>t+=o.displayValue,"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const o=new _e;let r=(t=this._mapPosToBlock(this.displayValue.length))==null?void 0:t.index;if(r==null)return o;this._blocks[r].isFilled&&++r;for(let l=r;l<this._blocks.length;++l){const a=this._blocks[l]._appendEager();if(!a.inserted)break;o.aggregate(a)}return o}_appendCharRaw(t,o){o===void 0&&(o={});const r=this._mapPosToBlock(this.displayValue.length),l=new _e;if(!r)return l;for(let s=r.index,c;c=this._blocks[s];++s){var a;const i=c._appendChar(t,{...o,_beforeTailState:(a=o._beforeTailState)==null||(a=a._blocks)==null?void 0:a[s]});if(l.aggregate(i),i.consumed)break}return l}extractTail(t,o){t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length);const r=new Nt;return t===o||this._forEachBlocksInRange(t,o,(l,a,s,c)=>{const i=l.extractTail(s,c);i.stop=this._findStopBefore(a),i.from=this._blockStartPos(a),i instanceof Nt&&(i.blockIndex=a),r.extend(i)}),r}extractInput(t,o,r){if(t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),r===void 0&&(r={}),t===o)return"";let l="";return this._forEachBlocksInRange(t,o,(a,s,c,i)=>{l+=a.extractInput(c,i,r)}),l}_findStopBefore(t){let o;for(let r=0;r<this._stops.length;++r){const l=this._stops[r];if(l<=t)o=l;else break}return o}_appendPlaceholder(t){const o=new _e;if(this.lazy&&t==null)return o;const r=this._mapPosToBlock(this.displayValue.length);if(!r)return o;const l=r.index,a=t??this._blocks.length;return this._blocks.slice(l,a).forEach(s=>{if(!s.lazy||t!=null){var c;o.aggregate(s._appendPlaceholder((c=s._blocks)==null?void 0:c.length))}}),o}_mapPosToBlock(t){let o="";for(let r=0;r<this._blocks.length;++r){const l=this._blocks[r],a=o.length;if(o+=l.displayValue,t<=o.length)return{index:r,offset:t-a}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce((o,r)=>o+=r.displayValue.length,0)}_forEachBlocksInRange(t,o,r){o===void 0&&(o=this.displayValue.length);const l=this._mapPosToBlock(t);if(l){const a=this._mapPosToBlock(o),s=a&&l.index===a.index,c=l.offset,i=a&&s?a.offset:this._blocks[l.index].displayValue.length;if(r(this._blocks[l.index],l.index,c,i),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,o){t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length);const r=super.remove(t,o);return this._forEachBlocksInRange(t,o,(l,a,s,c)=>{r.aggregate(l.remove(s,c))}),r}nearestInputPos(t,o){if(o===void 0&&(o=ge.NONE),!this._blocks.length)return 0;const r=new jf(this,t);if(o===ge.NONE)return r.pushRightBeforeInput()||(r.popState(),r.pushLeftBeforeInput())?r.pos:this.displayValue.length;if(o===ge.LEFT||o===ge.FORCE_LEFT){if(o===ge.LEFT){if(r.pushRightBeforeFilled(),r.ok&&r.pos===t)return t;r.popState()}if(r.pushLeftBeforeInput(),r.pushLeftBeforeRequired(),r.pushLeftBeforeFilled(),o===ge.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:o===ge.FORCE_LEFT?0:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:0)}return o===ge.RIGHT||o===ge.FORCE_RIGHT?(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.pushRightBeforeFilled()?r.pos:o===ge.FORCE_RIGHT?this.displayValue.length:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:this.nearestInputPos(t,ge.LEFT))):t}totalInputPositions(t,o){t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length);let r=0;return this._forEachBlocksInRange(t,o,(l,a,s,c)=>{r+=l.totalInputPositions(s,c)}),r}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const o=this._maskedBlocks[t];return o?o.map(r=>this._blocks[r]):[]}pad(t){const o=new _e;return this._forEachBlocksInRange(0,this.displayValue.length,r=>o.aggregate(r.pad(t))),o}}qe.DEFAULTS={...He.DEFAULTS,lazy:!0,placeholderChar:"_"},qe.STOP_CHAR="`",qe.ESCAPE_CHAR="\\",qe.InputDefinition=en,qe.FixedDefinition=ho,Ee.MaskedPattern=qe;class tn extends qe{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:o=this.to||0,from:r=this.from||0,maxLength:l=this.maxLength||0,autofix:a=this.autofix,...s}=t;this.to=o,this.from=r,this.maxLength=Math.max(String(o).length,l),this.autofix=a;const c=String(this.from).padStart(this.maxLength,"0"),i=String(this.to).padStart(this.maxLength,"0");let d=0;for(;d<i.length&&i[d]===c[d];)++d;s.mask=i.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 o="",r="";const[,l,a]=t.match(/^(\D*)(\d*)(\D*)/)||[];return a&&(o="0".repeat(l.length)+a,r="9".repeat(l.length)+a),o=o.padEnd(this.maxLength,"0"),r=r.padEnd(this.maxLength,"9"),[o,r]}doPrepareChar(t,o){o===void 0&&(o={});let r;return[t,r]=super.doPrepareChar(t.replace(/\D/g,""),o),t||(r.skip=!this.isComplete),[t,r]}_appendCharRaw(t,o){if(o===void 0&&(o={}),!this.autofix||this.value.length+1>this.maxLength)return super._appendCharRaw(t,o);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],o):Number(a)>this.to?!o.tail&&this.autofix==="pad"&&this.value.length+1<this.maxLength?super._appendCharRaw(r[this.value.length],o).aggregate(this._appendCharRaw(t,o)):super._appendCharRaw(l[this.value.length],o):super._appendCharRaw(t,o)}doValidate(t){const o=this.value;if(o.search(/[^0]/)===-1&&o.length<=this._matchFrom)return!0;const[l,a]=this.boundaries(o);return this.from<=Number(a)&&Number(l)<=this.to&&super.doValidate(t)}pad(t){const o=new _e;if(this.value.length===this.maxLength)return o;const r=this.value,l=this.maxLength-this.value.length;if(l){this.reset();for(let a=0;a<l;++a)o.aggregate(super._appendCharRaw("0",t));r.split("").forEach(a=>this._appendCharRaw(a))}return o}}Ee.MaskedRange=tn;const Uf="d{.}`m{.}`Y";class yt extends qe{static extractPatternOptions(t){const{mask:o,pattern:r,...l}=t;return{...l,mask:$t(o)?o:r}}constructor(t){super(yt.extractPatternOptions({...yt.DEFAULTS,...t}))}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:o,pattern:r,blocks:l,...a}={...yt.DEFAULTS,...t},s=Object.assign({},yt.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:$t(o)?o:r,blocks:s})}doValidate(t){const o=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&o!=null&&(this.min==null||this.min<=o)&&(this.max==null||o<=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(yt.extractPatternOptions(t))}}yt.GET_DEFAULT_BLOCKS=()=>({d:{mask:tn,from:1,to:31,maxLength:2},m:{mask:tn,from:1,to:12,maxLength:2},Y:{mask:tn,from:1900,to:9999}}),yt.DEFAULTS={...qe.DEFAULTS,mask:Date,pattern:Uf,format:(n,t)=>{if(!n)return"";const o=String(n.getDate()).padStart(2,"0"),r=String(n.getMonth()+1).padStart(2,"0"),l=n.getFullYear();return[o,r,l].join(".")},parse:(n,t)=>{const[o,r,l]=n.split(".").map(Number);return new Date(l,r-1,o)}},Ee.MaskedDate=yt;class nn extends He{constructor(t){super({...nn.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(o=>{const{expose:r,...l}=Ht(o),a=ht({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...l});return r&&(this.exposeMask=a),a}):[])}_appendCharRaw(t,o){o===void 0&&(o={});const r=this._applyDispatch(t,o);return this.currentMask&&r.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(o))),r}_applyDispatch(t,o,r){t===void 0&&(t=""),o===void 0&&(o={}),r===void 0&&(r="");const l=o.tail&&o._beforeTailState!=null?o._beforeTailState._value:this.value,a=this.rawInputValue,s=o.tail&&o._beforeTailState!=null?o._beforeTailState._rawInputValue:a,c=a.slice(s.length),i=this.currentMask,d=new _e,u=i?.state;return this.currentMask=this.doDispatch(t,{...o},r),this.currentMask&&(this.currentMask!==i?(this.currentMask.reset(),s&&(this.currentMask.append(s,{raw:!0}),d.tailShift=this.currentMask.value.length-l.length),c&&(d.tailShift+=this.currentMask.append(c,{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 o=new _e;return t&&o.aggregate(this._applyDispatch("",{},t)),o.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var o,r;return{...t,_beforeTailState:((o=t._beforeTailState)==null?void 0:o.currentMaskRef)===this.currentMask&&((r=t._beforeTailState)==null?void 0:r.currentMask)||t._beforeTailState}}doDispatch(t,o,r){return o===void 0&&(o={}),r===void 0&&(r=""),this.dispatch(t,this,o,r)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,o){o===void 0&&(o={});let[r,l]=super.doPrepare(t,o);if(this.currentMask){let a;[r,a]=super.doPrepare(r,this.currentMaskFlags(o)),l=l.aggregate(a)}return[r,l]}doPrepareChar(t,o){o===void 0&&(o={});let[r,l]=super.doPrepareChar(t,o);if(this.currentMask){let a;[r,a]=super.doPrepareChar(r,this.currentMaskFlags(o)),l=l.aggregate(a)}return[r,l]}reset(){var t;(t=this.currentMask)==null||t.reset(),this.compiledMasks.forEach(o=>o.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 o=String(t);this.currentMask&&(this.currentMask.typedValue=t,o=this.currentMask.unmaskedValue),this.unmaskedValue=o}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,o){const r=new _e;return this.currentMask&&r.aggregate(this.currentMask.remove(t,o)).aggregate(this._applyDispatch()),r}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map(o=>o.state),currentMaskRef:this.currentMask,currentMask:(t=this.currentMask)==null?void 0:t.state}}set state(t){const{compiledMasks:o,currentMaskRef:r,currentMask:l,...a}=t;o&&this.compiledMasks.forEach((s,c)=>s.state=o[c]),r!=null&&(this.currentMask=r,this.currentMask.state=l),super.state=a}extractInput(t,o,r){return this.currentMask?this.currentMask.extractInput(t,o,r):""}extractTail(t,o){return this.currentMask?this.currentMask.extractTail(t,o):super.extractTail(t,o)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,o){return this.currentMask?this.currentMask.nearestInputPos(t,o):super.nearestInputPos(t,o)}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((o,r)=>{if(!t[r])return;const{mask:l,...a}=t[r];return Ln(o,a)&&o.maskEquals(l)}):super.maskEquals(t)}typedValueEquals(t){var o;return!!((o=this.currentMask)!=null&&o.typedValueEquals(t))}}nn.DEFAULTS={...He.DEFAULTS,dispatch:(n,t,o,r)=>{if(!t.compiledMasks.length)return;const l=t.rawInputValue,a=t.compiledMasks.map((s,c)=>{const i=t.currentMask===s,d=i?s.displayValue.length:s.nearestInputPos(s.displayValue.length,ge.FORCE_LEFT);return s.rawInputValue!==l?(s.reset(),s.append(l,{raw:!0})):i||s.remove(d),s.append(n,t.currentMaskFlags(o)),s.appendTail(r),{index:c,weight:s.rawInputValue.length,totalInputPositions:s.totalInputPositions(0,Math.max(d,s.nearestInputPos(s.displayValue.length,ge.FORCE_LEFT)))}});return a.sort((s,c)=>c.weight-s.weight||c.totalInputPositions-s.totalInputPositions),t.compiledMasks[a[0].index]}},Ee.MaskedDynamic=nn;class on extends qe{constructor(t){super({...on.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){const{enum:o,...r}=t;if(o){const l=o.map(c=>c.length),a=Math.min(...l),s=Math.max(...l)-a;r.mask="*".repeat(a),s&&(r.mask+="["+"*".repeat(s)+"]"),this.enum=o}super._update(r)}_appendCharRaw(t,o){o===void 0&&(o={});const r=Math.min(this.nearestInputPos(0,ge.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,c)=>{const i=l[0][c];c>=this.value.length||i===s.value||(s.reset(),s._appendChar(i,o))});const a=super._appendCharRaw(l[0][this.value.length],o);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,o){return t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),new gt("",t)}remove(t,o){if(t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),t===o)return new _e;const r=Math.min(super.nearestInputPos(0,ge.FORCE_RIGHT),this.value.length);let l;for(l=t;l>=0&&!(this.enum.filter(c=>this.matchValue(c,this.value.slice(r,l),r)).length>1);--l);const a=super.remove(l,o);return a.tailShift+=l-t,a}get isComplete(){return this.enum.indexOf(this.value)>=0}}on.DEFAULTS={...qe.DEFAULTS,matchValue:(n,t,o)=>n.indexOf(t,o)===o},Ee.MaskedEnum=on;class Mr extends He{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}Ee.MaskedFunction=Mr;var Fr;class Ye extends He{constructor(t){super({...Ye.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){const t="^"+(this.allowNegative?"[+|\\-]?":""),o="\\d*",r=(this.scale?"("+mo(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+o+r),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(mo).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(mo(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const o=t.split(this.radix);return o[0]=o[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),o.join(this.radix)}doPrepareChar(t,o){o===void 0&&(o={});const[r,l]=super.doPrepareChar(this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(o.input&&o.raw||!o.input&&!o.raw)?t.replace(this._mapToRadixRegExp,this.radix):t),o);return t&&!r&&(l.skip=!0),r&&!this.allowPositive&&!this.value&&r!=="-"&&l.aggregate(this._appendChar("-")),[r,l]}_separatorsCount(t,o){o===void 0&&(o=!1);let r=0;for(let l=0;l<t;++l)this._value.indexOf(this.thousandsSeparator,l)===l&&(++r,o&&(t+=this.thousandsSeparator.length));return r}_separatorsCountFromSlice(t){return t===void 0&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,o,r){return t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),[t,o]=this._adjustRangeWithSeparators(t,o),this._removeThousandsSeparators(super.extractInput(t,o,r))}_appendCharRaw(t,o){o===void 0&&(o={});const r=o.tail&&o._beforeTailState?o._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 c=!isNaN(s),i=!1;if(c){let f;this.min!=null&&this.min<0&&this.number<this.min&&(f=this.min),this.max!=null&&this.max>0&&this.number>this.max&&(f=this.max),f!=null&&(this.autofix?(this._value=this.format(f,this).replace(Ye.UNMASKED_RADIX,this.radix),i||(i=a===this._value&&!o.tail)):c=!1),c&&(c=!!this._value.match(this._numberRegExp))}let d;c?d=new _e({inserted:this._value.slice(a.length),rawInserted:i?"":t,skip:i}):(this._value=a,d=new _e),this._value=this._insertThousandsSeparators(this._value);const u=o.tail&&o._beforeTailState?o._beforeTailState._value:this._value,p=this._separatorsCountFromSlice(u);return d.tailShift+=(p-l)*this.thousandsSeparator.length,d}_findSeparatorAround(t){if(this.thousandsSeparator){const o=t-this.thousandsSeparator.length+1,r=this.value.indexOf(this.thousandsSeparator,o);if(r<=t)return r}return-1}_adjustRangeWithSeparators(t,o){const r=this._findSeparatorAround(t);r>=0&&(t=r);const l=this._findSeparatorAround(o);return l>=0&&(o=l+this.thousandsSeparator.length),[t,o]}remove(t,o){t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length),[t,o]=this._adjustRangeWithSeparators(t,o);const r=this.value.slice(0,t),l=this.value.slice(o),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,o){if(!this.thousandsSeparator)return t;switch(o){case ge.NONE:case ge.LEFT:case ge.FORCE_LEFT:{const r=this._findSeparatorAround(t-1);if(r>=0){const l=r+this.thousandsSeparator.length;if(t<l||this.value.length<=l||o===ge.FORCE_LEFT)return r}break}case ge.RIGHT:case ge.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 o=t;this.min!=null&&(o=Math.max(o,this.min)),this.max!=null&&(o=Math.min(o,this.max)),o!==t&&(this.unmaskedValue=this.format(o,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 o=this._removeThousandsSeparators(t).split(this.radix);return o[0]=o[0].replace(/^(\D*)(0*)(\d*)/,(r,l,a,s)=>l+s),t.length&&!/\d$/.test(o[0])&&(o[0]=o[0]+"0"),o.length>1&&(o[1]=o[1].replace(/0*$/,""),o[1].length||(o.length=1)),this._insertThousandsSeparators(o.join(this.radix))}_padFractionalZeros(t){if(!t)return t;const o=t.split(this.radix);return o.length<2&&o.push(""),o[1]=o[1].padEnd(this.scale,"0"),o.join(this.radix)}doSkipInvalid(t,o,r){o===void 0&&(o={});const l=this.scale===0&&t!==this.thousandsSeparator&&(t===this.radix||t===Ye.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,o,r)&&!l}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,Ye.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(Ye.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)||Ye.EMPTY_VALUES.includes(t)&&Ye.EMPTY_VALUES.includes(this.typedValue))&&!(t===0&&this.value==="")}}Fr=Ye,Ye.UNMASKED_RADIX=".",Ye.EMPTY_VALUES=[...He.EMPTY_VALUES,0],Ye.DEFAULTS={...He.DEFAULTS,mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[Fr.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:n=>n.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},Ee.MaskedNumber=Ye;const Rn={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function go(n,t,o){t===void 0&&(t=Rn.MASKED),o===void 0&&(o=Rn.MASKED);const r=ht(n);return l=>r.runIsolated(a=>(a[t]=l,a[o]))}function Dr(n,t,o,r){return go(t,o,r)(n)}Ee.PIPE_TYPE=Rn,Ee.createPipe=go,Ee.pipe=Dr;class Tr extends qe{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 o,r,l;const{repeat:a,...s}=Ht(t);this._blockOpts=Object.assign({},this._blockOpts,s);const c=ht(this._blockOpts);this.repeat=(o=(r=a??c.repeat)!=null?r:this.repeat)!=null?o: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:c},eager:c.eager,overwrite:c.overwrite,skipInvalid:c.skipInvalid,lazy:c.lazy,placeholderChar:c.placeholderChar,displayChar:c.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(ht(this._blockOpts)),this.mask+="m",this._blocks[this._blocks.length-1]}_appendCharRaw(t,o){o===void 0&&(o={});const r=new _e;for(let i=(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[i])!=null?s:u=!u&&this._allocateBlock(i);++i){var l,a,s,c;const p=d._appendChar(t,{...o,_beforeTailState:(c=o._beforeTailState)==null||(c=c._blocks)==null?void 0:c[i]});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,o){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;o!=null&&(s=(l=this._mapPosToBlock(o))==null?void 0:l.index),s==null&&(s=this._blocks.length-1);let c=0;for(let i=s;a<=i&&!this._blocks[i].unmaskedValue;--i,++c);c&&(this._blocks.splice(s-c+1,c),this.mask=this.mask.slice(c))}reset(){super.reset(),this._trimEmptyTail()}remove(t,o){t===void 0&&(t=0),o===void 0&&(o=this.displayValue.length);const r=super.remove(t,o);return this._trimEmptyTail(t,o),r}totalInputPositions(t,o){return t===void 0&&(t=0),o==null&&this.repeatTo===1/0?1/0:super.totalInputPositions(t,o)}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}}Ee.RepeatBlock=Tr;try{globalThis.IMask=Ee}catch{}const Pn=Object.freeze(Object.defineProperty({__proto__:null,ChangeDetails:_e,ChunksTailDetails:Nt,DIRECTION:ge,HTMLContenteditableMaskElement:fo,HTMLInputMaskElement:$r,HTMLMaskElement:Qt,InputMask:Nr,MaskElement:In,Masked:He,MaskedDate:yt,MaskedDynamic:nn,MaskedEnum:on,MaskedFunction:Mr,MaskedNumber:Ye,MaskedPattern:qe,MaskedRange:tn,MaskedRegExp:Ar,PIPE_TYPE:Rn,PatternFixedDefinition:ho,PatternInputDefinition:en,RepeatBlock:Tr,createMask:ht,createPipe:go,default:Ee,forceDirection:_r,normalizeOpts:Ht,pipe:Dr},Symbol.toStringTag,{value:"Module"})),Hf=async n=>{try{const t=new FormData;return t.append("unique","true"),t.append("file",n),(await(await fetch("/file/upload/uploads?id=&form=&table=",{method:"POST",body:t})).json())?.result}catch(t){console.error(t)}},qf=async(n,t,o)=>{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:c}=n,{tr:i}=s,d=o.fromSchema(n.state.schema),u=new DOMParser().parseFromString(l,"text/html").body,p=d.parse(u),f=i.replaceSelectionWith(p);return c(f),t.preventDefault(),!0}if(a){const{state:s,dispatch:c}=n,{tr:i}=s,d=i.insertText(a,s.selection.from,s.selection.to);return c(d),t.preventDefault(),!0}for(let s=0;s<r.length;s++){const c=r[s];if(c.type.startsWith("image/")){const i=c.getAsFile();if(i){const d=await Hf(i),{schema:u}=n.state,p=u.nodes.image.create({src:d?.file_path}),f=n.state.tr.replaceSelectionWith(p);return n.dispatch(f),t.preventDefault(),!0}}}}return!1},Kf="https://esm.sh",Ze="3.7.2",Lr="3.7.2",Wf=`?deps=@tiptap/core@${Ze},@tiptap/pm@${Lr}`,Je=n=>`${Kf}/${n}${Wf}`,Qe={core:Je(`@tiptap/core@${Ze}`),starterKit:Je(`@tiptap/starter-kit@${Ze}`),textStyle:Je(`@tiptap/extension-text-style@${Ze}`),table:Je(`@tiptap/extension-table@${Ze}`),highlight:Je(`@tiptap/extension-highlight@${Ze}`),subscript:Je(`@tiptap/extension-subscript@${Ze}`),superscript:Je(`@tiptap/extension-superscript@${Ze}`),link:Je(`@tiptap/extension-link@${Ze}`),image:Je(`@tiptap/extension-image@${Ze}`),textAlign:Je(`@tiptap/extension-text-align@${Ze}`),heading:Je(`@tiptap/extension-heading@${Ze}`),paragraph:Je(`@tiptap/extension-paragraph@${Ze}`),pmModel:Je(`@tiptap/pm@${Lr}/model`)},rn="__vs_form_tiptap_loader__",et=n=>import(n),ze=(n,t)=>n?.[t]||n?.default?.[t]||n?.default?.default?.[t]||n?.default||n,Ir={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;"},Gf=n=>n.extend({addOptions(){return{...this.parent?.(),levels:[1,2,3,4,5,6]}}}).extend({addAttributes(){return{...this.parent?.(),level:{default:1,renderHTML:t=>{const o=t.level||1;return{class:`heading-level-${o}`,style:Ir[o]||Ir[1]}}}}}}),Yf=n=>n.configure({HTMLAttributes:{style:"min-height: 1rem;"}}),Xf=(n,t,o,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 n.extend({addExtensions(){return[a.configure({HTMLAttributes:{class:"editor-content"},resizable:!0}),o,r,l]}})},Zf=n=>n.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:o})=>o().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run(),setFontSize:t=>({chain:o})=>o().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run(),setColor:t=>({chain:o})=>o().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run(),setBackgroundColor:t=>({chain:o})=>o().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Jf=n=>n.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 Qf(){if(typeof window>"u")return null;const n=window;return n[rn]||(n[rn]=Promise.all([et(Qe.core),et(Qe.starterKit),et(Qe.textStyle),et(Qe.table),et(Qe.highlight),et(Qe.subscript),et(Qe.superscript),et(Qe.link),et(Qe.image),et(Qe.textAlign),et(Qe.heading),et(Qe.paragraph),et(Qe.pmModel)]).then(([t,o,r,l,a,s,c,i,d,u,p,f,y])=>{const h=ze(t,"Editor"),k=ze(t,"Node"),g=ze(t,"Extension"),v=ze(o,"StarterKit"),x=ze(r,"TextStyle"),C=ze(l,"TableKit"),S=ze(l,"Table"),H=ze(l,"TableRow"),K=ze(l,"TableCell"),L=ze(l,"TableHeader"),B=ze(a,"Highlight"),_=ze(s,"Subscript"),$=ze(c,"Superscript"),R=ze(i,"Link"),V=ze(d,"Image"),T=ze(u,"TextAlign"),M=ze(p,"Heading"),O=ze(f,"Paragraph"),Q=ze(y,"DOMParser");if(!h||!k||!v||!x||!C||!S||!H||!K||!L||!B||!_||!$||!R||!V||!T||!M||!O||!Q)throw new Error("Failed to resolve one or more Tiptap modules");return{Editor:h,Extension:g,ProseMirrorDOMParser:Q,StarterKit:v,ExtendedTextStyle:Zf(x),Highlight:B,Subscript:_,Superscript:$,Link:R,Image:V,TextAlign:T,CustomHeading:Gf(M),CustomParagraph:Yf(O),CustomTableKit:Xf(C,S,H,K,L),Iframe:Jf(k)}}).catch(t=>{throw delete n[rn],t})),n[rn]}function eh(n){let t=!1;const o=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 Qf();if(!p)return null;const f=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:(y,h)=>qf(y,h,p.ProseMirrorDOMParser),handleKeyDown:(y,h)=>{if(h.key==="Tab"){const k=y.state,{$anchor:g}=k.selection;let v=!1;for(let x=g.depth;x>0;x--){const C=g.node(x);if(C&&(C.type.name==="bulletList"||C.type.name==="orderedList")){v=!0;break}}return v?!1:(h.preventDefault(),!0)}return!1}}});return o.value=e.markRaw(f),f}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(()=>o.value||null);return e.watch(o,d=>{d&&o.value.on("update",u=>{if(!t){t=!0;const p=u.editor.getHTML();n.modelValue,setTimeout(()=>{t=!1},10)}})}),{editor:o,editorInstance:s,focusEditor:()=>{o.value&&!o.value.isFocused&&o.value.commands.focus()},createEditor:a,destroyEditor:()=>{o.value&&(o.value.destroy(),o.value=null)},isLoading:r,loadError:l}}function th(n,t,o,{toEditorContent:r,toSourceContent:l}={}){const a=e.ref(!1),s=e.ref(""),c=e.ref(null);return{isHtmlMode:a,htmlContent:s,htmlTextarea:c,toggleHtmlMode:async u=>{if(a.value=u,u)n.value&&(s.value=l?await l(n.value.getHTML(),t):n.value.getHTML()),e.nextTick(()=>{c.value&&c.value.focus?.()});else if(n.value){const p=r?await r(s.value,t):s.value;n.value.commands.setContent(p,!0),e.nextTick(()=>{n.value?.commands?.focus?.()})}},onHtmlInput:u=>{s.value=u,o&&o("update:modelValue",u)}}}function nh(){const n=e.ref(!1);return{isFullscreen:n,toggleFullscreen:()=>{n.value=!n.value}}}const At=n=>n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),ln=n=>{let t=At(n||"");return t=t.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(o,r,l,a)=>{const s=a?` title="${At(a)}"`:"";return`<img src="${At(l)}" alt="${At(r)}"${s}>`}),t=t.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(o,r,l,a)=>{const s=a?` title="${At(a)}"`:"";return`<a href="${At(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},an=n=>/^\s*\d+\.\s+/.test(n),yo=n=>/^\s*[-*+]\s+/.test(n),Or=n=>/^\s*[-*+]\s+\[[ xX]\]\s+/.test(n),bo=n=>/^\s*>\s?/.test(n),ko=n=>/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(n),Rr=n=>n.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>ln(t.trim())),oh=(n,t)=>{const o=n[t],r=n[t+1];if(!o||!r||!o.includes("|")||!ko(r))return null;const l=Rr(o),a=[];let s=t+2;for(;s<n.length&&n[s].includes("|")&&n[s].trim()!=="";){const d=Rr(n[s]);a.push(`<tr>${d.map(u=>`<td>${u}</td>`).join("")}</tr>`),s+=1}const c=`<thead><tr>${l.map(d=>`<th>${d}</th>`).join("")}</tr></thead>`,i=a.length?`<tbody>${a.join("")}</tbody>`:"";return{html:`<table>${c}${i}</table>`,nextIndex:s}},rh=(n,t)=>{const o=an(n[t]),r=o?"ol":"ul",l=[];let a=t;for(;a<n.length;){const s=n[a];if(s.trim()===""||!(o?an(s):(yo(s)||Or(s))&&!an(s)))break;const i=s.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);if(i){const d=i[1].toLowerCase()==="x";l.push(`<li><input type="checkbox" disabled${d?" checked":""}> ${ln(i[2])}</li>`)}else{const d=s.replace(/^\s*(?:[-*+]|\d+\.)\s+/,"");l.push(`<li>${ln(d)}</li>`)}a+=1}return{html:`<${r}>${l.join("")}</${r}>`,nextIndex:a}},lh=(n,t)=>{const r=n[t].replace(/^```/,"").trim(),l=[];let a=t+1;for(;a<n.length&&!n[a].startsWith("```");)l.push(n[a]),a+=1;return{html:`<pre><code${r?` class="language-${At(r)}"`:""}>${At(l.join(`
|
|
6
6
|
`))}</code></pre>`,nextIndex:a<n.length?a+1:a}},ah=(n,t)=>{const o=[];let r=t;for(;r<n.length;){const l=n[r];if(l.trim()===""||l.startsWith("```")||/^#{1,6}\s+/.test(l)||/^---+$/.test(l.trim())||/^\*\*\*+$/.test(l.trim())||bo(l)||an(l)||yo(l)||r+1<n.length&&l.includes("|")&&ko(n[r+1]))break;o.push(l.trim()),r+=1}return{html:`<p>${ln(o.join(" "))}</p>`,nextIndex:r}},Pr=n=>{const o=(n||"").replace(/\r\n/g,`
|
|
7
7
|
`).split(`
|