@opengis/form 0.0.167 → 0.0.168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- (function(he,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):(he=typeof globalThis<"u"?globalThis:he||self,e(he.FormBuilder={},he.Vue,he.OpenGISCore,he.lucide))})(this,function(he,e,ue,q){"use strict";const Bo=e.defineComponent({__name:"vs-info-tooltip",props:{text:{}},setup(o){const t=o,n=e.ref(!1),r=e.ref({top:"0px",left:"0px"});function l(s){if(!t.text)return;const i=s.currentTarget.getBoundingClientRect();r.value={top:`${i.bottom+4}px`,left:`${Math.min(i.left,window.innerWidth-230)}px`},n.value=!0}function a(){n.value=!1}return(s,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("span",{class:"inline-flex items-center",onMouseenter:l,onMouseleave:a},[e.renderSlot(s.$slots,"default",{},()=>[e.createVNode(e.unref(q.Info),{class:"h-4 w-4 text-gray-400 cursor-help"})])],32),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.value&&s.text?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle(r.value),class:"fixed z-[9999] max-w-xs p-2 bg-gray-900 text-white text-xs rounded-lg shadow-lg pointer-events-none"},e.toDisplayString(s.text),5)):e.createCommentVNode("",!0)]))],64))}}),Qr={class:"w-full relative"},el={key:0,class:"text-[14px] font-medium text-gray-900 mb-2 flex items-center gap-1"},tl={class:"opacity-100"},nl={key:0,class:"text-red-500 text-[14px]"},ol={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},rl=e.defineComponent({__name:"vs-layout-default",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.computed(()=>typeof t.item?.label=="string"&&t.item.label?t.item.label:t.item?.ua||t.label||t.ua),r=e.computed(()=>!!n.value),l=e.computed(()=>!!t.item?.rules?.includes("required")),a=e.computed(()=>t.item?.info||"");return(s,i)=>(e.openBlock(),e.createElementBlock("div",Qr,[r.value?(e.openBlock(),e.createElementBlock("div",el,[e.createElementVNode("span",tl,e.toDisplayString(n.value),1),l.value?(e.openBlock(),e.createElementBlock("span",nl,"*")):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(Bo,{key:1,text:a.value},null,8,["text"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"default",e.mergeProps(s.$attrs,{class:{"opacity-60":s.item.disabled}})),s.error?(e.openBlock(),e.createElementBlock("span",ol,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0)]))}}),ll={class:"w-full relative flex flex-row items-center gap-2"},al={key:0,class:"text-red-500 text-[14px]"},sl={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},il=e.defineComponent({__name:"vs-layout-horizontal",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{default:()=>({container:12,label:3})}},setup(o){const t=o,n=e.computed(()=>t.item?.label||t.label||t.ua),r=e.computed(()=>t.item?.info||""),l=e.computed(()=>t.columns??{container:12,label:3}),a=e.computed(()=>{const{container:d,label:u}=l.value;return!d||d<=0?0:Math.min(Math.max(u??0,0),d)/d}),s=e.computed(()=>t.item?.type==="html"||a.value<=0?!1:!!n.value),i=e.computed(()=>{if(!s.value)return{};const d=`${a.value*100}%`;return{flexBasis:d,maxWidth:d}}),c=e.computed(()=>{const{container:d,label:u}=l.value;if(!d||d<=0)return{};if(t.item?.type==="html")return{flexBasis:"100%",maxWidth:"100%"};if(!s.value)return{flexBasis:"100%",maxWidth:"100%"};const p=Math.max(d-Math.max(u??0,0),0)/d;if(!p)return{};const g=`${p*100}%`;return{flexBasis:g,maxWidth:g}});return(d,u)=>(e.openBlock(),e.createElementBlock("div",ll,[s.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"text-sm text-gray-900 font-medium flex shrink-0 items-center gap-1",style:e.normalizeStyle(i.value)},[e.createTextVNode(e.toDisplayString(n.value)+" ",1),d.item?.rules?.includes("required")&&n.value?(e.openBlock(),e.createElementBlock("span",al,"*")):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createBlock(Bo,{key:1,text:r.value},null,8,["text"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"flex-1 min-w-0",style:e.normalizeStyle(c.value)},[e.renderSlot(d.$slots,"default",e.normalizeProps(e.guardReactiveProps(d.$attrs)))],4),d.error?(e.openBlock(),e.createElementBlock("span",sl,e.toDisplayString(d.error),1)):e.createCommentVNode("",!0)]))}}),cl={class:"w-full relative"},dl={key:0,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},ul=e.defineComponent({__name:"vs-layout-inline",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",cl,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(t.$attrs))),t.error?(e.openBlock(),e.createElementBlock("span",dl,e.toDisplayString(t.error),1)):e.createCommentVNode("",!0)]))}}),pl={class:"flex-1 min-w-0"},fl={key:0,class:"text-sm font-medium text-slate-700 dark:text-slate-200 flex items-center gap-1"},ml={class:"truncate"},hl={key:0,class:"text-red-500 text-[14px]"},gl=["innerHTML"],yl={key:0,class:"mt-1 text-xs text-red-500"},bl={default:rl,horizontal:il,inline:ul,settings:e.defineComponent({__name:"vs-layout-settings",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.ref("uk");e.computed(()=>(t.item??{})?.[n.value]??t.ua??t.label??"");const r=e.computed(()=>t.item?.description??""),l=e.computed(()=>Array.isArray(t.item?.rules)&&t.item.rules.includes("required")),a=e.computed(()=>(typeof t.error=="string"?t.error:"")??""),s=()=>{const i=typeof localStorage<"u"?localStorage.getItem("locale"):null;n.value=i||"uk"};return e.onMounted(()=>{try{typeof localStorage<"u"&&localStorage.locale&&(n.value=localStorage.locale)}catch{}window.addEventListener("storage",s)}),e.onUnmounted(()=>{window.removeEventListener("storage",s)}),(i,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-full relative",{"opacity-60":i.item?.disabled}])},[e.createElementVNode("div",{class:e.normalizeClass(["gap-2 md:flex-row md:items-center md:justify-between",[["switcher","native-select"].includes(i.item.type)?"flex flex-col":""]])},[e.createElementVNode("div",pl,[i.ua||i.label?(e.openBlock(),e.createElementBlock("p",fl,[e.createElementVNode("span",ml,e.toDisplayString(i.item[n.value]||i.ua||i.label),1),l.value?(e.openBlock(),e.createElementBlock("span",hl,"*")):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,gl)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["w-full",["select","native-select"].includes(i.item.type)?"md:w-[30%]":"md:w-auto"])},[e.renderSlot(i.$slots,"default",e.normalizeProps(e.guardReactiveProps(i.$attrs)))],2)],2),a.value?(e.openBlock(),e.createElementBlock("p",yl,e.toDisplayString(a.value),1)):e.createCommentVNode("",!0)],2))}})};function je(o){return{inputClass:e.computed(()=>{const n=`disabled:opacity-50 disabled:cursor-not-allowed outline-none focus:ring-2 focus:ring-ring focus:ring-${o?.primaryColor||"blue"}-500 border border-solid border-stone-200 rounded-md text-sm text-stone-800 placeholder:text-stone-400 `;return o?.size==="sm"?`${n}h-[32px]`:`${n}h-[38px]`})}}const kl=["placeholder","disabled"],xl=e.defineComponent({__name:"vs-input-password",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=je(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");return(s,i)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"password","onUpdate:modelValue":i[0]||(i[0]=c=>r.value=c),placeholder:a.value,disabled:l.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":s.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,kl)),[[e.vModelText,r.value]])}}),wl=["placeholder","disabled","maxlength","minlength"],zt=e.defineComponent({__name:"vs-input-text",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=je(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??""),s=e.computed(()=>t.maxlength??void 0),i=e.computed(()=>t.minlength??void 0);function c(){typeof r.value=="string"&&(r.value=r.value.trim())}return(d,u)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"text","onUpdate:modelValue":u[0]||(u[0]=p=>r.value=p),placeholder:a.value,disabled:l.value,maxlength:s.value,minlength:i.value,onBlur:c,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[d.customClass,e.unref(n),{"!border-red-600":d.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,wl)),[[e.vModelText,r.value]])}}),_l=["step","placeholder","disabled","min","max"],Vo=e.defineComponent({__name:"vs-input-number",props:e.mergeModels({style:{type:Object,default:()=>({})},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},min:{type:Number,default:void 0},max:{type:Number,default:void 0},step:{type:[Number,String],default:void 0}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=je(t.style),r=e.useAttrs(),l=e.useModel(o,"modelValue"),a=e.computed(()=>!!t.disabled),s=u=>{if(u==null||u==="")return;const p=typeof u=="string"?u.trim().replace(",","."):u,g=Number(p);return Number.isFinite(g)?g:void 0},i=e.computed(()=>s(t.min??r.min)),c=e.computed(()=>s(t.max??r.max)),d=e.computed(()=>{if(t.step!==void 0&&t.step!==null&&t.step!=="")return t.step;const u=r.step;return typeof u=="number"||typeof u=="string"?u:"any"});return(u,p)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"number",step:d.value,"onUpdate:modelValue":p[0]||(p[0]=g=>l.value=g),placeholder:o.placeholder,disabled:a.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"},min:i.value,max:c.value},null,10,_l)),[[e.vModelText,l.value]])}}),fn=o=>!!String(o??"").trim(),Vt=o=>o?.color?String(o.color):"",Wt=o=>{const t=o?.icon;if(typeof t=="string")return t;const n=o?.imgUrl;return typeof n=="string"?n:""},Gt=o=>{const t=o?.icon;return t&&typeof t!="string"?t:null},Cl={class:"flex items-center gap-[4px]"},vl=["value","id","disabled"],El=["for"],Bl=["innerHTML"],Vl={key:1,class:"text-[14px] text-gray-700 flex items-center gap-2 dark:text-neutral-400"},Sl=["src"],$l=e.defineComponent({__name:"vs-checkbox-default",props:{value:{default:""},label:{default:""},html:{default:""},disabled:{type:Boolean,default:!1},id:{},modelValue:{default:""},info:{},error:{},option:{default:null}},emits:["update:modelValue"],setup(o,{emit:t}){const n=t,r=o,l=e.computed({get:()=>r.modelValue,set:b=>n("update:modelValue",b)}),a=e.computed(()=>!!r.disabled),s=e.computed(()=>Wt(r.option)),i=e.computed(()=>Gt(r.option)),c=e.computed(()=>Vt(r.option)),d=e.computed(()=>!!(c.value&&!s.value&&!i.value)),u=e.computed(()=>!!(s.value&&c.value)),p=e.computed(()=>c.value?{color:c.value}:void 0),g=e.computed(()=>{if(!(!s.value||!c.value))return{backgroundColor:c.value,WebkitMaskImage:`url(${s.value})`,maskImage:`url(${s.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(b,m)=>(e.openBlock(),e.createElementBlock("div",Cl,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",value:b.value,"onUpdate:modelValue":m[0]||(m[0]=h=>l.value=h),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:b.id,disabled:a.value},null,10,vl),[[e.vModelCheckbox,l.value]]),e.createElementVNode("label",{for:b.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",b.error?"border-red-600":""]])},[e.createVNode(e.unref(q.Check),{class:"h-4 w-4"})],2),b.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:b.html},null,8,Bl)):(e.openBlock(),e.createElementBlock("span",Vl,[d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:c.value})},null,4)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(g.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,Sl)):i.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(p.value)},null,8,["style"])):e.createCommentVNode("",!0),e.renderSlot(b.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(b.label),1)])]))],10,El)]))}}),Nl=["name","value","disabled"],Al=["innerHTML"],Ml={key:1,class:"flex items-center gap-[6px] text-[14px]"},Fl={key:2,class:"text-[16px] inline-flex items-center justify-center"},Dl=["src"],Tl=e.defineComponent({__name:"vs-checkbox-buttons",props:{value:{type:[String,Number,Boolean],default:""},label:{default:""},html:{default:""},modelValue:{default:""},disabled:{type:Boolean},id:{},icon:{},imgUrl:{},style:{},option:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=e.computed({get:()=>n.modelValue,set:h=>{r("update:modelValue",h)}}),a=e.computed(()=>Array.isArray(l.value)?l.value.includes(n.value):l.value===!0||l.value===n.value),s=e.computed(()=>n.style?.size==="xs"?"p-1.5 text-xs":n.style?.size==="lg"?"p-3.5 text-[20px]":"p-2.5 text-xs"),i=e.computed(()=>({...n.option??{},icon:n.option?.icon??n.icon,imgUrl:n.option?.imgUrl??n.imgUrl,color:n.option?.color})),c=e.computed(()=>Wt(i.value)),d=e.computed(()=>Gt(i.value)),u=e.computed(()=>Vt(i.value)),p=e.computed(()=>!!(u.value&&!c.value&&!d.value)),g=e.computed(()=>!!(c.value&&u.value)),b=e.computed(()=>u.value?{color:u.value}:void 0),m=e.computed(()=>{if(!(!c.value||!u.value))return{backgroundColor:u.value,WebkitMaskImage:`url(${c.value})`,maskImage:`url(${c.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(h,y)=>(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:h.id,value:h.value,"onUpdate:modelValue":y[0]||(y[0]=w=>l.value=w),disabled:h.disabled},null,8,Nl),[[e.vModelCheckbox,l.value]]),h.html?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-full",innerHTML:h.html},null,8,Al)):(e.openBlock(),e.createElementBlock("span",Ml,[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),g.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(m.value)},null,4)):c.value||d.value?(e.openBlock(),e.createElementBlock("span",Fl,[c.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:c.value,width:"16",height:"16",alt:"icon"},null,8,Dl)):d.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),{key:1,class:"h-4 w-4",style:e.normalizeStyle(b.value)},null,8,["style"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(h.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(h.label),1)])]))],2))}}),Ll={class:"flex items-center"},qn=e.defineComponent({__name:"vs-input-checkbox-item",props:{value:{default:""},label:{default:""},labelHtml:{default:""},disabled:{type:Boolean,default:!1},view:{default:"default"},modelValue:{type:[Boolean,Array],default:!1},icon:{},imgUrl:{},slots:{},option:{},style:{},error:{default:""}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=`radio-${Math.floor(Math.random()*1e4)}`,a=e.computed({get:()=>Array.isArray(n.modelValue)?Array.isArray(n.modelValue)&&n.modelValue.includes(n.value):n.modelValue,set:i=>{if(Array.isArray(n.modelValue)){let c=[...n.modelValue];i?c.includes(n.value)||c.push(n.value):c=c.filter(d=>d!==n.value),r("update:modelValue",c)}else r("update:modelValue",i)}}),s=e.ref(`vs-checkbox-${n.view||"default"}`);return(i,c)=>(e.openBlock(),e.createElementBlock("div",Ll,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value==="vs-checkbox-buttons"?e.unref(Tl):e.unref($l)),{value:i.value,label:i.label,html:i.labelHtml,info:i.option?.info,disabled:i.disabled,modelValue:a.value,"onUpdate:modelValue":c[0]||(c[0]=d=>a.value=d),id:l,icon:i.icon,imgUrl:i.imgUrl,option:i.option,style:e.normalizeStyle(i.style),error:i.error},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.label),1)]),_:1},8,["value","label","html","info","disabled","modelValue","icon","imgUrl","option","style","error"]))]))}}),Il={key:0,class:"flex items-start gap-x-1"},Rl={key:0,class:"text-red-500 text-[14px]"},Ol=["title"],Pl=["disabled"],Kn=e.defineComponent({__name:"vs-input-switcher",props:e.mergeModels({rules:{default:()=>[]},view:{default:"checkbox"},label:{default:""},i:{default:""},text:{default:""},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue");return(r,l)=>t.view==="checkbox"?(e.openBlock(),e.createElementBlock("div",Il,[e.createVNode(qn,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),error:r.error||""},null,8,["modelValue","error"]),r.rules?.includes("required")?(e.openBlock(),e.createElementBlock("span",Rl,"*")):e.createCommentVNode("",!0),r.i?(e.openBlock(),e.createElementBlock("button",{key:1,class:"cursor-pointer",title:r.i,onClick:l[1]||(l[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(e.unref(q.Info),{class:"h-4 w-4 text-gray-500"})],8,Ol)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["inline-flex h-5 w-9 shrink-0 px-[2px] cursor-pointer items-center rounded-full shadow-sm disabled:cursor-not-allowed disabled:opacity-50",[n.value?`bg-${r.style?.primaryColor||"blue"}-500`:"bg-stone-200",r.customClass]]),disabled:r.disabled,onClick:l[2]||(l[2]=a=>n.value=!n.value)},[e.createElementVNode("span",{"data-state":"checked",class:e.normalizeClass(["pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform",[n.value?"translate-x-4":"translate-x-0"]])},null,2)],10,Pl))}}),zl=["id","innerHTML"],Wn=e.defineComponent({__name:"vs-input-static",props:{text:{default:""},html:{default:""},style:{},customClass:{default:""},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{id:t.name,class:e.normalizeClass(["text-gray-900",t.customClass]),innerHTML:t.html?t.html:t.text},null,10,zl))}}),jl=["placeholder","disabled","name"],mn=e.defineComponent({__name:"vs-input-mask",props:e.mergeModels({name:{},mask:{default:""},unmask:{type:Boolean,default:!1},placeholder:{default:"_"},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=je(t.style),r=e.useModel(o,"modelValue"),l=e.ref(null);let a=null;function s(i){const c={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},d=new Set;let u=!1;for(let g=0;g<i.length;g+=1){const b=i[g];b==="{"?u=!0:b==="}"?u=!1:u&&d.add(b)}const p={};return Object.keys(c).forEach(g=>{d.has(g)||(p[g]=c[g])}),{mask:i,definitions:p,lazy:!1}}return e.onMounted(async()=>{if(l.value){const{default:i}=await Promise.resolve().then(()=>Pn),c=s(t.mask||"");a=i(l.value,c),a.on("accept",()=>{r.value=t.unmask?a.unmaskedValue:a.value}),a.on("complete",()=>{r.value=t.unmask?a.unmaskedValue:a.value}),a.value=r.value!=null?String(r.value):""}}),e.onBeforeUnmount(()=>{a?.destroy()}),e.watch(()=>t.mask,i=>{if(a){const c=s(i||"");a.updateOptions(c)}}),e.watch(r,i=>{a&&a.unmaskedValue!==i&&(a.value=i!=null?String(i):"")}),(i,c)=>(e.openBlock(),e.createElementBlock("input",{type:"text",ref_key:"inputEl",ref:l,placeholder:i.placeholder,disabled:i.disabled,name:i.name,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,10,jl))}}),Ul={class:"relative w-full bg-white rounded-lg"},Hl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},ql=["placeholder","disabled"],Gn=e.defineComponent({__name:"vs-input-email",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=je(t.style),r=e.useModel(o,"modelValue");return(l,a)=>(e.openBlock(),e.createElementBlock("div",Ul,[e.createElementVNode("div",Hl,[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:l.placeholder,disabled:l.disabled,class:e.normalizeClass(["!pl-8 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":l.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,ql),[[e.vModelText,r.value]])]))}}),wt="+99(999)-999-99-99";function St(o){if(!o?.trim())return 0;const t=new Set(["9","0","a","A","*"]);let n=!1,r=0;for(let l=0;l<o.length;l+=1){const a=o[l];if(a==="{"){n=!0;continue}if(a==="}"){n=!1;continue}!n&&t.has(a)&&(r+=1)}return r}const Kl={class:"relative w-full bg-white rounded-lg"},Wl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] pointer-events-none"},Gl=["name","placeholder","disabled","pattern"],Yn=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(o){const t=o,n=e.computed(()=>`^\\+[1-9]\\d{${(St(t.mask||wt)||St(wt))-1}}$`),{inputClass:r}=je(t.style),l=e.useModel(o,"modelValue"),a=e.ref(null);let s=null;function i(u){const p={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},g=new Set;let b=!1;for(let h=0;h<u.length;h+=1){const y=u[h];y==="{"?b=!0:y==="}"?b=!1:b&&g.add(y)}const m={};return Object.keys(p).forEach(h=>{g.has(h)||(m[h]=p[h])}),{mask:u,definitions:m,lazy:!1,disabled:t.disabled}}function c(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=i(t.mask||"");s=u(a.value,p),s.on("accept",d),s.on("complete",d);const g=c(l.value);s.unmaskedValue=g}),e.onBeforeUnmount(()=>{s?.destroy(),s=null}),e.watch(()=>t.mask,u=>{s&&s.updateOptions(i(u||""))}),e.watch(()=>t.disabled,u=>{s&&s.updateOptions({disabled:u})}),e.watch(l,u=>{if(!s)return;const p=c(u);s.unmaskedValue!==p&&(s.unmaskedValue=p)}),(u,p)=>(e.openBlock(),e.createElementBlock("div",Kl,[e.createElementVNode("div",Wl,[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:u.name,placeholder:u.placeholder,disabled:u.disabled,pattern:n.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":u.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Gl)]))}}),Yl=["value","disabled"],Xl=["innerHTML"],Zl={key:1,class:"flex items-center gap-2"},Jl=["src"],Ql={class:"text-[13px] text-gray-700"},ea=e.defineComponent({__name:"vs-input-radio-default",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Wt(t.option)),a=e.computed(()=>Gt(t.option)),s=e.computed(()=>Vt(t.option)),i=e.computed(()=>!!(s.value&&!l.value&&!a.value)),c=e.computed(()=>!!(l.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),u=e.computed(()=>{if(!(!l.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${l.value})`,maskImage:`url(${l.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(p,g)=>(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":g[0]||(g[0]=b=>n.value=b),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,Yl),[[e.vModelRadio,n.value]]),e.createElementVNode("span",{class:e.normalizeClass(["w-[16px] shrink-0 h-[16px] border rounded-full flex items-center justify-center mr-[10px]",[`border-${t.style?.primaryColor||"blue"}-500`,r.value?"opacity-50 cursor-not-allowed":""]])},[n.value==t.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["w-[12px] h-[12px] shrink-0 rounded-full",[`bg-${t.style?.primaryColor||"blue"}-500`]])},null,2)):e.createCommentVNode("",!0)],2),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,Xl)):(e.openBlock(),e.createElementBlock("div",Zl,[i.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(u.value)},null,4)):l.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:l.value,alt:"icon"},null,8,Jl)):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",Ql,e.toDisplayString(t.text),1)]))],2))}}),ta=["value","disabled"],na=["innerHTML"],oa={key:1,class:"flex items-center gap-2"},ra=["src"],la={class:"text-[13px] text-gray-700"},aa={"vs-input-radio-default":ea,"vs-input-radio-buttons":e.defineComponent({__name:"vs-input-radio-buttons",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Wt(t.option)),a=e.computed(()=>Gt(t.option)),s=e.computed(()=>Vt(t.option)),i=e.computed(()=>!!(s.value&&!l.value&&!a.value)),c=e.computed(()=>!!(l.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),u=e.computed(()=>{if(!(!l.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${l.value})`,maskImage:`url(${l.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(p,g)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex h-full w-full items-center border rounded-lg px-2 py-1",[n.value==t.value?`ring-2 ring-ring ring-${t.style?.primaryColor||"blue"}-500`:"",t.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":g[0]||(g[0]=b=>n.value=b),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,ta),[[e.vModelRadio,n.value]]),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,na)):(e.openBlock(),e.createElementBlock("div",oa,[i.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(u.value)},null,4)):l.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:l.value,alt:"icon"},null,8,ra)):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",la,e.toDisplayString(t.text),1)]))],2))}})},So=o=>Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[],$o=o=>{const t=o.host??"",n=o.prefix??"api",r=o.api??`/${n}/suggest/${o.data}`;return`${t}${r}`},sa=o=>({fetchOptions:async(r="")=>{const l=o();if(!l.data)return l.options?[...l.options]:[];try{const a=new URLSearchParams;a.set("json","1"),r&&a.set("key",r),l.parentValue!==void 0&&l.parentValue!==null&&l.parentValue!==""&&a.set("parent",String(l.parentValue)),l.start===1&&a.set("start","1");const i=await(await fetch(`${$o(l)}?${a.toString()}`)).json();return So(i)}catch{return[]}},fetchOptionByValue:async r=>{if(r==null||r==="")return null;const l=o();if(!l.data)return(l.options??[]).find(s=>s?.id?.toString()===String(r))??null;try{const a=new URLSearchParams;a.set("json","1"),a.set("val",String(r)),l.parentValue!==void 0&&l.parentValue!==null&&l.parentValue!==""&&a.set("parent",String(l.parentValue)),l.start===1&&a.set("start","1");const i=await(await fetch(`${$o(l)}?${a.toString()}`)).json();return So(i)[0]??null}catch{return null}}}),hn=({props:o,formValues:t=null,watchParent:n=!0})=>{const r=e.ref([]),l=e.computed(()=>o.parent?t?.value?.[o.parent]?.toString?.()??null:null),{fetchOptions:a,fetchOptionByValue:s}=sa(()=>({data:o.data,options:o.options,api:o.api,prefix:o.prefix,host:o.host,start:o.start,parentValue:l.value})),i=async(c="")=>{const d=o.data?await a(c):o.options?[...o.options]:[];return r.value=d,r.value};return e.watch(()=>o.options,()=>{o.data||(r.value=o.options?[...o.options]:[])},{immediate:!0,deep:!0}),n&&e.watch(l,async()=>{o.data&&(r.value=await a())},{immediate:!1}),{optionsList:r,parentValue:l,fetchOptions:a,fetchOptionByValue:s,loadOptions:i}},ia=/\{\{\s*([^}]+?)\s*\}\}/g,ca=o=>(o?String(o):"").replace(/<[^>]*>/g,"").trim(),da=(o,t)=>t.split(".").reduce((n,r)=>n==null?n:n[r.trim()],o),gn=(o,t)=>{if(!o)return"";const n=(t??"").trim();return n?n.replace(ia,(r,l)=>{const a=String(l).trim(),s=o,c=(a.includes(".")?da(s,a):void 0)??s[a];return c!=null?String(c):""}):o.text??""},yn=(o,t)=>{if(!o)return"";const n=gn(o,t);return ca(n)||o.text||""},Xn=e.defineComponent({__name:"vs-input-radio",props:e.mergeModels({options:{},slot:{},data:{},api:{},prefix:{},host:{},start:{},parent:{},position:{default:"vertical"},view:{default:"default"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>aa[`vs-input-radio-${t.view}`]),l=e.computed(()=>t.slot??t?.optionTemplate??""),a=e.computed(()=>fn(l.value)),s=b=>gn(b,l.value),i=b=>yn(b,l.value),c=e.computed(()=>t.position==="horizontal"?"flex w-full flex-row flex-wrap gap-[10px]":"flex w-full flex-col gap-2"),d=e.computed(()=>{if(t.position==="horizontal"&&t.customClass?.includes("50%"))return{flex:"0 0 calc(50% - 5px)"}}),u=e.inject("values",null),{optionsList:p,loadOptions:g}=hn({props:t,formValues:u});return e.onMounted(async()=>{await g()}),(b,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p),h=>(e.openBlock(),e.createElementBlock("div",{key:h?.id,class:e.normalizeClass(["flex items-stretch",b.position==="horizontal"?t.customClass:""]),style:e.normalizeStyle(d.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),e.mergeProps({text:i(h),html:a.value?s(h):"",option:h,value:h.id.toString(),checked:n.value?.toString?.()===h.id?.toString?.(),"custom-class":b.position==="horizontal"?"":t.customClass,modelValue:n.value,"onUpdate:modelValue":m[0]||(m[0]=y=>n.value=y)},{ref_for:!0},b.$attrs),null,16,["text","html","option","value","checked","custom-class","modelValue"]))],6))),128))],2))}}),ua={key:1,class:"w-full flex flex-col gap-4"},pa={key:0,class:"text-sm font-medium text-muted-foreground my-2"},fa="Без категорії",ma=e.defineComponent({__name:"vs-input-checkbox",props:{options:{default:()=>[]},position:{default:"vertical"},slots:{default:null},slot:{},colSpan:{default:0},data:{},api:{},prefix:{},host:{},start:{},parent:{},view:{},group:{default:void 0},values:{default:()=>[]},style:{},customClass:{},disabled:{type:Boolean},modelValue:{default:!1},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=e.reactive({}),a=e.inject("values",null),{optionsList:s,loadOptions:i}=hn({props:{...n,options:n.options},formValues:a}),c=e.computed(()=>s.value),d=x=>x?.value||x?.id||x?.text||x,u=e.computed(()=>n.slot??n?.optionTemplate??""),p=e.computed(()=>fn(u.value)),g=x=>gn(x,u.value),b=x=>yn(x,u.value),m=x=>`lg:col-span-${x||12}`,h=e.computed(()=>[n.position==="vertical"?"flex flex-col":"",n.colSpan?"grid":"flex justify-start"]),y=x=>x==null||x===""?null:typeof x=="string"||typeof x=="number"?x:String(x),w=e.computed(()=>{if(!n.group)return[];const x=new Map;c.value.forEach(T=>{const E=T[n.group],$=y(E);x.has($)||x.set($,[]),x.get($)?.push(T)});const C=[];n.values?.length&&n.values.forEach(T=>{const E=y(T);C.push(E)});const S=new Set,H=T=>{const E=x.get(T)||[];if(!E.length)return null;const $=T===null?"group-null":`group-${String(T)}`,N=T===null?fa:String(T);return S.add(T),{key:$,label:N,options:E}},W=[];return C.forEach(T=>{const E=H(T);E&&W.push(E)}),x.forEach((T,E)=>{if(S.has(E))return;const $=H(E);$&&W.push($)}),W});return e.watch(()=>n.modelValue,x=>{if(typeof x=="boolean"&&c.value.length===1){const C=d(c.value[0]);l[C]=x}else if(Array.isArray(x)){const C=new Set(x);c.value.forEach(S=>{if(!S.disabled){const H=d(S);l[H]=C.has(H)}})}},{immediate:!0}),e.watch(l,()=>{if(!c.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 i(),typeof n.modelValue=="boolean"&&c.value.length===1){const x=d(c.value[0]);l[x]=n.modelValue}else if(Array.isArray(n.modelValue)){const x=new Set(n.modelValue);c.value.forEach(C=>{if(!C.disabled){const S=d(C);l[S]=x.has(S)}})}}),(x,C)=>n.group?(e.openBlock(),e.createElementBlock("div",ua,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,S=>(e.openBlock(),e.createElementBlock("div",{key:S.key,class:"flex flex-col gap-2"},[S.label?(e.openBlock(),e.createElementBlock("span",pa,e.toDisplayString(S.label),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-0 w-full gap-[12px]",h.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(S.options,H=>(e.openBlock(),e.createBlock(qn,{modelValue:l[d(H)],"onUpdate:modelValue":W=>l[d(H)]=W,value:d(H),class:e.normalizeClass(m(x.colSpan)),disabled:n.disabled||H.disabled,label:b(H),labelHtml:p.value?g(H):"",key:`${S.key}-${d(H)}`,icon:H?.icon,imgUrl:H?.imgUrl,option:H,view:x.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]",h.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,S=>(e.openBlock(),e.createBlock(qn,{modelValue:l[d(S)],"onUpdate:modelValue":H=>l[d(S)]=H,value:d(S),class:e.normalizeClass(m(x.colSpan)),disabled:n.disabled||S.disabled,label:b(S),labelHtml:p.value?g(S):"",key:d(S),icon:S?.icon,imgUrl:S?.imgUrl,option:S,view:x.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2))}}),ye=(o,t)=>{const n=o.__vccOpts||o;for(const[r,l]of t)n[r]=l;return n},No=ye(ma,[["__scopeId","data-v-9056e0ec"]]),ha=["type","placeholder","disabled"],ga=e.defineComponent({__name:"vs-input-date1",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},mode:{default:"date"}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o;function r(u){return u?n.mode==="datetime"?(u.includes("T")?u:null)||u+(u.includes(" ")?"":"T00:00"):u?.split(" ")[0]:null}const{inputClass:l}=je(n.style),a=t,s=e.computed({get:()=>r(n.modelValue),set:u=>a("update:modelValue",u)}),i=e.computed(()=>n.mode==="datetime"?"datetime-local":n.mode),c=e.computed(()=>!!n.disabled),d=e.computed(()=>n.placeholder??"");return(u,p)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:i.value,"onUpdate:modelValue":p[0]||(p[0]=g=>s.value=g),placeholder:d.value,disabled:c.value,ref:"date",class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[u.modelValue?"":"text-opacity-50",e.unref(l)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,ha)),[[e.vModelDynamic,s.value]])}}),ya=(o,t)=>{if(!t||!Object.keys(t).length)return o;const[n,r=""]=o.split("?"),l=new URLSearchParams(r);Object.entries(t).forEach(([s,i])=>{i==null||i===""||l.set(s,String(i))});const a=l.toString();return a?`${n}?${a}`:n},Ao=async(o,t={})=>{try{const n=new FormData;n.append("unique","true"),n.append("file",o);const{api:r,id:l="1",form:a="form",table:s="table",customParams:i}=t,c=r||`/file/upload/uploads?id=${l||""}&form=${a||""}&table=${s||""}`,d=ya(c,i);return(await fetch(d,{method:"POST",body:n}).then(p=>p.json()))?.result}catch(n){return ue.notify({type:"error",title:"Помилка!",message:"Сталась помилка під час завантаження файлу",position:"right-bottom"}),console.error("Сталась помилка завантаження файлу",n),null}},ba=async o=>{try{return await fetch(`file/delete${o}`),!0}catch(t){return console.error(t),!1}},Mo=async o=>{try{const t=await fetch(`/file/download${o}`);if(!t.ok)throw new Error(`Download failed with status ${t.status}`);const n=await t.blob(),l=(t.headers.get("content-disposition")||"").match(/filename\*?=(?:UTF-8''|")?([^\";]+)/i),a=l?.[1]?decodeURIComponent(l[1].replace(/"/g,"").trim()):"",s=o.split("/").filter(Boolean).pop()||"download",i=a||s,c=document.createElement("a");c.setAttribute("download",i),c.href=window.URL.createObjectURL(n),c.click(),window.URL.revokeObjectURL(c.href)}catch(t){console.error(t.message)}},ka=o=>{if(!o)return"";const t=o?.split(".");return t[t.length-1]},xa=o=>{const t=ka(o),n={imageFormat:["tiff","jpg","jpeg","png","svg","ico","webp"],sheetsFormat:["xls","csv","xlsx"],archivesFormat:["zip","rar"],textsFormat:["json","geojson","txt","yml","yaml","shp"],documentsFormat:["pdf"]};return n.imageFormat.includes(t)?"img":n.sheetsFormat.includes(t)?q.Table:n.textsFormat.includes(t)?q.FileCode:n.documentsFormat.includes(t)?q.FileText:n.archivesFormat.includes(t)?q.FileArchive:q.FileText},wa=["title"],_a={class:"absolute hidden top-0 right-0 flex items-center gap-x-2 w-full h-full justify-center"},Zn=ye(e.defineComponent({__name:"vs-input-file-list-item",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{value:{},valueModifiers:{},item:{},itemModifiers:{}}),emits:["update:value","update:item"],setup(o){const t=e.useModel(o,"value"),n=e.useModel(o,"item"),r=o,l=e.computed(()=>n.value?typeof n.value=="string"?n.value:n.value.file_path:""),a=c=>typeof c=="string"?c:c?.file_path||"",s=()=>{const c=l.value;ba(c),r.multiple&&Array.isArray(t.value)?t.value=t.value.filter(d=>a(d)!==c):t.value=""},i=()=>{l.value&&window.open(l.value,"_blank")};return(c,d)=>(e.openBlock(),e.createElementBlock("div",{title:l.value,class:"h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg overflow-hidden relative item-file"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(xa)(l.value)),{src:l.value,alt:"file",class:"w-full h-full object-cover cursor-pointer",onClick:d[0]||(d[0]=u=>e.unref(Mo)(l.value))},null,8,["src"])),e.createElementVNode("div",_a,[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:i,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-emerald-600"},[e.createVNode(e.unref(q.Eye),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:d[1]||(d[1]=u=>e.unref(Mo)(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,wa))}}),[["__scopeId","data-v-89357cbb"]]),Ca={class:"flex items-center gap-x-2"},va=["accept","multiple","disabled"],Ea={key:1,class:"flex items-center flex-wrap gap-2"},Ba={key:1,class:"loader"},Va={key:1,class:"loader"},Fo=ye(e.defineComponent({__name:"vs-input-file",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["change"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),l=t,a=e.computed(()=>{const x=r.value;return!n.multiple||!Array.isArray(x)?[]:x}),s=e.ref(null),i=e.ref(!1),c=e.inject("values"),d=e.computed(()=>n.format?n.format.split(",").map(x=>x.trim().toLowerCase()).filter(Boolean):[]),u=x=>{if(n.max_size&&x.size>n.max_size*1024*1024){const C=(x.size/1048576).toFixed(2);return ue.notify({type:"error",title:"Помилка!",message:`Файл "${x.name}" занадто великий. Максимальний розмір: ${n.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||ue.notify({type:"error",title:"Помилка!",message:`Неприпустимий формат файлу "${x.name}". Дозволені формати: ${d.value.join(", ")}`,position:"right-bottom"}),S},g=e.computed(()=>{const x={},C=[];if(!n.customParams?.length)return{params:x,missingSources:C};const S=c?.value??{};return n.customParams.forEach(H=>{if(!H)return;const[W,T]=H.split("="),E=W?.trim(),$=T?.trim();if(!E||!$)return;const N=S[$];if(N==null||N===""){C.push($);return}x[E]=N}),{params:x,missingSources:C}}),b=()=>{const{params:x}=g.value;return{api:n.api,customParams:Object.keys(x).length?x:void 0}},m=()=>{const x=g.value.missingSources;if(!x.length)return!0;const C=x.join(", ");return ue.notify({type:"warning",title:"Заповніть поля",message:`Поля (${C}) необхідні для завантаження файлу`,position:"right-bottom"}),!1},h=x=>{ue.notify({type:"error",title:"Помилка завантаження",message:x||"Не вдалося завантажити файл. Спробуйте ще раз.",position:"right-bottom"})},y=()=>{n.disabled||i.value||m()&&s.value?.click()},w=async x=>{const{files:C}=x.target;if(!C||C.length===0)return;if(!m()){s.value&&(s.value.value="");return}const S=Array.from(C);if(n.max_size&&S.filter(T=>!u(T)).length>0){s.value&&(s.value.value="");return}if(S.filter(W=>!p(W)).length>0){s.value&&(s.value.value="");return}i.value=!0;try{if(n.multiple){const W=Array.from(C).map(async V=>await Ao(V,b())),T=await Promise.all(W),E=T.filter(V=>V?.file_path);if(E.length===0){h();return}E.length<T.length&&h("Деякі файли не вдалося завантажити. Перевірте їх та спробуйте знову.");const $=E.map(V=>V.file_path),N=Array.isArray(r.value)?r.value:[];r.value=[...N,...$],l("change",r.value)}else{const W=C[0],T=await Ao(W,b());if(!T?.file_path){h();return}const E=T.file_path;r.value=E,l("change",E)}}catch(W){const T=W?.message||void 0;h(T)}finally{i.value=!1,s.value&&(s.value.value="")}};return(x,C)=>(e.openBlock(),e.createElementBlock("div",Ca,[e.createElementVNode("input",{class:"hidden",ref_key:"fileInput",ref:s,type:"file",accept:n.format,multiple:x.multiple,onChange:w,disabled:i.value||x.disabled},null,40,va),!x.multiple&&r.value&&!Array.isArray(r.value)?(e.openBlock(),e.createBlock(Zn,{key:0,item:r.value,value:r.value,"onUpdate:value":C[0]||(C[0]=S=>r.value=S)},null,8,["item","value"])):x.multiple?(e.openBlock(),e.createElementBlock("div",Ea,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(S,H)=>(e.openBlock(),e.createBlock(Zn,{multiple:x.multiple,key:H,value:r.value,"onUpdate:value":C[1]||(C[1]=W=>r.value=W),item:S},null,8,["multiple","value","item"]))),128)),e.createElementVNode("div",{onClick:y,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",x.disabled||i.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500 hover:bg-blue-50"])},[i.value?(e.openBlock(),e.createElementBlock("div",Ba)):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:0,class:"h-4 w-4"}))],2)])):e.createCommentVNode("",!0),x.multiple?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:2,onClick:y,class:e.normalizeClass([x.disabled||i.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500","relative h-[120px] w-[120px] border text-gray-300 hover:text-blue-500 border-dashed border-gray-300 rounded-lg flex items-center justify-center cursor-pointer hover:border-blue-500 transition-all duration-300 hover:bg-blue-50"])},[i.value?(e.openBlock(),e.createElementBlock("div",Va)):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:0,class:"h-4 w-4"}))],2))]))}}),[["__scopeId","data-v-dda91e05"]]),Sa={class:"vs-input-file2 flex flex-col gap-4"},$a={class:"flex items-center gap-x-2"},Na=["accept","disabled"],Aa={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"},Ma={key:0,class:"rounded-lg border border-[#CFD9E0] bg-white p-4 shadow-sm"},Fa={class:"flex items-center justify-between text-sm"},Da={class:"truncate pr-4"},Ta={class:"font-medium text-slate-800 truncate"},La={class:"text-slate-500"},Ia={class:"text-slate-500 whitespace-nowrap"},Ra={class:"mt-3 h-2 rounded-full bg-slate-100 overflow-hidden"},Oa={class:"mt-3 flex flex-wrap gap-2 text-sm"},Pa={key:0,class:"mt-2 text-sm text-rose-600"},za=e.defineComponent({__name:"vs-input-file2",props:e.mergeModels({format:{},max_size:{},api:{},chunkSize:{default:5*1024*1024},subdir:{default:""},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(null),l=e.ref(null),a=e.ref(""),s=e.ref(0),i=e.ref(!1),c=e.ref(""),d=e.ref(null),u=e.inject("values"),p=e.computed(()=>t.format?t.format.split(",").map(M=>M.trim().toLowerCase()).filter(Boolean):[]),g=e.computed(()=>!l.value||!l.value.size?0:Math.min(100,Math.round(s.value/l.value.size*100))),b=e.computed(()=>l.value?`${y(s.value)} / ${y(l.value.size)}`:""),m=e.computed(()=>t.disabled?"opacity-50 cursor-not-allowed":i.value?"cursor-default text-blue-500":"cursor-pointer hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500"),h=()=>{t.disabled||i.value||S()&&r.value?.click()},y=M=>{if(!Number.isFinite(M))return"0 B";const O=["B","KB","MB","GB"];let B=0,K=M;for(;K>=1024&&B<O.length-1;)K/=1024,B+=1;return`${K.toFixed(B===0?0:1)} ${O[B]}`},w=M=>{if(!t.max_size)return!0;const O=t.max_size*1024*1024;return M.size>O?(ue.notify({type:"error",title:"Файл занадто великий",message:`Максимальний розмір ${t.max_size} МБ`,position:"right-bottom"}),!1):!0},x=M=>{if(!p.value.length)return!0;const O=`.${M.name.split(".").pop()?.toLowerCase()||""}`;return p.value.includes(O)?!0:(ue.notify({type:"error",title:"Непідтримуваний формат",message:`Дозволені формати: ${p.value.join(", ")}`,position:"right-bottom"}),!1)},C=e.computed(()=>{const M={},O=[];if(!t.customParams?.length)return{params:M,missing:O};const B=u?.value??{};return t.customParams.forEach(K=>{if(!K)return;const[I,G]=K.split("="),L=I?.trim(),Z=G?.trim();if(!L||!Z)return;const oe=B[Z];oe==null||oe===""?O.push(Z):M[L]=oe}),{params:M,missing:O}}),S=()=>C.value.missing.length?(ue.notify({type:"warning",title:"Заповніть поля",message:`Потрібні значення: ${C.value.missing.join(", ")}`,position:"right-bottom"}),!1):!0,H=M=>{const O=M.target,B=O.files?.[0];if(B){if(!S()){O.value="";return}if(!w(B)||!x(B)){O.value="";return}l.value=B,s.value=0,a.value="",c.value=""}},W=async()=>{if(!l.value){h();return}try{c.value="";const M={id:a.value||"",fileName:l.value.name,subdir:t.subdir,size:l.value.size,...C.value.params},O=await fetch("/api/file/upload2/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)});if(!O.ok)throw new Error("Не вдалося ініціалізувати завантаження");const B=await O.json();a.value=B.id||a.value,s.value=B.uploaded||0,await T()}catch(M){c.value=M?.message||"Помилка при старті завантаження"}},T=async()=>{if(!(!l.value||!a.value)){i.value=!0;try{for(;s.value<l.value.size;){const M=s.value,O=Math.min(M+t.chunkSize,l.value.size),B=l.value.slice(M,O);d.value=new AbortController;const K=await fetch(`/api/file/upload2/${a.value}`,{method:"PATCH",headers:{"Content-Range":`bytes ${M}-${O-1}/${l.value.size}`},body:B,signal:d.value.signal});if(!K.ok)throw new Error("Помилка завантаження частини");const I=await K.json().catch(()=>({}));if(I.uploaded!=null?s.value=Number(I.uploaded):s.value=O,I.finished||s.value>=l.value.size){i.value=!1;const G=I.file_path||I.url||a.value;n.value={file_id:I.file_id??a.value??G,file_path:G},ue.notify({type:"success",title:"Файл завантажено",message:l.value.name,position:"right-bottom"}),V();return}}}catch(M){if(M?.name==="AbortError")return;c.value=M?.message||"Помилка при завантаженні",i.value=!1}finally{d.value=null,i.value=!1}}},E=()=>{i.value&&(d.value?.abort(),d.value=null,i.value=!1)},$=async()=>{if(l.value){if(!a.value){await W();return}await T()}},N=()=>{d.value?.abort(),d.value=null,V()},V=()=>{const M=r.value;M&&(M.value=""),l.value=null,a.value="",s.value=0,c.value=""};return(M,O)=>(e.openBlock(),e.createElementBlock("div",Sa,[e.createElementVNode("div",$a,[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",class:"hidden",accept:t.format,disabled:i.value||t.disabled,onChange:H},null,40,Na),n.value?(e.openBlock(),e.createBlock(Zn,{key:0,item:n.value,"onUpdate:item":O[0]||(O[0]=B=>n.value=B),value:n.value,"onUpdate:value":O[1]||(O[1]=B=>n.value=B)},null,8,["item","value"])):(e.openBlock(),e.createElementBlock("div",{key:1,onClick:h,class:e.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",m.value])},[i.value?(e.openBlock(),e.createElementBlock("div",Aa,[O[2]||(O[2]=e.createElementVNode("div",{class:"loader"},null,-1)),e.createElementVNode("span",null,e.toDisplayString(g.value)+"%",1)])):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:1,class:"h-4 w-4"}))],2))]),l.value&&!n.value?(e.openBlock(),e.createElementBlock("div",Ma,[e.createElementVNode("div",Fa,[e.createElementVNode("div",Da,[e.createElementVNode("div",Ta,e.toDisplayString(l.value.name),1),e.createElementVNode("div",La,e.toDisplayString(y(l.value.size)),1)]),e.createElementVNode("div",Ia,e.toDisplayString(b.value),1)]),e.createElementVNode("div",Ra,[e.createElementVNode("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-300",style:e.normalizeStyle({width:`${g.value}%`})},null,4)]),e.createElementVNode("div",Oa,[!i.value&&s.value>0&&s.value<(l.value?.size||0)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:$}," Resume ")):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:E}," Pause ")):e.createCommentVNode("",!0),!i.value&&s.value===0?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:W}," Upload ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"rounded border border-rose-200 px-3 py-1 text-rose-600",onClick:N}," Cancel ")]),c.value?(e.openBlock(),e.createElementBlock("p",Pa,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]))}}),Jn=ye(za,[["__scopeId","data-v-19ea2129"]]),ja={class:"flex items-center justify-center h-[30px] w-[30px]"},Ua={class:"max-w-[55vw]"},Ha={class:"text-sm font-semibold text-gray-800 truncate dark:text-neutral-200"},qa={class:"flex items-center text-xs text-gray-500 truncate dark:text-neutral-500"},Ka={class:"px-[5px]"},Wa={class:""},bn=e.defineComponent({__name:"vs-widget-file-info",props:{item:{default:null}},setup(o){const t=o,n=e.computed(()=>{try{return new Date(t.item.cdate).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}});function r(l){if(l<1024)return`${l} B`;const a=l/1024;return a<1024?`${a.toFixed(2)} KB`:`${(a/1024).toFixed(2)} MB`}return(l,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ja,[e.createVNode(e.unref(q.FileText),{class:"icon icon-tabler icons-tabler-outline icon-tabler-file h-4 w-4"})]),e.createElementVNode("div",Ua,[e.createElementVNode("p",Ha,e.toDisplayString(l.item?.uploaded_name),1),e.createElementVNode("p",qa,[e.createElementVNode("span",null,e.toDisplayString(l.item?.username),1),e.withDirectives(e.createElementVNode("span",Ka,"|",512),[[e.vShow,l.item?.username]]),e.createElementVNode("span",null,e.toDisplayString(n.value),1),a[0]||(a[0]=e.createElementVNode("span",{class:"px-[5px]"},"|",-1)),e.createElementVNode("span",Wa,e.toDisplayString(r(l.item?.size)),1)])])],64))}}),Ga={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-md w-full"},Ya={key:0,class:"flex w-full gap-x-3 items-center"},Xa={key:1,class:"flex gap-x-3 w-full items-center"},Za={key:2,class:"flex gap-x-3 w-full items-center"},Ja=["href"],Qa={key:3,class:"flex gap-x-3 w-full items-center"},es={class:"lg:absolute lg:top-3 lg:end-1 opacity-100"},ts={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"},ns={class:"inline-block"},os={class:"inline-block"},rs={class:"inline-block"},ls=e.defineComponent({__name:"vs-widget-file-item",props:{item:{default:null},index:{default:0},prefix:{default:"/api"}},emits:["update","openModal","openLightbox"],setup(o,{emit:t}){const n=o,r=t;function l(p){return["pdf","json"].includes(p.ext)}function a(p){return["ppt","pptx","doc","docx","xls","xlsx"].includes(p.ext)}function s(p){const g=document.createElement("a");g.setAttribute("download",p?.uploaded_name),g.href=p?.file_path,g.click()}function i(p){p?.file_path&&window.open(p.file_path,"_blank")}async function c(){try{await fetch(`${n.prefix}/widget/file/${n.item.entity_id}/${n.item.file_id}`),r("update")}catch(p){console.error(p)}}function d(){r("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:c,updateListOnConfirm:!0})}function u(p){(n.item.ext==="jpg"||n.item.ext==="png")&&r("openLightbox",{item:n.item,index:p})}return(p,g)=>(e.openBlock(),e.createElementBlock("div",Ga,[p.item.ext==="jpg"||p.item.ext==="png"?(e.openBlock(),e.createElementBlock("div",Ya,[e.createElementVNode("div",{class:"max-w-[55vw] cursor-pointer flex gap-x-3 w-full items-center",onClick:g[0]||(g[0]=b=>u(p.index))},[e.createVNode(bn,{item:p.item},null,8,["item"])])])):l(p.item)?(e.openBlock(),e.createElementBlock("div",Xa,[e.createVNode(bn,{item:p.item},null,8,["item"])])):a(p.item)?(e.openBlock(),e.createElementBlock("div",Za,[e.createElementVNode("a",{href:`/api/file-preview?id=${p.item.file_id}`,target:"_blank",class:"flex gap-x-3 w-full items-center"},[e.createVNode(bn,{item:p.item},null,8,["item"])],8,Ja)])):(e.openBlock(),e.createElementBlock("div",Qa,[e.createVNode(bn,{item:p.item},null,8,["item"])])),e.createElementVNode("div",es,[e.createElementVNode("div",ts,[e.createElementVNode("div",ns,[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:g[1]||(g[1]=b=>i(p.item))},[e.createVNode(e.unref(q.Eye),{class:"h-4 w-4"})])]),e.createElementVNode("div",os,[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:g[2]||(g[2]=b=>s(p.item))},[e.createVNode(e.unref(q.Download),{class:"h-4 w-4"})])]),g[4]||(g[4]=e.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),e.createElementVNode("div",rs,[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:g[3]||(g[3]=b=>d())},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})])])])])]))}}),as={class:"flex flex-col widget-file xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700 w-full"},ss={class:"flex w-full mb-[12px] items-center gap-x-2"},is={class:"font-semibold text-gray-800 dark:text-neutral-200 text-[14px]"},cs={class1:"ml-auto"},ds={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"},us={key:0,class:"py-4 mb-4 space-y-4 border-gray-200 border-y dark:border-neutral-700"},ps={class:"relative"},fs={class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-[1] ps-3.5"},ms={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"},hs={key:0},Do=e.defineComponent({__name:"vs-input-file-list",props:{id:{default:""},prefix:{default:"/api"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update"],setup(o,{emit:t}){const n=o,r=e.inject("form"),l=e.computed(()=>r.value.formId),a=e.ref(!1),s=e.ref(0),i=t,c=e.ref(!1),d=e.ref({}),u=e.ref([]),p=e.ref(""),g=e.computed(()=>Array.isArray(u.value)?u.value.filter(C=>C.ext==="jpg"||C.ext==="png").map(C=>C?.file_path):[]),b=e.computed(()=>p.value===""?u.value:u.value.filter(C=>C?.uploaded_name?.includes(p.value))),m=C=>{const S=g.value.findIndex(H=>H===C.item.file_path);S!==-1&&(a.value=!0,s.value=S)},h=async()=>{try{const C=await fetch(`${n.prefix}/widget/file/${l.value}`).then(S=>S.json());u.value=C?.rows}catch(C){console.error(C)}},y=async C=>{await Promise.all(Array.from(C.target.files).map(async S=>{const H=new FormData;H.append("file",S);try{const W=`${n.prefix}/widget/file/${l.value}`,T=await fetch(W,{method:"POST",body:H});return T.ok?(i("update","file-list"),S):(ue.notify({type:T.status>=400&&T.status<500?"warning":"error",title:"Error",message:`Error code: ${T.status}`}),null)}catch(W){return ue.notify({type:"error",title:"Error",message:W.message||"Unknown error"}),console.error(W),null}})),await h()},w=C=>{const S={...C};return C.cancel||(S.cancel=()=>{c.value=!1}),C.updateListOnConfirm&&(S.confirm=async()=>{await C.confirm(),c.value=!1,h()}),S},x=C=>{d.value=w(C),c.value=!0};return e.watch(l,C=>{C&&h()}),e.onMounted(()=>{l.value&&h()}),(C,S)=>{const H=e.resolveComponent("Lightbox"),W=e.resolveComponent("MessageBox");return e.openBlock(),e.createElementBlock("div",as,[e.createElementVNode("div",ss,[e.createElementVNode("h2",is," Файлів: "+e.toDisplayString(u.value?.length),1),e.createElementVNode("div",cs,[e.createElementVNode("label",null,[e.createElementVNode("input",{type:"file",class:"hidden",onChange:S[0]||(S[0]=T=>y(T))},null,32),e.createElementVNode("div",ds,[e.createVNode(e.unref(q.Upload),{class:"h-4 w-4"})])])])]),u.value?.length>4?(e.openBlock(),e.createElementBlock("div",us,[e.createElementVNode("div",null,[e.createElementVNode("div",ps,[e.createElementVNode("div",fs,[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]=T=>p.value=T),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",ms,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(T,E)=>(e.openBlock(),e.createBlock(ls,{key:E,prefix:C.prefix,item:T,index:E,onUpdate:S[2]||(S[2]=$=>C.$emit("update","file-list")),onOpenModal:S[3]||(S[3]=$=>x($)),onOpenLightbox:S[4]||(S[4]=$=>m($))},null,8,["prefix","item","index"]))),128)),b.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",hs,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]=T=>a.value=T),startIndex:s.value,"onUpdate:index":S[6]||(S[6]=T=>s.value=T),images:g.value},null,8,["modelValue","startIndex","images"]),e.createVNode(W,e.mergeProps({modelValue:c.value,"onUpdate:modelValue":S[7]||(S[7]=T=>c.value=T),onConfirm:d.value.confirm},d.value),null,16,["modelValue","onConfirm"])])}}}),gs={class:"flex items-center justify-between"},ys={class:"text-[16px] text-gray-900 font-medium"},bs={class:"grid gap-3"},ks=ye(e.defineComponent({__name:"vs-container-switcher",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",gs,[e.createElementVNode("p",ys,e.toDisplayString(o.title),1),e.createVNode(Kn,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),style:e.normalizeStyle(o.style)},null,8,["modelValue","style"])]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",bs,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-90320b87"]]),xs={class:"text-[16px] text-gray-900 font-medium"},ws={class:"grid gap-3"},_s=ye(e.defineComponent({__name:"vs-container-accordion",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("button",{type:"button",onClick:l[0]||(l[0]=a=>n.value=!n.value),class:"flex items-center gap-2"},[e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 duration-300",[n.value?"-rotate-180":""]])},null,8,["class"]),e.createElementVNode("span",xs,e.toDisplayString(o.title),1)]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",ws,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-0c825d65"]]),Cs={class:"flex items-center justify-between"},vs={switcher:ks,accordion:_s,default:e.defineComponent({__name:"vs-container-default",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",Cs,[e.createElementVNode("p",null,e.toDisplayString(o.title),1)]),e.renderSlot(t.$slots,"default")]))}})},lt={Equal:"==",Inequal:"!=",Higer:">",HigerOrEqual:">=",Lower:"<",LowerOrEqual:"<=",Between:"between",StartWith:"^",EndWith:"$",Contain:"*",In:"in",NotIn:"not_in"},Es=(o,t)=>String(o)===String(t),Bs=(o,t)=>String(o)!==String(t),Vs=(o,t)=>o>t,Ss=(o,t)=>o>=t,$s=(o,t)=>o<t,Ns=(o,t)=>o<=t,As=(o,t)=>Array.isArray(t)&&t.length===2?o>=t[0]&&o<=t[1]:!1,Ms=(o,t)=>String(o).startsWith(String(t)),Fs=(o,t)=>String(o).endsWith(String(t)),Ds=(o,t)=>String(o).includes(String(t)),Ts=(o,t)=>Array.isArray(t)?t.includes(o):!1,Ls=(o,t)=>Array.isArray(t)?!t.includes(o):!0,Is=(o,t)=>{if(!t)return!0;switch(t?.[1]){case lt.Equal:return Es(o,t?.[2]);case lt.Inequal:return Bs(o,t?.[2]);case lt.Higer:return Vs(o,t?.[2]);case lt.HigerOrEqual:return Ss(o,t?.[2]);case lt.Lower:return $s(o,t?.[2]);case lt.LowerOrEqual:return Ns(o,t?.[2]);case lt.Between:return As(o,t?.[2]);case lt.StartWith:return Ms(o,t?.[2]);case lt.EndWith:return Fs(o,t?.[2]);case lt.Contain:return Ds(o,t?.[2]);case lt.In:return Ts(o,t?.[2]);case lt.NotIn:return Ls(o,t?.[2]);default:return!0}};function To(o,t,n){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=n?o?.[n]?.[a]??o?.[a]:o?.[a];return Is(s,l)})}const Lo=e.defineComponent({__name:"vs-input-container",props:{style:{type:Object,default:()=>({})},title:{type:String,default:""},view:{type:String,default:"default"},name:{type:String,default:""},schema:{type:Array,default:()=>[]}},setup(o){const t=o,n=e.inject("values",e.ref({})),r=e.inject("form"),l=e.computed(()=>t.schema?.filter(i=>To(n.value,i?.conditions,t.name||void 0))),a=e.computed(()=>vs[t.view]),s=e.computed(()=>{if(n.value||(n.value={}),!t.name)return n.value;const i=n.value[t.name];if(i)return i;const c={};return n.value={...n.value,[t.name]:c},c});return(i,c)=>o.schema?.length?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:0,title:o.title,style:e.normalizeStyle(o.style)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,d=>(e.openBlock(),e.createBlock(lr,e.mergeProps({key:d.name},{ref_for:!0},d,{item:d,modelValue:s.value[d.name],"onUpdate:modelValue":u=>s.value[d.name]=u,style:o.style,error:e.unref(r)?.errors?.[d.name]}),null,16,["item","modelValue","onUpdate:modelValue","style","error"]))),128))]),_:1},8,["title","style"])):e.createCommentVNode("",!0)}}),Io=({props:o,fetchOptionByValue:t,optionsList:n,selectedOption:r,modelValue:l,onCreated:a})=>{const s=e.ref(!1),i=e.ref({}),c=e.ref([]),d=e.ref(null),u=e.computed(()=>o.add?.title||"Додати"),p=e.computed(()=>o.add?.token||o.add?.model||""),g=e.computed(()=>o.add?.pk||"id");return{isOpenAdd:s,addData:i,addSchema:c,addForm:d,addTitle:u,addOption:async()=>{if(!(!p.value||d?.value.validate()))try{const y=o.add?.api??`/api/table/${p.value}`,w=await fetch(y,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i.value)}),x=await w.json().catch(()=>({})),C=x?.error||x?.message,S=Number(x?.code)>=400;if(!w.ok||S){ue.notify({title:"Помилка",type:"error",message:C||`Код помилки: ${x?.code||w.status}`});return}const H=x?.[g.value]??x?.id;if(!H){ue.notify({title:"Помилка",type:"error",message:"Обʼєкт створено, але в відповіді відсутній ID."});return}const W=await t(H);W&&(n.value.some(E=>String(E?.id)===String(W.id))||n.value.push(W)),a?await a(W,H):W&&(r.value=W,l.value=H),s.value=!1,ue.notify({title:"Успіх",message:"Обʼєкт успішно створено."})}catch(y){ue.notify({title:"Помилка",type:"error",message:y?.message||"Не вдалося створити обʼєкт."})}},onAddValue:async()=>{if(!o.add)return null;const h=await fetch(`/api/template/form/${o.add.form}`).then(y=>y.json());return c.value=h.schema,i.value={},s.value=!0,null}}},Rs=["aria-expanded","data-focus"],Os={class:"relative flex flex-1 items-center gap-1 py-0.5 pl-1 pr-0 overflow-hidden h-full min-w-0"},Ps={key:0,class:"flex flex-nowrap items-center gap-1 overflow-x-auto overflow-y-hidden min-w-0 flex-1 py-0.5"},zs={class:"flex items-center gap-1 min-w-0"},js=["title"],Us=["innerHTML"],Hs=["onClick"],qs={class:"flex-1 min-w-[2px]"},Ks=["placeholder"],Ws=["title"],Gs=["innerHTML"],Ys={key:3,class:"truncate flex-1 min-w-0"},Xs={key:2,class:"flex-1 min-w-[2px]"},Zs=["placeholder"],Js={key:3,class:"flex-1 flex items-center min-h-[30px] py-0.5 pl-2 text-sm truncate text-inherit"},Qs={class:"flex items-center shrink-0"},ei=["disabled"],ti={key:1,class:"self-stretch w-px bg-[#ccc] my-[1px]"},ni=["disabled","title"],oi=e.defineComponent({__name:"vs-select-control",props:{disabled:{type:Boolean},isOpen:{type:Boolean},inputFocus:{type:Boolean},isMulti:{type:Boolean},selectedOptions:{},selectedIds:{},placeholder:{},search:{type:Boolean},optionTemplate:{default:""},iconWrapperClass:{},selectedOptionLabel:{},selectedOption:{},showClear:{type:Boolean},keyWord:{default:""},setTriggerRef:{},setInputRef:{},shouldShowColorDot:{},optionHasIcon:{},getIconColorStyle:{},resolveOptionIcon:{},renderTemplate:{},getLabel:{},onControlKeydown:{},onControlClick:{},onInputFocus:{},onInputBlur:{},onInputKeydown:{},onRemoveSelected:{},onClearSelected:{},onToggleSelect:{}},emits:["update:keyWord"],setup(o,{emit:t}){const n=o,r=t,l=e.computed({get:()=>n.keyWord,set:a=>r("update:keyWord",a)});return(a,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-input-select__control flex min-h-[38px] items-center justify-between rounded transition-colors bg-white",a.disabled?"bg-gray-100 text-gray-400 cursor-not-allowed":""]),role:"combobox","aria-expanded":a.isOpen,"aria-haspopup":"listbox",onKeydown:s[10]||(s[10]=(...i)=>a.onControlKeydown&&a.onControlKeydown(...i)),onClick:s[11]||(s[11]=(...i)=>a.onControlClick&&a.onControlClick(...i)),"data-focus":a.isOpen||a.inputFocus?"true":"false",ref:a.setTriggerRef},[e.createElementVNode("div",Os,[a.isMulti?(e.openBlock(),e.createElementBlock("div",Ps,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.selectedOptions,i=>(e.openBlock(),e.createElementBlock("div",{key:i.id,class:"flex min-w-0 bg-[rgb(230,230,230)] rounded-[2px] m-[2px] box-border max-w-full"},[e.createElementVNode("div",zs,[a.shouldShowColorDot(i)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[16px] h-[16px] rounded-md block ml-1.5 flex-shrink-0",style:e.normalizeStyle({backgroundColor:i?.color})},null,4)):e.createCommentVNode("",!0),!a.optionTemplate&&a.optionHasIcon(i)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(a.iconWrapperClass),style:e.normalizeStyle(a.getIconColorStyle(i)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.resolveOptionIcon(i)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"truncate text-[#172b4d] overflow-hidden max-w-[200px] px-0.5 pl-1.5",title:a.getLabel(i)},[a.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:a.renderTemplate(i)},null,8,Us)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(i.text),1)],64))],8,js)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border text-[#172b4d] hover:bg-[rgb(255,189,173)] hover:text-[rgb(222,53,11)] flex-shrink-0",onClick:e.withModifiers(c=>a.onRemoveSelected(i.id),["stop"])},[e.createVNode(e.unref(q.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Hs)]))),128)),e.createElementVNode("div",qs,[!a.disabled&&a.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref:a.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:a.selectedIds.length?" ":a.placeholder,"onUpdate:modelValue":s[0]||(s[0]=i=>l.value=i),onFocus:s[1]||(s[1]=(...i)=>a.onInputFocus&&a.onInputFocus(...i)),onBlur:s[2]||(s[2]=(...i)=>a.onInputBlur&&a.onInputBlur(...i)),onKeydown:s[3]||(s[3]=(...i)=>a.onInputKeydown&&a.onInputKeydown(...i))},null,40,Ks)),[[e.vModelText,l.value]]):e.createCommentVNode("",!0)])])):!a.isMulti&&a.selectedOptionLabel&&l.value===""?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["truncate flex items-center gap-1 min-w-0 pl-2",a.disabled||!a.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:a.selectedOptionLabel},[a.shouldShowColorDot(a.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[14px] h-[14px] rounded-md block flex-shrink-0",style:e.normalizeStyle({backgroundColor:a.selectedOption?.color})},null,4)):e.createCommentVNode("",!0),!a.optionTemplate&&a.optionHasIcon(a.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(a.iconWrapperClass),style:e.normalizeStyle(a.getIconColorStyle(a.selectedOption)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.resolveOptionIcon(a.selectedOption)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),a.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:2,class:"truncate flex-1 min-w-0",innerHTML:a.renderTemplate(a.selectedOption)},null,8,Gs)):(e.openBlock(),e.createElementBlock("span",Ys,e.toDisplayString(a.selectedOption?.text),1))],10,Ws)):e.createCommentVNode("",!0),!a.isMulti&&!a.disabled&&a.search?(e.openBlock(),e.createElementBlock("div",Xs,[e.withDirectives(e.createElementVNode("input",{ref:a.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:a.selectedOptionLabel?" ":a.placeholder,"onUpdate:modelValue":s[4]||(s[4]=i=>l.value=i),onFocus:s[5]||(s[5]=(...i)=>a.onInputFocus&&a.onInputFocus(...i)),onBlur:s[6]||(s[6]=(...i)=>a.onInputBlur&&a.onInputBlur(...i)),onKeydown:s[7]||(s[7]=(...i)=>a.onInputKeydown&&a.onInputKeydown(...i))},null,40,Zs),[[e.vModelText,l.value]])])):!a.isMulti&&a.disabled&&(!a.selectedOptionLabel||l.value!=="")?(e.openBlock(),e.createElementBlock("div",Js,e.toDisplayString(a.placeholder),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Qs,[a.showClear?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.disabled,onClick:s[8]||(s[8]=e.withModifiers((...i)=>a.onClearSelected&&a.onClearSelected(...i),["stop"]))},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,ei)):e.createCommentVNode("",!0),a.showClear?(e.openBlock(),e.createElementBlock("div",ti)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.disabled,onClick:s[9]||(s[9]=e.withModifiers((...i)=>a.onToggleSelect&&a.onToggleSelect(...i),["stop"])),title:a.isOpen?"Закрити список":"Відкрити список"},[e.createVNode(e.unref(q.ChevronDown),{class:"h-4 w-4"})],8,ni)])],42,Rs))}}),ri=["aria-disabled","onMousedown"],li={class:"leading-[19px]"},ai=["innerHTML"],si={key:1,class:"px-3 py-2 text-center text-gray-500"},ii=e.defineComponent({__name:"vs-select-dropdown",props:{isOpen:{type:Boolean},dropdownStyle:{},filteredOptionsList:{},selectedNavIndex:{},optionTemplate:{},iconWrapperClass:{},setDropdownRef:{type:Function},setListRef:{type:Function},setItemRef:{type:Function},isSelected:{type:Function},onOptionClick:{type:Function},shouldShowColorDot:{type:Function},optionHasIcon:{type:Function},getIconColorStyle:{type:Function},resolveOptionIcon:{type:Function},renderTemplate:{type:Function}},setup(o){return(t,n)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.isOpen?(e.openBlock(),e.createElementBlock("div",{key:0,ref:t.setDropdownRef,class:"fixed z-[3000] rounded bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.1),0_4px_11px_rgba(0,0,0,0.1)]",style:e.normalizeStyle(t.dropdownStyle),role:"listbox"},[e.createElementVNode("div",{class:"overflow-y-auto py-1",style:e.normalizeStyle({maxHeight:t.dropdownStyle.maxHeight||"300px"}),ref:t.setListRef},[t.filteredOptionsList.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.filteredOptionsList,(r,l)=>(e.openBlock(),e.createElementBlock("div",{key:r.id,ref_for:!0,ref:a=>t.setItemRef(a,l),class:e.normalizeClass(["flex px-3 py-2 gap-2 cursor-pointer select-none text-gray-900",t.isSelected(r.id)?"bg-[#2684ff] text-white":"bg-white hover:bg-[#deebff] hover:text-[#172b4d]",t.selectedNavIndex===l&&!t.isSelected(r.id)?"bg-[#deebff] text-[#172b4d]":""]),"aria-disabled":t.isSelected(r.id)?"true":"false",role:"option",tabindex:"-1",onMousedown:e.withModifiers(a=>t.onOptionClick(r),["prevent","stop"])},[t.shouldShowColorDot(r)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[11px] h-[11px] rounded-full block flex-shrink-0",style:e.normalizeStyle({backgroundColor:r?.color})},null,4)):e.createCommentVNode("",!0),!t.optionTemplate&&t.optionHasIcon(r)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(t.iconWrapperClass),style:e.normalizeStyle(t.getIconColorStyle(r)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.resolveOptionIcon(r)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",li,[t.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:t.renderTemplate(r)},null,8,ai)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r.text),1)],64))])],42,ri))),128)):(e.openBlock(),e.createElementBlock("div",si," No options "))],4)],4)):e.createCommentVNode("",!0)]))}}),ci=["disabled"],Ro="w-[16px] h-[16px] flex items-center justify-center flex-shrink-0 text-current",Qn=ye(e.defineComponent({__name:"vs-input-select",props:{multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean,default:!0},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{default:400},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{default:0},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t,l=e.computed(()=>n.multiple),a=e.computed(()=>n.disabled),s=e.computed(()=>n.search);je(n.style);const i=e.computed({get:()=>n.modelValue,set:j=>r("update:modelValue",j)});!i.value&&n.defaultValue&&(i.value=n.defaultValue);const c=e.ref(null),d=e.ref(null),u=e.ref(null),p=e.ref(null),g=e.ref(!1),b=e.ref(!1),m=e.ref(null),h=e.ref(-1),y=e.ref([]),w=e.ref(""),x=e.ref(null),C=j=>{d.value=j},S=j=>{x.value=j},H=j=>{p.value=j},W=j=>{u.value=j},T=(j,te)=>{y.value[te]=j},E=e.ref({}),$=e.ref([]),N=e.computed(()=>{if(!$.value.length)return[];const j=fe.value,te=new Map(j.map(se=>[se.id?.toString(),se]));return $.value.map(se=>te.get(se?.toString())).filter(se=>!!se)}),V=e.computed(()=>n.placeholder||"Select..."),M=e.computed(()=>oe(m.value)),O=e.computed(()=>a.value?!1:l.value?$.value.length>0:!!i.value),B=j=>l.value?$.value.some(te=>te?.toString()===j?.toString()):i.value?.toString()===j?.toString(),K=e.computed(()=>{let j=fe.value??[];if(!n.data&&w.value.trim()!==""){const te=w.value.toLowerCase();j=j.filter(se=>{const ve=oe(se).toLowerCase(),De=se.text?.toLowerCase?.()||"";return ve.includes(te)||De.includes(te)})}if(l.value&&$.value.length){const te=new Set($.value.map(se=>se?.toString()));j=j.filter(se=>!te.has(se.id?.toString()))}return j}),I=e.inject("values"),G=e.inject("field-props"),L=e.computed(()=>n.slot??n?.optionTemplate??""),Z=j=>gn(j,L.value),oe=j=>yn(j,L.value),be=e.computed(()=>fn(L.value)),pe=j=>Gt(j),ee=j=>!!(!be.value&&Vt(j)&&!pe(j)),ae=j=>{const te=Vt(j);return te?{color:te}:void 0},me=j=>!!(!be.value&&(Wt(j)||pe(j))),Q=(j,te,se)=>{if(!G)return!1;const ve=G.value?.[j]??{},De=(Te,ot,pt)=>{if(!ot.length)return Te;const[ft,...kt]=ot,ct={...Te};if(!kt.length)return ct[ft]=pt,ct;const dn=typeof Te[ft]=="object"&&Te[ft]!==null?Te[ft]:{};return ct[ft]=De(dn,kt,pt),ct},Ke=De(ve,te,se);return G.value={...G.value||{},[j]:Ke},!0},ie=j=>{if(!n.set)return;const te=I?.value;!te&&!G||Object.entries(n.set).forEach(([se,ve])=>{if(!se)return;const De=j?j[ve]:null,Ke=se.split(".").map(pt=>pt.trim()).filter(Boolean);if(!Ke.length)return;const[Te,...ot]=Ke;ot.length&&Q(Te,ot,De??null)||te&&(te[Te]=De??null)})},{optionsList:fe,parentValue:Ee,fetchOptions:$e,fetchOptionByValue:Pe,loadOptions:Fe}=hn({props:n,formValues:I,watchParent:!1}),_e=j=>j==null?"":String(j),Ne=j=>{if(l.value){if(!$.value.length){fe.value=j;return}}else if(!m.value){fe.value=j;return}const te=new Set(j.map(ve=>_e(ve.id)).filter(Boolean));if(l.value){const ve=new Set($.value.map(Ke=>_e(Ke)).filter(Boolean)),De=(fe.value??[]).filter(Ke=>{const Te=_e(Ke.id);return!Te||!ve.has(Te)?!1:!te.has(Te)});fe.value=[...De,...j];return}const se=_e(m.value?.id);if(se&&!te.has(se)){fe.value=[m.value,...j];return}fe.value=j},Be=e.ref(0),Ae=async j=>{const te=++Be.value,se=await $e(j);return te!==Be.value?null:se},Re=async()=>{if(n.data){const j=await Ae(w.value);return j&&Ne(j),fe.value}return Fe()},Oe=async j=>{if(j==null||j==="")return null;const te=fe.value?.find(se=>se?.id?.toString()===String(j));return te||Pe(j)},tt=async j=>{const te=new Set(fe.value.map(ve=>ve.id?.toString())),se=j.filter(ve=>!te.has(ve?.toString()));se.length&&await se.reduce(async(ve,De)=>{await ve;const Ke=await Oe(De);Ke&&fe.value.push(Ke)},Promise.resolve())},U=()=>{if(!K.value.length){h.value=-1;return}let j=0;if(!l.value&&m.value){const te=m.value.id?.toString(),se=K.value.findIndex(ve=>ve.id?.toString()===te);se>=0&&(j=se)}h.value=j,e.nextTick(()=>{A(y.value[j],u.value)})},J=async()=>{a.value||(g.value=!0,await e.nextTick(()=>{re()}),await Re(),await e.nextTick(()=>{re(),x.value?.focus()}),U())},ne=()=>{g.value=!1,h.value=-1,e.nextTick(()=>{x.value?.blur()})},P=async j=>{if(a.value)return;(j!==void 0?j:!g.value)?await J():ne()},Y=async()=>{if(!a.value){if(g.value){ne();return}await J()}},we=()=>{l.value?($.value=[],i.value=[],r("change",[]),Ce(null,[])):(m.value=null,i.value=null,r("change",null),Ce(null,null)),ie(null),w.value="",e.nextTick(()=>{x.value?.focus(),g.value||J()})},Ve=j=>{l.value&&($.value=$.value.filter(te=>te?.toString()!==j?.toString()),i.value=[...$.value],r("change",i.value),Ce(null),e.nextTick(()=>x.value?.focus()))},Ce=(j,te)=>{const se=te??(l.value?[...$.value]:j?.id??null);r("value-selected",{name:n.name,value:se,option:j})},R=j=>{l.value?(B(j.id)||($.value=[...$.value,j.id],i.value=[...$.value],r("change",i.value),Ce(j)),w.value="",e.nextTick(()=>{x.value?.focus(),h.value=Math.min(h.value,K.value.length-1)}),ie(null)):(m.value=j,i.value=j.id,r("change",i.value),Ce(j),w.value="",ne(),ie(j))},_=j=>{if(B(j.id)){l.value||ne();return}R(j)},A=(j,te)=>{if(!j||!te)return;const se=j.offsetTop,ve=se+j.offsetHeight,De=te.scrollTop,Ke=De+te.clientHeight;let Te=te.scrollTop;se<De?Te=se-80:ve>Ke&&(Te=ve-te.clientHeight+4);const ot=te;ot.scrollTop=Te},z=j=>{let te=j.parentElement;for(;te;){if(te.classList.contains("ui-dialog__content"))return te;const se=window.getComputedStyle(te),ve=se.overflow+se.overflowY+se.overflowX;if(ve.includes("auto")||ve.includes("scroll")||te===document.body||te===document.documentElement)return te;te=te.parentElement}return document.body},re=()=>{if(!d.value)return;const j=d.value.getBoundingClientRect(),te=window.innerHeight||document.documentElement.clientHeight,se=window.innerWidth||document.documentElement.clientWidth,ve=8,De=8,Ke=n.maxHeight||300,Te=te-j.bottom-De-ve,ot=j.top-De-ve,pt=Te>=ot,ft=Math.max(se-ve*2,0);let{width:kt}=j;ft>0&&kt>ft&&(kt=ft);let{left:ct}=j;ct+kt+ve>se&&(ct=se-kt-ve),ct=Math.max(ct,ve);const dn=Math.min(Ke,Math.max(pt?Te:ot,50));E.value={position:"fixed",left:`${ct}px`,width:`${kt}px`,maxHeight:`${dn}px`,transform:pt?"none":"translateY(-100%)",top:pt?`${j.bottom+De}px`:`${j.top-De}px`}},ke=async j=>{a.value||!g.value&&(j.key==="ArrowDown"||j.key==="ArrowUp")&&(j.preventDefault(),await J())},Me=j=>{if(!g.value)return;const{key:te}=j;if(te==="ArrowDown")j.preventDefault(),h.value+1<K.value.length&&(h.value+=1,A(y.value[h.value],u.value));else if(te==="ArrowUp")j.preventDefault(),h.value>0&&(h.value-=1,A(y.value[h.value],u.value));else if(te==="Enter"){j.preventDefault();const se=K.value[h.value];se&&R(se),x.value?.blur()}else te==="Escape"?(j.preventDefault(),ne()):te==="Backspace"?l.value&&w.value===""&&$.value.length&&($.value=$.value.slice(0,-1),i.value=[...$.value],r("change",i.value)):te==="Home"?(h.value=0,A(y.value[0],u.value)):te==="End"?(h.value=K.value.length-1,A(y.value[h.value],u.value)):te==="Tab"&&ne()},Se=()=>{a.value||(b.value=!0)},We=()=>{b.value=!1,w.value=""},st=j=>{j.key==="Escape"&&g.value&&ne()},Ge=j=>{const te=j.target;c.value?.contains(te)||p.value?.contains(te)||ne()},ze=j=>{g.value&&u.value&&!u.value.contains(j.target)&&re()},nt=()=>{g.value&&re()},Ht=()=>{g.value&&re()};async function Ft(){if(l.value)Array.isArray(i.value)?$.value=[...i.value]:($.value=i.value==null?[]:[i.value],i.value=[...$.value]),n.data&&$.value.length&&(await tt($.value),await e.nextTick());else{if(Array.isArray(i.value)){const j=i.value[0]??null;i.value=j??null}i.value!=null&&(m.value=await Oe(i.value)),ie(m.value??null)}}e.watch(i,()=>{Ft()}),e.onMounted(async()=>{if(addEventListener("keydown",st),addEventListener("scroll",ze,!0),addEventListener("resize",nt),document.addEventListener("click",Ge,!0),d.value&&z(d.value).addEventListener("scroll",Ht,!0),n.options?.length&&!n.data)fe.value=[...n.options];else if(n.data){const j=await Ae("");j&&Ne(j)}await Ft(),Dt.value=!1}),e.onUnmounted(()=>{removeEventListener("keydown",st),removeEventListener("scroll",ze,!0),removeEventListener("resize",nt),document.removeEventListener("click",Ge,!0),d.value&&z(d.value).removeEventListener("scroll",Ht,!0)});const{isOpenAdd:sn,addData:bt,addSchema:Pt,addForm:xo,addTitle:Et,addOption:wo,onAddValue:qt}=Io({props:n,fetchOptionByValue:Pe,optionsList:fe,selectedOption:m,modelValue:i});function it(j,te=200){let se;return(...ve)=>{se&&clearTimeout(se),se=window.setTimeout(()=>j(...ve),te)}}const cn=it(async j=>{const te=await Ae(j);te&&Ne(te)},200);e.watch(w,j=>{n.data&&cn(j.trim())}),e.watch(()=>n.options,j=>{!n.data&&j?.length&&(fe.value=[...j],Ft())},{immediate:!0});const Dt=e.ref(!0);return e.watch(Ee,async()=>{if(n.data&&(Dt.value||(l.value?($.value=[],i.value=[],r("change",[])):(m.value=null,i.value=null,r("change",null))),await Re(),n.auto===1&&Ee.value&&fe.value.length>0)){const j=fe.value[0];j&&R(j)}}),(j,te)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(ue.VsModal),{visible:e.unref(sn),"onUpdate:visible":te[1]||(te[1]=se=>e.isRef(sn)?sn.value=se:null),class:"z-[1000]",title:e.unref(Et),buttonText:"Додати",onDone:e.unref(wo),teleport:j.teleport},{default:e.withCtx(()=>[e.createVNode(at,{schema:e.unref(Pt),modelValue:e.unref(bt),"onUpdate:modelValue":te[0]||(te[0]=se=>e.isRef(bt)?bt.value=se:null),ref_key:"addForm",ref:xo},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone","teleport"]),e.createElementVNode("div",{class:"flex gap-1 w-full",ref_key:"selectRoot",ref:c,onClick:te[4]||(te[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass])},[te[5]||(te[5]=e.createElementVNode("span",{id:"react-select-live-region",class:"sr-only"},null,-1)),te[6]||(te[6]=e.createElementVNode("span",{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text",role:"log",class:"sr-only"},null,-1)),e.createVNode(oi,{keyWord:w.value,"onUpdate:keyWord":te[2]||(te[2]=se=>w.value=se),disabled:a.value,"is-open":g.value,"input-focus":b.value,"is-multi":l.value,"selected-options":N.value,"selected-ids":$.value,placeholder:V.value,search:s.value,"option-template":L.value,"icon-wrapper-class":Ro,"selected-option-label":M.value,"selected-option":m.value,"show-clear":O.value,"set-trigger-ref":C,"set-input-ref":S,"should-show-color-dot":ee,"option-has-icon":me,"get-icon-color-style":ae,"resolve-option-icon":pe,"render-template":Z,"get-label":oe,"on-control-keydown":ke,"on-control-click":Y,"on-input-focus":Se,"on-input-blur":We,"on-input-keydown":Me,"on-remove-selected":Ve,"on-clear-selected":we,"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(ii,{"is-open":g.value,"dropdown-style":E.value,"filtered-options-list":K.value,"selected-nav-index":h.value,"option-template":L.value,"icon-wrapper-class":Ro,"set-dropdown-ref":H,"set-list-ref":W,"set-item-ref":T,"is-selected":B,"on-option-click":_,"should-show-color-dot":ee,"option-has-icon":me,"get-icon-color-style":ae,"resolve-option-icon":pe,"render-template":Z},null,8,["is-open","dropdown-style","filtered-options-list","selected-nav-index","option-template"])],2),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:te[3]||(te[3]=(...se)=>e.unref(qt)&&e.unref(qt)(...se)),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"}),te[7]||(te[7]=e.createElementVNode("span",null,"Додати",-1))],8,ci)):e.createCommentVNode("",!0)],512)],64))}}),[["__scopeId","data-v-47aa1c50"]]),eo=(o="")=>`${o}${Math.floor(Math.random()*1e4)}`,di=["disabled","aria-expanded"],ui={class:"truncate"},pi={class:"py-2 px-4"},fi={class:"block font-medium text-[13px] text-foreground"},mi={class:"truncate"},hi={class:"p-1 border-t border-gray-200"},gi={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"},yi=["onClick"],bi=["checked"],ki={class:"shrink-0 size-3.5 flex justify-center items-center"},xi={key:1,class:"shrink-0 size-2 block mx-auto rounded-full bg-secondary/60"},wi={class:"truncate"},_i={key:0,class:"px-3 py-2 text-xs text-stone-500"},kn=e.defineComponent({__name:"vs-input-inline-select",props:{multiple:{type:Boolean},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t;je(n.style);const l=e.computed({get:()=>Array.isArray(n.modelValue)?n.modelValue[0]??null:n.modelValue??null,set:Q=>r("update:modelValue",Q)});l.value==null&&n.defaultValue!=null&&(l.value=n.defaultValue);const a=e.inject("values"),s=e.inject("field-props"),i=e.computed(()=>!!n.disabled),c=e.ref(null),d=e.ref(!1),u=e.ref(null),p=e.ref(null),g=e.ref(null),b=e.ref({}),m=`vs-input-inline-select-${eo()}`,h=e.computed(()=>n.placeholder||"Оберіть значення"),y=e.computed(()=>H(c.value)||n.placeholder||"Оберіть значення"),w=e.computed(()=>n.slot??""),x=e.computed(()=>fn(w.value)),C=e.computed(()=>n.teleport||"body"),S=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6}|[\da-fA-F]{8})$/,H=Q=>yn(Q,w.value),W=Q=>!!(!x.value&&Vt(Q)),T=e.computed(()=>{const Q=Vt(c.value).trim();return Q?S.test(Q)?`bg-[${Q}] border-[${Q}]`:`bg-${Q.toLowerCase()}-500 border-${Q.toLowerCase()}-500`:""}),{optionsList:E,parentValue:$,fetchOptions:N,fetchOptionByValue:V,loadOptions:M}=hn({props:n,formValues:a,watchParent:!1}),O=(Q,ie,fe)=>{if(!s)return!1;const Ee=s.value?.[Q]??{},$e=(Fe,_e,Ne)=>{if(!_e.length)return Fe;const[Be,...Ae]=_e,Re={...Fe};if(!Ae.length)return Re[Be]=Ne,Re;const Oe=typeof Fe[Be]=="object"&&Fe[Be]!==null?Fe[Be]:{};return Re[Be]=$e(Oe,Ae,Ne),Re},Pe=$e(Ee,ie,fe);return s.value={...s.value||{},[Q]:Pe},!0},B=Q=>{if(!n.set)return;const ie=a?.value;!ie&&!s||Object.entries(n.set).forEach(([fe,Ee])=>{if(!fe)return;const $e=Q?Q[Ee]:null,Pe=fe.split(".").map(Ne=>Ne.trim()).filter(Boolean);if(!Pe.length)return;const[Fe,..._e]=Pe;_e.length&&O(Fe,_e,$e??null)||ie&&(ie[Fe]=$e??null)})},K=Q=>l.value?.toString?.()===Q?.toString?.(),I=()=>{if(!p.value||typeof window>"u")return;const Q=p.value.getBoundingClientRect(),ie=8,fe=8,Ee=window.innerHeight||document.documentElement.clientHeight,$e=window.innerWidth||document.documentElement.clientWidth,Pe=g.value?.offsetHeight||260,Fe=Math.max(Q.width,176),_e=Math.max($e-ie*2,120),Ne=Math.min(Fe,_e);let Be=Q.left;Be+Ne+ie>$e&&(Be=$e-Ne-ie),Be=Math.max(Be,ie);const Ae=Ee-Q.bottom-fe-ie,Re=Q.top-fe-ie,Oe=Ae<Math.min(Pe,260)&&Re>Ae,tt=Math.max(120,Math.min(320,Oe?Re:Ae));b.value={position:"fixed",left:`${Be}px`,top:Oe?`${Q.top-fe}px`:`${Q.bottom+fe}px`,transform:Oe?"translateY(-100%)":"none",width:`${Ne}px`,maxHeight:`${tt}px`}},G=async()=>{if(n.data){E.value=await N("");return}await M()},L=async()=>{if(l.value==null||l.value===""){c.value=null,B(null);return}const Q=E.value.find(ie=>ie.id?.toString()===String(l.value));if(Q){c.value=Q,B(Q);return}c.value=await V(l.value),B(c.value??null)},Z=async()=>{i.value||(d.value=!0,await e.nextTick(),I(),await G(),await e.nextTick(),I())},oe=()=>{d.value=!1},be=async()=>{if(d.value){oe();return}await Z()},pe=Q=>{r("value-selected",{name:n.name,value:Q?.id??null,option:Q})},ee=Q=>{c.value=Q,l.value=Q.id,r("change",Q.id),pe(Q),B(Q),oe()},ae=Q=>{const ie=Q.target;u.value?.contains(ie)||g.value?.contains(ie)||oe()},me=()=>{d.value&&I()};return e.watch(()=>n.options,Q=>{n.data||(E.value=Q?[...Q]:[],L())},{immediate:!0,deep:!0}),e.watch(l,()=>{L()}),e.watch($,async()=>{n.data&&(await G(),c.value&&!E.value.some(Q=>Q.id?.toString()===c.value?.id?.toString())&&(c.value=null,l.value=null,r("change",null),pe(null),B(null)))}),e.onMounted(async()=>{document.addEventListener("click",ae,!0),window.addEventListener("resize",me),window.addEventListener("scroll",me,!0),await G(),await L()}),e.onUnmounted(()=>{document.removeEventListener("click",ae,!0),window.removeEventListener("resize",me),window.removeEventListener("scroll",me,!0)}),(Q,ie)=>(e.openBlock(),e.createElementBlock("div",{class:"relative inline-flex w-full max-w-full",ref_key:"rootRef",ref:u,onClick:ie[0]||(ie[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("button",{ref_key:"triggerRef",ref:p,type:"button",disabled:i.value,"aria-expanded":d.value?"true":"false","aria-haspopup":"menu",class:e.normalizeClass(["py-1.5 px-2.5 inline-flex items-center gap-2 text-nowrap text-xs sm:text-[13px] rounded-lg focus:outline-hidden disabled:opacity-50 disabled:pointer-events-none max-w-full border",T.value?`${T.value} text-white`:"bg-secondary text-secondary-foreground hover:bg-secondary-hover focus:bg-secondary-focus border-gray-300 hover:border-gray-400"]),onClick:be},[e.createElementVNode("span",ui,e.toDisplayString(y.value),1)],10,di),(e.openBlock(),e.createBlock(e.Teleport,{to:C.value},[d.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:g,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(b.value),role:"menu","aria-orientation":"vertical"},[e.createElementVNode("div",pi,[e.createElementVNode("span",fi,[e.createElementVNode("span",mi,e.toDisplayString(h.value),1)])]),e.createElementVNode("div",hi,[e.createElementVNode("div",gi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(E),fe=>(e.openBlock(),e.createElementBlock("label",{key:fe.id,class:"py-1.5 px-3 group flex items-center gap-x-3 rounded-lg cursor-pointer text-[13px] text-gray-800 hover:bg-gray-100",onClick:e.withModifiers(Ee=>ee(fe),["prevent"])},[e.createElementVNode("input",{type:"radio",class:"hidden",name:m,checked:K(fe.id),tabindex:"-1"},null,8,bi),e.createElementVNode("span",ki,[W(fe)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"shrink-0 size-2 block mx-auto rounded-full",style:e.normalizeStyle({backgroundColor:fe.color})},null,4)):(e.openBlock(),e.createElementBlock("span",xi))]),e.createElementVNode("span",wi,e.toDisplayString(H(fe)),1),e.createVNode(e.unref(q.Check),{class:e.normalizeClass(["shrink-0 size-3.5 ms-auto transition-opacity",K(fe.id)?"opacity-100":"opacity-0"])},null,8,["class"])],8,yi))),128))]),e.unref(E).length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",_i,"Немає варіантів"))])],4)):e.createCommentVNode("",!0)],8,["to"]))],512))}}),Ci=["placeholder","disabled"],Oo=e.defineComponent({__name:"vs-input-textarea",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=je(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");function s(){typeof r.value=="string"&&(r.value=r.value.trim())}return(i,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{"onUpdate:modelValue":c[0]||(c[0]=d=>r.value=d),placeholder:a.value,disabled:l.value,row:"2",onBlur:s,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] h-auto bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,42,Ci)),[[e.vModelText,r.value]])}}),Po=e.defineComponent({__name:"vs-input-richtext",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},format:{default:"html"},richtextProps:{default:()=>({})}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.defineAsyncComponent(()=>Promise.resolve().then(()=>y0)),n=o,{inputClass:r}=je(n.style),l=e.useModel(o,"modelValue"),a=e.computed(()=>!!n.disabled),s=e.computed(()=>n.placeholder??""),i=e.computed(()=>({height:n.richtextProps.height||"300px",format:n.format,...n.richtextProps}));return(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["!h-full",[c.customClass,e.unref(r)]]),style:e.normalizeStyle(a.value?{pointerEvents:"none",opacity:.6}:{})},[e.createVNode(e.unref(t),e.mergeProps({modelValue:l.value,"onUpdate:modelValue":d[0]||(d[0]=u=>l.value=u),placeholder:s.value},i.value),null,16,["modelValue","placeholder"])],6))}}),vi={},Ei={viewBox:"0 0 178 90",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function Bi(o,t){return e.openBlock(),e.createElementBlock("svg",Ei,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 Vi=ye(vi,[["render",Bi]]),Si={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden flex flex-col"},$i={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"},Ni={key:0,class:"relative flex-1 min-w-0"},Ai={class:"flex flex-nowrap items-center justify-end gap-2 shrink-0"},Mi={class:"w-full overflow-x-auto"},Fi={class:"w-full min-w-[640px] table-auto divide-y divide-gray-200"},Di={class:"bg-gray-50"},Ti={class:"border-b border-gray-200"},Li={class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 w-12 text-center"},Ii=["onClick"],Ri={key:0,class:"text-gray-400"},Oi={key:0,colspan:"100%",class:"text-center"},Pi={class:"w-full"},zi={class:"p-5 min-h-[200px] flex flex-col justify-center items-center text-center"},ji=["data-row-index","onDragstart","onDragover","onDrop"],Ui=["onPointerdown"],Hi={class:"flex items-center justify-center"},qi=["innerHTML"],Ki={key:0,class:"flex items-center gap-3 text-sm text-gray-700"},Wi={key:0},Gi=["src"],Yi={key:1,class:"rounded-md max-w-[45px] w-[45px] max-h-[45px] h-[45px] bg-gray-200 flex items-center justify-center"},Xi={key:1,class:"flex items-center justify-center"},Zi={key:2,class:"text-sm font-medium text-gray-900"},Ji={class:"px-4 py-3 text-right whitespace-nowrap"},Qi={class:"flex items-center justify-end gap-2"},ec=["onClick"],tc=["onClick"],nc={class:"vs-form__head mr-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},zo=e.defineComponent({__name:"vs-input-datatable",props:e.mergeModels({actions:{},colModel:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useSlots(),r=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(o,"modelValue"),i=e.ref({}),c=e.ref(""),d=e.ref(null),u=e.ref("asc"),p=e.computed(()=>{const U=s.value??[],J=c.value?U.filter(Y=>g.value?.some(we=>{const Ve=we.key||we.name;if(!Ve)return!1;const Ce=Y[Ve];return Ce?Array.isArray(Ce)?Ce.join(", ").toLowerCase().includes(c.value.toLowerCase()):String(Ce).toLowerCase().includes(c.value.toLowerCase()):!1})):U;if(!d.value)return J;const ne=d.value,P=[...J].sort((Y,we)=>{const Ve=$e(Y?.[ne]),Ce=$e(we?.[ne]);return typeof Ve=="number"&&typeof Ce=="number"?Ve-Ce:String(Ve).localeCompare(String(Ce))});return u.value==="asc"?P:P.reverse()}),g=e.computed(()=>(t.colModel??[]).filter(U=>!U.tableHidden)),b=e.ref(null),m=e.ref(null),h=e.ref(null);function y(U){return U.pointerType==="touch"||U.pointerType==="pen"}function w(U,J){const P=document.elementFromPoint(U,J)?.closest?.("[data-row-index]")??null;if(!P)return null;const Y=P.getAttribute("data-row-index");if(Y==null)return null;const we=Number.parseInt(Y,10);return Number.isNaN(we)?null:we}function x(U,J){y(U)&&(U.preventDefault(),U.currentTarget.setPointerCapture(U.pointerId),b.value=J,m.value=J)}function C(U){if(b.value===null||!y(U))return;U.preventDefault();const J=w(U.clientX,U.clientY);J!==null&&(m.value=J)}function S(U){if(b.value===null||!y(U))return;U.preventDefault();const J=w(U.clientX,U.clientY);E(J??b.value);try{U.currentTarget.releasePointerCapture(U.pointerId)}catch{}}function H(U){if(y(U)){b.value=null,m.value=null;try{U.currentTarget.releasePointerCapture(U.pointerId)}catch{}}}const W=U=>{b.value=U},T=U=>{m.value=U},E=U=>{if(b.value===null||b.value===U){b.value=null,m.value=null;return}const J=[...s.value],[ne]=J.splice(b.value,1);J.splice(U,0,ne),s.value=J,b.value=null,m.value=null},$=()=>{h.value&&h.value.click()},N=U=>{const J=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tif"],ne=U.toLowerCase();return J.some(P=>ne.endsWith(P))},V=U=>{const ne=U.target.files?.[0];if(!ne)return;const P=new FileReader;P.onload=Y=>{try{const we=Y.target?.result;if(typeof we=="string"){const Ve=JSON.parse(we);Array.isArray(Ve)&&s.value.push(...Ve)}}catch(we){console.error("Error parsing file:",we)}},P.readAsText(ne)},M=()=>{const U=JSON.stringify(s.value,null,2),J=new Blob([U],{type:"application/json"}),ne=URL.createObjectURL(J),P=document.createElement("a");P.href=ne,P.download="data.json",P.click(),URL.revokeObjectURL(ne)},O=new Set(["autocomplete","select","radio","checkbox","combobox"]),B=new Map,K=(U,J)=>{const ne=`/api/suggest/${U}`,P=ne.includes("?")?"&":"?",Y=J?`&val=${J}`:"";return`${ne}${P}json=1${Y}`},I=U=>U==null||U===""?null:typeof U=="object"?U?.id!==void 0&&U.id!==null&&U.id!==""?U.id:null:U,G=U=>{const J=new Set;return Array.isArray(s.value)&&s.value.forEach(ne=>{const P=ne?.[U];if(P==null||P==="")return;if(Array.isArray(P)){P.forEach(we=>{const Ve=I(we);Ve!==null&&J.add(Ve)});return}const Y=I(P);Y!==null&&J.add(Y)}),J},L=async()=>{if(!t.colModel?.length)return;const U=t.colModel.filter(J=>J.data&&O.has(J.type?.toLowerCase()||""));U.length&&await Promise.all(U.map(async J=>{const ne=J.key||J.name;if(!ne)return;const P=G(ne),Y=Array.from(P).map(Ce=>String(Ce)).sort(),we=Y.join(",");if(!Y.length||B.get(ne)===we)return;B.set(ne,we);const Ve=Y.map(encodeURIComponent).join(",");try{const R=await(await fetch(K(J.data,Ve))).json();i.value[ne]=R?.data??R}catch(Ce){console.error("Failed to fetch column values",Ce)}}))};e.watch([()=>t.colModel,()=>s.value],()=>{L()},{immediate:!0,deep:!0});const Z=e.ref(""),oe=e.ref(!1);let be="edit",pe=0;const ee=U=>(U?.format||U?.type||"").toString().toLowerCase(),ae=e.computed(()=>(t.colModel?.filter(J=>ee(J)!=="slot")??[]).map(J=>{const ne=J.key||J.name;return ne?{...J,name:ne,key:ne}:J})),me=e.ref({}),Q=e.ref({}),ie=U=>typeof U!="string"?!1:!!n[U],fe=(U,J)=>J?J.split(".").reduce((ne,P)=>ne==null?ne:ne[P.trim()],U):U,Ee=(U,J)=>typeof U!="string"?"":U.replace(/{{\s*([^}]+)\s*}}/g,(ne,P)=>{const Y=fe(J,P.trim());return Y??""}),$e=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(J=>$e(J)).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()},Pe=U=>{const J=U.key||U.name;if(J){if(d.value===J){u.value=u.value==="asc"?"desc":"asc";return}d.value=J,u.value="asc"}};async function Fe(){Z.value="Додати",oe.value=!0,be="add",me.value={}}function _e(U,J){if(!U?.length)return null;const ne=typeof J=="object"?J?.id:J;return ne==null||ne===""?null:U.find(P=>P?.id?.toString()===ne.toString())?.text??null}function Ne(U){return U==null||U===""?"-":Array.isArray(U)?U.map(J=>typeof J=="object"?J?.text??J?.id??"-":J).join(", "):typeof U=="object"?U?.text??U?.id??"-":U}function Be(U,J){const ne=J.key||J.name,P=U?.[ne],Y=i.value[ne];if(!P)return"-";if(Array.isArray(P)){const Ve=P.map(Ce=>_e(Y,Ce)).filter(Boolean);return Ve.length?Ve.join(", "):Ne(P)}const we=_e(Y,P);return we||Ne(P)}async function Ae(U,J){Z.value="Редагувати",oe.value=!0,be="edit",pe=J,me.value={...U}}function Re(){const U=Q.value.validate();if(U){ue.notify({type:"warning",title:"Помилка валідації",message:Object.entries(U).map(([J,ne])=>`${J}: ${ne}`).join(`
2
- `)});return}be==="add"?Array.isArray(s.value)?s.value=[...s.value,me.value]:s.value=[me.value]:s.value=s.value.map((J,ne)=>ne===pe?me.value:J),oe.value=!1}function Oe(U){s.value=s.value.filter((J,ne)=>ne!==U)}function tt(){oe.value=!1}return(U,J)=>(e.openBlock(),e.createElementBlock("div",Si,[a.value?(e.openBlock(),e.createElementBlock("div",$i,[r("search")?(e.openBlock(),e.createElementBlock("div",Ni,[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":J[0]||(J[0]=ne=>c.value=ne),placeholder:"Пошук",class:"w-full rounded-md border border-gray-200 bg-white pl-10 pr-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100"},null,512),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),e.createElementVNode("div",Ai,[r("import")?(e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"fileInput",ref:h,onChange:V,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"}),J[4]||(J[4]=e.createTextVNode(" Імпорт ",-1))])):e.createCommentVNode("",!0),r("export")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:M,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"}),J[5]||(J[5]=e.createTextVNode(" Експорт ",-1))])):e.createCommentVNode("",!0),r("add")?(e.openBlock(),e.createElementBlock("button",{key:3,onClick:Fe,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"}),J[6]||(J[6]=e.createTextVNode(" Додати ",-1))])):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Mi,[e.createElementVNode("table",Fi,[e.createElementVNode("thead",Di,[e.createElementVNode("tr",Ti,[e.createElementVNode("th",Li,[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(g.value,ne=>(e.openBlock(),e.createElementBlock("th",{key:ne.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[e.createElementVNode("button",{type:"button",onClick:P=>Pe(ne),class:"flex items-center gap-1 text-xs font-semibold text-gray-700 hover:text-gray-900 transition-colors"},[e.createElementVNode("span",null,e.toDisplayString(ne.ua||ne.label),1),d.value===(ne.key||ne.name)?(e.openBlock(),e.createElementBlock("span",Ri,e.toDisplayString(u.value==="asc"?"▲":"▼"),1)):e.createCommentVNode("",!0)],8,Ii)]))),128)),J[7]||(J[7]=e.createElementVNode("th",{class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 text-center w-[1%] whitespace-nowrap"}," Дії ",-1))])]),e.createElementVNode("tbody",{class:e.normalizeClass(["divide-y divide-gray-200",{"[&_tr:last-child]:border-0":!m.value}])},[p.value.length===0?(e.openBlock(),e.createElementBlock("td",Oi,[e.createElementVNode("div",Pi,[e.createElementVNode("div",zi,[e.createVNode(Vi,{class:"w-48 mx-auto"}),J[8]||(J[8]=e.createElementVNode("div",{class:"max-w-sm mx-auto mt-6"},[e.createElementVNode("p",{class:"font-medium text-gray-800 dark:text-neutral-200"},"Нічого не знайдено"),e.createElementVNode("p",{class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"})],-1))])])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(ne,P)=>(e.openBlock(),e.createElementBlock("tr",{key:ne.id,"data-row-index":P,class:e.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":b.value===P,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":m.value===P}]),draggable:"true",onDragstart:Y=>W(P),onDragover:e.withModifiers(Y=>T(P),["prevent"]),onDrop:Y=>E(P)},[e.createElementVNode("td",{class:"px-4 py-3 text-center align-middle touch-none select-none",onPointerdown:Y=>x(Y,P),onPointermove:C,onPointerup:S,onPointercancel:H},[e.createElementVNode("div",Hi,[e.createVNode(e.unref(q.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])],40,Ui),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,Y=>(e.openBlock(),e.createElementBlock("td",{key:Y.key,class:"px-4 py-3 align-middle"},[ee(Y)==="slot"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[ie(Y.slot)?e.renderSlot(U.$slots,Y.slot,{key:0,row:ne,value:ne[Y.key],column:Y}):(e.openBlock(),e.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:Ee(Y.slot,ne)},null,8,qi))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[ee(Y)==="file"?(e.openBlock(),e.createElementBlock("div",Ki,[N(Be(ne,Y))?(e.openBlock(),e.createElementBlock("div",Wi,[e.createElementVNode("img",{src:Be(ne,Y),alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,Gi)])):(e.openBlock(),e.createElementBlock("div",Yi,[e.createVNode(e.unref(q.FileText),{class:"h-4 w-4 min-w-4"})]))])):ee(Y)==="color"?(e.openBlock(),e.createElementBlock("div",Xi,[e.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:e.normalizeStyle({backgroundColor:Be(ne,Y)||"#ffffff"})},null,4)])):(e.openBlock(),e.createElementBlock("div",Zi,e.toDisplayString(Be(ne,Y)),1))],64))]))),128)),e.createElementVNode("td",Ji,[e.createElementVNode("div",Qi,[e.createElementVNode("button",{onClick:Y=>Ae(ne,P),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,ec),e.createElementVNode("button",{onClick:Y=>Oe(P),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,tc)])])],42,ji))),128))],2)])]),e.createVNode(e.unref(ue.VsModal),{visible:oe.value,title:Z.value,size:"lg",onClose:tt,teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(at,{schema:ae.value,"form-id":"datatable-row",values:me.value,"onUpdate:values":J[1]||(J[1]=ne=>me.value=ne),form:Q.value,"onUpdate:form":J[2]||(J[2]=ne=>Q.value=ne)},null,8,["schema","values","form"]),e.createElementVNode("div",nc,[e.createElementVNode("button",{type:"button",onClick:J[3]||(J[3]=ne=>oe.value=!1),class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:Re,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])]),_:1},8,["visible","title"])]))}}),oc={},rc={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 lc(o,t){return e.openBlock(),e.createElementBlock("svg",rc,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 ac=ye(oc,[["render",lc]]),sc={},ic={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 cc(o,t){return e.openBlock(),e.createElementBlock("svg",ic,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 dc=ye(sc,[["render",cc]]),uc={},pc={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 fc(o,t){return e.openBlock(),e.createElementBlock("svg",pc,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 mc=ye(uc,[["render",fc]]),hc={class:"bg-white/30 p-1 rounded-md shadow w-fit"},gc={class:"flex gap-2"},yc=["onClick","title"],bc=["src"],kc=e.defineComponent({__name:"map-layers",props:{basemaps:{}},emits:["onLayerChange"],setup(o,{emit:t}){const n=o,r=e.ref(Object.keys(n.basemaps)[0]),l=t;function a(c){l("onLayerChange",c),r.value=c}const s={z:13,x:4790,y:2762};function i(c){if(c?.preview)return c.preview;if(!c?.url)return;const d={"{z}":s.z,"{x}":s.x,"{y}":s.y};let u=c.url;return Object.entries(d).forEach(([p,g])=>{u=u.replace(new RegExp(p,"gi"),String(g))}),u}return(c,d)=>(e.openBlock(),e.createElementBlock("div",hc,[e.createElementVNode("div",gc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.basemaps,(u,p)=>(e.openBlock(),e.createElementBlock("div",{key:p,class:e.normalizeClass(["cursor-pointer border rounded-lg overflow-hidden hover:shadow-sm",{"ring-2 ring-blue-500 border-blue-300":r.value===p}]),onClick:g=>a(p),title:u.name||p,role:"button",tabindex:"0"},[e.createElementVNode("img",{src:i(u),alt:"",class:"w-10 h-10 object-cover"},null,8,bc)],10,yc))),128))])]))}}),Lt=1e-10,xn=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,xc=/^[+-]?\d+(?:\.\d+)?$/;function wc(o,t,n){const r=o.split(/\r?\n/).map(d=>d.trim()).filter(Boolean);if(r.length<3)return{ok:!1,errors:[{line:0,message:"Має бути щонайменше 3 рядки координат."}]};if(r.length>100)return{ok:!1,errors:[{line:0,message:"Допускається не більше 100 рядків координат."}]};const l=[],a=[];if(r.forEach((d,u)=>{const p=u+1,g=t==="decimal"?_c(d,p,n):Uo(d,p,n);if(!g.ok){l.push(...g.errors);return}const b=a[a.length-1];if(b&&qo(b,g.point)){l.push({line:p,message:"Послідовні точки не повинні дублюватися."});return}a.push(g.point)}),l.length)return{ok:!1,errors:l};if(new Set(a.map(vc)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const i=[...a];let c=!1;return qo(i[0],i[i.length-1])||(i.push(i[0]),c=!0),Ec(i)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:i,wasClosedAutomatically:c}}function _c(o,t,n){return jo(o,"decimal",n,t)}function jo(o,t,n,r=1){return t==="decimal"?Cc(o,r,n):Uo(o,r,n)}function Cc(o,t,n){const r=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(o))return{ok:!1,errors:[{line:t,message:"У десятковому форматі не допускаються літери."}]};const l=o.split(/[\s,;]+/).filter(Boolean);if(l.length<2)return{ok:!1,errors:[{line:t,message:"Кожен рядок має містити дві координати."}]};if(l.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(!l.every(d=>xc.test(d)))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const a=Number(l[0]),s=Number(l[1]);if(!Number.isFinite(a)||!Number.isFinite(s))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const i=n==="lat-lon"?a:s,c=n==="lat-lon"?s:a;return(i<-90||i>90)&&r.push({line:t,message:"Широта поза діапазоном (-90..90)."}),(c<-180||c>180)&&r.push({line:t,message:"Довгота поза діапазоном (-180..180)."}),r.length?{ok:!1,errors:r}:{ok:!0,point:[c,i]}}function Uo(o,t,n){xn.lastIndex=0;const r=[...o.matchAll(xn)];if(r.length<2)return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати DMS-координати."}]};if(r.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(xn.lastIndex=0,o.replace(xn," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:t,message:"У рядку виявлено зайві символи або значення."}]};const a=Ho(r[0],t,n==="lat-lon"?"lat":"lon"),s=Ho(r[1],t,n==="lat-lon"?"lon":"lat"),i=[];if(a.ok||i.push(a.error),s.ok||i.push(s.error),i.length)return{ok:!1,errors:i};const c=n==="lat-lon"?a.value:s.value;return{ok:!0,point:[n==="lat-lon"?s.value:a.value,c]}}function Ho(o,t,n){const r=Number(o[1]),l=Number(o[2]),a=Number(o[3]),s=String(o[4]).toUpperCase();if(!Number.isFinite(r)||!Number.isFinite(l)||!Number.isFinite(a))return{ok:!1,error:{line:t,message:"Невірні значення DMS-координат."}};if(n==="lat"&&!(s==="N"||s==="S")||n==="lon"&&!(s==="E"||s==="W"))return{ok:!1,error:{line:t,message:n==="lat"?"Для широти напрям повинен бути N або S.":"Для довготи напрям повинен бути E або W."}};if(l<0||l>59)return{ok:!1,error:{line:t,message:"Хвилини повинні бути в діапазоні 0..59."}};if(a<0||a>60)return{ok:!1,error:{line:t,message:"Секунди повинні бути в діапазоні 0..60."}};const d=Math.abs(r),u=n==="lat"?90:180;if(d>u)return{ok:!1,error:{line:t,message:n==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===u&&(l!==0||a!==0))return{ok:!1,error:{line:t,message:n==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const p=d+l/60+a/3600;return{ok:!0,value:s==="S"||s==="W"?-p:p}}function vc(o){return`${o[0].toFixed(12)}:${o[1].toFixed(12)}`}function qo(o,t){return Math.abs(o[0]-t[0])<Lt&&Math.abs(o[1]-t[1])<Lt}function Ec(o){if(o.length<4)return!1;for(let t=0;t<o.length-1;t+=1){const n=o[t],r=o[t+1];for(let l=t+1;l<o.length-1;l+=1){if(Math.abs(t-l)<=1||t===0&&l===o.length-2)continue;const a=o[l],s=o[l+1];if(Bc(n,r,a,s))return!0}}return!1}function Bc(o,t,n,r){const l=wn(o,t,n),a=wn(o,t,r),s=wn(n,r,o),i=wn(n,r,t);return!!(l!==a&&s!==i||l===0&&_n(o,n,t)||a===0&&_n(o,r,t)||s===0&&_n(n,o,r)||i===0&&_n(n,t,r))}function wn(o,t,n){const r=(t[1]-o[1])*(n[0]-t[0])-(t[0]-o[0])*(n[1]-t[1]);return Math.abs(r)<Lt?0:r>0?1:2}function _n(o,t,n){return t[0]<=Math.max(o[0],n[0])+Lt&&t[0]+Lt>=Math.min(o[0],n[0])&&t[1]<=Math.max(o[1],n[1])+Lt&&t[1]+Lt>=Math.min(o[1],n[1])}const Vc=["title"],Sc={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"},$c=["onClick"],Nc=["placeholder"],Ac={class:"absolute inset-y-0 right-2 flex items-center gap-1"},Mc={class:"flex items-center justify-between gap-2 px-3 py-2 border-b border-gray-100"},Fc={class:"text-xs font-semibold uppercase tracking-wide text-gray-500"},Dc={class:"max-h-[260px] overflow-auto"},Tc={key:0,class:"divide-y divide-gray-100"},Lc=["onClick"],Ic={key:1,class:"px-3 py-3 text-xs text-gray-500"},Ko="formMapSearchAddressHistory",Rc=12,Oc="https://geo.rv.ua/api-user/dzk.api",Pc="https://nominatim.openstreetmap.org/search",zc=ye(e.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(o,{emit:t}){const n={mounted(R,_){if(typeof document>"u")return;let A=null;const z=8,re=()=>{const Me=String(_?.value??"");if(!Me)return;A=document.createElement("div"),A.textContent=Me,Object.assign(A.style,{position:"absolute",background:"#333",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"9999"}),document.body.appendChild(A);const Se=R.getBoundingClientRect();A.style.left=`${Se.right+window.scrollX+z}px`,A.style.top=`${Se.top+window.scrollY+(Se.height-A.offsetHeight)/2}px`},ke=()=>{A?.parentNode&&A.parentNode.removeChild(A),A=null};R.addEventListener("mouseenter",re),R.addEventListener("mouseleave",ke),Object.assign(R,{tooltipRightHandlers:{show:re,hide:ke}})},unmounted(R){if(typeof document>"u")return;const _=R.tooltipRightHandlers;_&&(R.removeEventListener("mouseenter",_.show),R.removeEventListener("mouseleave",_.hide))}},r=o,l=t,a=e.getCurrentInstance();function s(){return typeof globalThis<"u"&&globalThis.proxy?globalThis.proxy:typeof window<"u"&&window.proxy?window.proxy:null}function i(){const _=a?.appContext.config.globalProperties?.$settings?.map?.searchViewbox;if(_)return Array.isArray(_)?_.join(","):String(_);const z=s()?.map?.searchViewbox;if(z)return Array.isArray(z)?z.join(","):String(z)}function c(){const _=a?.appContext.config.globalProperties?.$settings?.map?.addressSuggest;if(typeof _=="string"&&_.trim())return _.trim();const z=s()?.map?.addressSuggest;if(typeof z=="string"&&z.trim())return z.trim()}function d(){if(typeof r.config?.cadastreSuggest=="string"&&r.config.cadastreSuggest.trim())return r.config.cadastreSuggest.trim();const R=a?.appContext.config.globalProperties?.$settings,_=R?.map?.cadastreSuggest??R?.map?.parcelSuggest??R?.map?.parcelSearch;if(typeof _=="string"&&_.trim())return _.trim();const A=s(),z=A?.map?.cadastreSuggest??A?.map?.parcelSuggest??A?.map?.parcelSearch;if(typeof z=="string"&&z.trim())return z.trim()}const u=!!c(),p=!!i(),g=e.computed(()=>{const R=["nominatim","xy","parcel"];return u&&R.unshift("address"),p?R:R.filter(_=>_!=="nominatim")}),b=e.computed(()=>{const R=g.value,_=r.config?.tools?.filter(A=>R.includes(A));return _&&_.length?_:R}),m=e.computed(()=>r.config?.placeholder?.trim()||"Пошук…"),h=e.ref(b.value[0]);e.watch(b,R=>{R.includes(h.value)||(h.value=R[0])});const y=e.ref(""),w=e.ref(!1),x=e.ref(null),C=e.ref(null),S=e.ref(null),H=e.ref(null),W=e.ref([]),T=e.ref(null),E=e.ref(!1),$=e.ref([]),N=e.computed(()=>(h.value==="address"||h.value==="nominatim")&&E.value),V=e.computed(()=>r.config?.addressDebounceMs??1e3);let M=null;const O=e.ref(!1),B=e.computed(()=>y.value.trim().length>0?W.value:$.value),K=e.computed(()=>y.value.trim().length?`Знайдено ${W.value.length}`:"Історія пошуку"),I=e.computed(()=>y.value.trim().length?"Нічого не знайдено":"Історія порожня");function G(){if(typeof window>"u")return[];try{const R=window.localStorage?.getItem?.(Ko);if(!R)return[];const _=JSON.parse(R);return Array.isArray(_)?_:[]}catch{return[]}}function L(R){typeof window>"u"||window.localStorage?.setItem?.(Ko,JSON.stringify(R))}function Z(R){const A=[R,...$.value.filter(z=>z.id!==R.id)].slice(0,10);$.value=A,L(A)}const oe=e.reactive({position:"absolute",left:"0px",top:"0px",width:"100%",display:"none"});function be(){if(!H.value)return;const R=H.value.getBoundingClientRect(),_=S.value?.getBoundingClientRect(),A=_?.width??R.width,z=(_?.left??R.left)+window.scrollX,re=R.bottom+window.scrollY+Rc;oe.left=`${z}px`,oe.top=`${re}px`,oe.width=`${A}px`,oe.display="block"}const pe=()=>{N.value&&be()};function ee(){M&&(clearTimeout(M),M=null)}e.watch(h,()=>{y.value="",w.value=!1,W.value=[],E.value=!1,ee(),O.value=!1}),e.watch(N,R=>{R?e.nextTick(()=>{be()}):oe.display="none"}),e.watch(y,R=>{if(h.value!=="address"&&h.value!=="nominatim"){W.value=[],ee();return}if(!R.trim()){W.value=[],E.value=$.value.length>0,ee();return}ee(),E.value=!0,M=window.setTimeout(()=>{ne(R).catch(_=>{const A=_?.message||"Помилка пошуку адреси";ue.notify({type:"error",title:"Пошук адреси",message:A})})},V.value)});function ae(R){const _=[];C.value&&_.push(C.value),R instanceof HTMLElement&&_.push(R),x.value?.querySelectorAll("li")?.forEach(z=>{_.push(z)}),_.forEach(z=>{z.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))})}function me(R){w.value&&ae(R.target),w.value=!w.value}function Q(R,_){ae(_?.target),h.value=R}function ie(){y.value="",W.value=[],E.value=!1,O.value=!1}function fe(R){const _=R.target;if(w.value){const A=x.value;A&&!A.contains(_)&&(ae(_),w.value=!1)}if(N.value){const A=T.value,z=H.value;A&&!A.contains(_)&&(!z||!z.contains(_))&&(E.value=!1)}}e.onMounted(()=>{$.value=G(),window.addEventListener("click",fe,!0),window.addEventListener("scroll",pe,!0),window.addEventListener("resize",pe)}),e.onBeforeUnmount(()=>{window.removeEventListener("click",fe,!0),window.removeEventListener("scroll",pe,!0),window.removeEventListener("resize",pe),ee()});function Ee(R){return R==="xy"?"Координати":R==="parcel"?"Кадастр":R==="nominatim"?"Адреса":"Адресний"}function $e(R){switch(R){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 Pe(R){const _=jo(R.trim(),"dms","lat-lon");if(_.ok){const[ze,nt]=_.point;return{lat:nt,lng:ze}}const A=R.replace(/[,]+/g," ").trim();if(!A)return null;const z=A.split(/\s+/).filter(Boolean);if(z.length<2)return null;const re=z.slice(0,2).map(Number);if(!re.every(ze=>Number.isFinite(ze)))return null;let[ke,Me]=re,Se=ke,We=Me;const st=ze=>Math.abs(ze)<=90,Ge=ze=>Math.abs(ze)<=180;if(!st(Se)||!Ge(We))if(st(We)&&Ge(Se))Se=Me,We=ke;else return null;return{lat:Se,lng:We}}function Fe(R){const _=R?.result||R?.data||R;return(Array.isArray(_)?_:_?[_]:[]).map((z,re)=>{const ke=z?.geom_centroid,Me=Array.isArray(ke?.coordinates)?ke.coordinates:null;if(!Me||Me.length<2)return null;const Se=Number(Me[0]),We=Number(Me[1]);return!Number.isFinite(We)||!Number.isFinite(Se)?null:{id:String(z?.parcel_id??z?.cad_num??re),title:z?.cadnum||z?.cad_num||"Земельна ділянка",lat:We,lng:Se}}).filter(z=>!!z)}function _e(R){return(Array.isArray(R?.features)?R.features:[]).map((A,z)=>{const re=A?.geometry?.coordinates,ke=Number(re?.[0]),Me=Number(re?.[1]);if(!Number.isFinite(Me)||!Number.isFinite(ke))return null;const Se=A?.properties||{},We=Se?.geocoding?.label||Se?.display_name||Se?.label||"Адреса";return{id:String(Se?.geocoding?.place_id||Se?.place_id||z),title:We,lat:Me,lng:ke}}).filter(A=>!!A)}function Ne(R){return Number.isFinite(R.lat)&&Number.isFinite(R.lng)}function Be(R){if(R==null||typeof R=="string"&&!R.trim())return null;const _=Number(R);return Number.isFinite(_)?_:null}function Ae(R){const _=Be(R.lng)??Be(R.lon)??Be(R.longitude)??Be(R.x),A=Be(R.lat)??Be(R.latitude)??Be(R.y);if(_!=null&&A!=null)return{lat:A,lng:_};const z=R?.geometry?.coordinates??R?.geom_centroid?.coordinates??R?.centroid?.coordinates??R?.geojson?.geometry?.coordinates??R?.geom?.coordinates;if(Array.isArray(z)&&z.length>=2){const re=Be(z[0]),ke=Be(z[1]);if(re!=null&&ke!=null)return{lat:ke,lng:re}}return null}function Re(R){return(Array.isArray(R?.data)?R.data:[]).map((A,z)=>{const re=Ae(A),ke=String(A.text??A.title??A.label??A.name??A.address??A.display_name??A.id??"Адреса"),Me=String(A.id??A.code??A.value??z);return re?{id:Me,title:ke,...re}:{id:Me,title:ke}}).filter(A=>!!A?.title)}function Oe(R){const _=d()||Oc;if(_.includes(":id"))return _.replace(":id",encodeURIComponent(R));if(_.includes(":name"))return _.replace(":name",encodeURIComponent(R));try{const A=new URL(_,window.location.origin),z=r.config?.parcelQueryParam?.trim()||"cad_num";return A.searchParams.set(z,R),A.toString()}catch{return _}}function tt(R){const _=c();if(!_)return null;if(_.includes(":name"))return _.replace(":name",encodeURIComponent(R));try{const A=new URL(_,window.location.origin);return R.trim()&&A.searchParams.set("q",R),A.toString()}catch{return _}}async function U(R){const _=tt(R);if(!_)return[];const A=await fetch(_);if(!A.ok)throw new Error(`HTTP ${A.status}`);const z=await A.json();return Re(z)}async function J(R){const _=new URL(Pc);_.searchParams.set("format","geojson"),_.searchParams.set("q",R),_.searchParams.set("addressdetails","1"),_.searchParams.set("bounded","1");const A=i();A&&_.searchParams.set("viewbox",A);const z=await fetch(_.toString());if(!z.ok)throw new Error(`HTTP ${z.status}`);const re=await z.json();return _e(re)}async function ne(R){if(W.value=[],ee(),h.value==="address"){if(!c()){ue.notify({type:"warning",title:"Пошук адреси",message:"Не налаштовано addressSuggest"});return}const z=await U(R);if(!z.length){ue.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}W.value=z;return}const _=await J(R);if(!_.length){ue.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}W.value=_}async function P(R){if(Ne(R)){Ve(R),Z(R);return}ue.notify({type:"warning",title:"Пошук адреси",message:"Геометрія для обраної адреси відсутня"})}function Y(){h.value!=="address"&&h.value!=="nominatim"||(E.value=!0,e.nextTick(()=>{be()}))}function we(R){const A=R.replace(/\s+/g,"").split(":");if(A.length!==4)return!1;const z=[10,2,3,4];return A.every((re,ke)=>re.length===z[ke]&&/^\d+$/.test(re))}function Ve(R){l("goToCoordinates",[R.lat,R.lng]),O.value=!0}async function Ce(){const R=y.value.trim();if(R){if(h.value==="xy"){const _=Pe(R);if(!_){ue.notify({type:"warning",title:"Пошук координат",message:"Використайте `lat lon` або DMS у форматі `50°27'00\"N 30°31'24\"E`."});return}Ve(_);return}if(h.value==="address"||h.value==="nominatim"){try{await ne(R)}catch(_){const A=_?.message||"Помилка пошуку адреси";ue.notify({type:"error",title:"Пошук адреси",message:A})}return}try{if(!we(R)){ue.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}const _=await fetch(Oe(R));if(!_.ok)throw new Error(`HTTP ${_.status}`);const A=await _.json(),z=Fe(A);if(!z.length)ue.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const re=z.find(Ne);if(!re){ue.notify({type:"warning",title:"Пошук",message:"Геометрія ділянки відсутня"});return}Ve(re)}}catch(_){const A=_?.message||"Помилка пошуку";ue.notify({type:"error",title:"Пошук",message:A})}}}return(R,_)=>(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(Ce,["prevent"])},[b.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:me},[e.withDirectives((e.openBlock(),e.createElementBlock("span",{ref_key:"selectedToolLabelRef",ref:C,class:"block w-full truncate",title:Ee(h.value)},[e.createTextVNode(e.toDisplayString(Ee(h.value)),1)],8,Vc)),[[n,$e(h.value)]]),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-4 h-4 text-gray-500 transition-transform",{"rotate-180":w.value}]),viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},_[3]||(_[3]=[e.createElementVNode("path",{d:"M6 9l6 6 6-6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)]),2))]),w.value?(e.openBlock(),e.createElementBlock("div",Sc,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,A=>e.withDirectives((e.openBlock(),e.createElementBlock("li",{key:A,class:"px-3 py-2 cursor-pointer hover:bg-gray-100 text-gray-900",onClick:z=>Q(A,z)},[e.createTextVNode(e.toDisplayString(Ee(A)),1)],8,$c)),[[n,$e(A)]])),128))])])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"searchWrapperRef",ref:H,class:"relative flex-1 min-w-[140px]"},[h.value==="parcel"?(e.openBlock(),e.createBlock(mn,{key:0,modelValue:y.value,"onUpdate:modelValue":_[0]||(_[0]=A=>y.value=A),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",O.value?"!pr-14":"!pr-8"])},null,8,["modelValue","class"])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":_[1]||(_[1]=A=>y.value=A),placeholder:m.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",O.value?"!pr-14":"!pr-8"]),onFocus:Y},null,42,Nc)),[[e.vModelText,y.value,void 0,{trim:!0}]]),e.createElementVNode("div",Ac,[O.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Очистити",onClick:ie},_[4]||(_[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),_[5]||(_[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))]),N.value?(e.openBlock(),e.createBlock(e.Teleport,{key:2,to:"body"},[e.createElementVNode("div",{ref_key:"addressResultsRef",ref:T,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(oe)},[e.createElementVNode("div",Mc,[e.createElementVNode("span",Fc,e.toDisplayString(K.value),1),e.createElementVNode("button",{type:"button",class:"text-gray-400 hover:text-gray-600","aria-label":"Закрити",onClick:_[2]||(_[2]=A=>E.value=!1)}," ✕ ")]),e.createElementVNode("div",Dc,[B.value.length?(e.openBlock(),e.createElementBlock("ul",Tc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,A=>(e.openBlock(),e.createElementBlock("li",{key:A.id,class:"px-3 py-2 cursor-pointer hover:bg-gray-50",onClick:z=>P(A)},e.toDisplayString(A.title),9,Lc))),128))])):(e.openBlock(),e.createElementBlock("div",Ic,e.toDisplayString(I.value),1))])],4)])):e.createCommentVNode("",!0)],512)],32)],512))}}),[["__scopeId","data-v-4d528cf7"]]),jc={class:"pt-1 border-t border-gray-100"},Uc={class:"space-y-1"},Hc=e.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(o,{emit:t}){const n=t,r=e.ref(null),l=e.ref(null),a=(c,d,u)=>Math.min(Math.max(c,d),u),s=()=>{if(r.value===null||l.value===null||!Number.isFinite(r.value)||!Number.isFinite(l.value))return;const c=a(r.value,-90,90),d=a(l.value,-180,180);n("submit",{lat:c,lng:d}),r.value=null,l.value=null},i=()=>{r.value=null,l.value=null,n("cancel")};return(c,d)=>(e.openBlock(),e.createElementBlock("div",jc,[d[2]||(d[2]=e.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),e.createElementVNode("div",Uc,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[0]||(d[0]=u=>r.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта (50.4501)"},null,512),[[e.vModelText,r.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=u=>l.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота (30.5234)"},null,512),[[e.vModelText,l.value,void 0,{number:!0}]]),e.createElementVNode("div",{class:"flex gap-1.5"},[e.createElementVNode("button",{class:"flex-1 px-2 py-1 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors",type:"button",onClick:s}," Додати "),e.createElementVNode("button",{class:"px-2 py-1 bg-gray-200 hover:bg-gray-300 text-gray-700 text-xs font-medium rounded transition-colors",type:"button",onClick:i}," Скасувати ")])])]))}}),qc=e.defineComponent({__name:"BtnAdd",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Plus),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Додати ",-1))]))}}),Kc=e.defineComponent({__name:"BtnClear",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"w-full px-2 py-1.5 bg-rose-500 hover:bg-rose-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Trash2),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Очистити ",-1))]))}}),Wc=e.defineComponent({__name:"BtnComplete",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Circle),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode("Замкнути ",-1))]))}}),Gc=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function It(o){return Gc.format(o)}function Wo(o){return o>=1e3?`${It(o/1e3)} км`:`${It(o)} м`}const Yc={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},Xc={key:0,class:"flex-1 flex gap-1"},Zc={key:1,class:"flex-1 font-mono text-gray-700"},Jc=e.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(o,{emit:t}){const n=o,r=t,l=e.computed(()=>`${n.coords.lat.toFixed(4)}°, ${n.coords.lng.toFixed(4)}°`),a=e.ref(!1),s=e.ref(n.coords.lat),i=e.ref(n.coords.lng);e.watch(()=>n.coords,g=>{s.value=g.lat,i.value=g.lng},{deep:!0,immediate:!0});const c=(g,b,m)=>Math.min(Math.max(g,b),m),d=()=>{a.value=!0},u=()=>{if(!Number.isFinite(s.value)||!Number.isFinite(i.value))return;const g=c(s.value,-90,90),b=c(i.value,-180,180);r("update",{id:n.id,coords:{lat:g,lng:b}}),a.value=!1},p=()=>{r("delete",n.id)};return(g,b)=>(e.openBlock(),e.createElementBlock("div",Yc,[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",Xc,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[0]||(b[0]=m=>s.value=m),type:"number",step:"0.0001",min:"-90",max:"90",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":b[1]||(b[1]=m=>i.value=m),type:"number",step:"0.0001",min:"-180",max:"180",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота"},null,512),[[e.vModelText,i.value,void 0,{number:!0}]]),e.createElementVNode("button",{class:"px-1.5 py-0.5 bg-emerald-500 text-white rounded hover:bg-emerald-600 text-xs",type:"button",onClick:u}," ✓ ")])):(e.openBlock(),e.createElementBlock("span",Zc,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}," ✕ ")]))}}),Qc={class:"ruler-control px-3 py-2.5 space-y-2"},ed={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},td={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"},nd={class:"text-sm font-semibold text-slate-700"},od={class:"ruler-row"},rd={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},ld={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"},ad={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},sd=["onClick"],id={class:"flex items-center gap-2 mt-0.5 pl-7"},cd={key:0,class:"text-base font-semibold text-green-600"},dd={key:1,class:"text-xs text-gray-400"},ud={class:"ruler-row flex items-center gap-2 cursor-pointer"},pd={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"},fd={class:"text-xs font-medium text-gray-600 flex-1"},md={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},hd=e.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(o){const t=o,n=e.ref(!1),r=e.ref("km2"),l=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],a=()=>{n.value=!n.value},s=(m,h)=>{const y=$=>$*Math.PI/180,w=y(h.lat-m.lat),x=y(h.lng-m.lng),C=y(m.lat),S=y(h.lat),H=Math.sin(w/2),W=Math.sin(x/2);return 6371e3*(2*Math.asin(Math.sqrt(H*H+Math.cos(C)*Math.cos(S)*W*W)))},i=e.computed(()=>{if(t.points.length<2)return 0;let m=0;for(let h=1;h<t.points.length;h+=1)m+=s(t.points[h-1].coords,t.points[h].coords);return t.isShapeClosed&&t.points.length>=2&&(m+=s(t.points[t.points.length-1].coords,t.points[0].coords)),m}),c=e.computed(()=>i.value>=1e3?`${It(i.value/1e3)} км`:`${It(i.value)} м`);function d(m){if(m.length<3)return 0;const h=m[0].lat,y=m[0].lng,w=(C,S)=>{const H=(C-h)*110574;return{x:(S-y)*111320*Math.cos(h*Math.PI/180),y:H}};let x=0;for(let C=0;C<m.length;C++){const S=(C+1)%m.length,H=w(m[C].lat,m[C].lng),W=w(m[S].lat,m[S].lng);x+=H.x*W.y-H.y*W.x}return Math.abs(x)*.5}const u=e.computed(()=>{if(!t.isShapeClosed||t.points.length<3)return 0;const m=t.points.map(h=>h.coords);return d(m)}),p=e.computed(()=>u.value>0),g=e.computed(()=>{const m=u.value;if(m===0)return"—";if(r.value==="km2"){const y=m/1e6;return`${It(y)} км²`}if(r.value==="ha"){const y=m/1e4;return`${It(y)} га`}const h=m>=1?Math.round(m):m;return`${It(h)} м²`}),b=e.computed(()=>{const m=t.points.length;return m===1?"1 точка":m>=2&&m<=4?`${m} точки`:`${m} точок`});return e.watch(()=>t.points.length,()=>{t.points.length===0&&(n.value=!1)}),(m,h)=>(e.openBlock(),e.createElementBlock("div",Qc,[e.createElementVNode("button",ed,[e.createElementVNode("span",td,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),h[1]||(h[1]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),e.createElementVNode("span",nd,e.toDisplayString(c.value),1)]),e.createElementVNode("div",od,[e.createElementVNode("button",rd,[e.createElementVNode("span",ld,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),h[2]||(h[2]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),e.createElementVNode("div",ad,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,(y,w)=>e.createElementVNode("button",{key:y.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",w===0&&"rounded-l-md",w===l.length-1&&"rounded-r-md",r.value===y.id?"bg-white text-green-600 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-50"]),onClick:e.withModifiers(x=>r.value=y.id,["stop"])},e.toDisplayString(y.label),11,sd)),64))])]),e.createElementVNode("div",id,[p.value?(e.openBlock(),e.createElementBlock("span",cd,e.toDisplayString(g.value),1)):(e.openBlock(),e.createElementBlock("span",dd,"—"))])]),e.createElementVNode("div",ud,[e.createElementVNode("span",pd,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),e.createElementVNode("span",fd,e.toDisplayString(b.value),1),e.createElementVNode("button",{type:"button",class:"text-xs text-blue-500 hover:text-blue-600 font-medium transition-colors",onClick:e.withModifiers(a,["stop"])}," Координати ")]),n.value?(e.openBlock(),e.createElementBlock("div",md,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.points,(y,w)=>(e.openBlock(),e.createBlock(Jc,{key:y.id,id:y.id,index:w+1,coords:y.coords,onUpdate:h[0]||(h[0]=x=>m.$emit("update-point",x)),onDelete:x=>m.$emit("delete-point",y.id)},null,8,["id","index","coords","onDelete"]))),128))])):e.createCommentVNode("",!0)]))}}),gd={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},yd={class:"flex items-start gap-2"},bd=e.defineComponent({__name:"InfoHint",setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",gd,[e.createElementVNode("div",yd,[e.createVNode(e.unref(q.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),n[0]||(n[0]=e.createElementVNode("div",{class:"space-y-1"},[e.createElementVNode("p",{class:"text-xs font-medium text-blue-900"}," Натискайте на карту, щоб додати точки вимірювання "),e.createElementVNode("p",{class:"text-[10px] text-blue-700"},' Або скористайтесь кнопкою "Додати" внизу для введення координат вручну ')],-1))])]))}}),kd={class:"space-y-1.5"},xd={class:"space-y-1 max-h-40 overflow-y-auto"},wd={class:"text-gray-700"},_d={class:"font-semibold text-slate-800"},Cd=e.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(o){const t=o;function n(a,s){const i=b=>b*Math.PI/180,c=i(s.lat-a.lat),d=i(s.lng-a.lng),u=i(a.lat),p=i(s.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(c/2)**2+Math.cos(u)*Math.cos(p)*Math.sin(d/2)**2)))}function r(a){return Wo(a)}const l=e.computed(()=>{const a=[],s=t.points;if(s.length<2)return a;for(let i=0;i<s.length;i++){const c=i===s.length-1&&t.isShapeClosed?0:i+1;if(c>=s.length)break;const d=n(s[i].coords,s[c].coords);a.push({from:i+1,to:c+1,label:r(d)})}return a});return(a,s)=>(e.openBlock(),e.createElementBlock("div",kd,[s[0]||(s[0]=e.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),e.createElementVNode("div",xd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(i,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[e.createElementVNode("span",wd,"Точка "+e.toDisplayString(i.from)+" → Точка "+e.toDisplayString(i.to),1),e.createElementVNode("span",_d,e.toDisplayString(i.label),1)]))),128))])]))}}),vd={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},Ed={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},Bd={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},Vd={class:"flex items-center gap-2"},Sd={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},$d={class:"flex border-b border-gray-200"},Nd={key:1,class:"px-3 py-2.5"},Ad={key:1,class:"text-xs text-gray-500"},Md={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},Fd={class:"flex gap-1.5"},Dd=e.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(o,{expose:t,emit:n}){const r=n,l=e.ref([]),a=e.computed(()=>l.value.length>0),s=e.ref(!1),i=e.ref(!1),c=e.ref("general");function d(N){c.value=N,r("tab-change",N)}e.onMounted(()=>{r("tab-change",c.value)});const u=e.computed(()=>l.value.length>=3&&!i.value);let p=1;const g=()=>l.value.map(N=>({id:N.id,coords:{...N.coords}})),b=()=>{l.value.length<3&&i.value&&(i.value=!1,r("shape-closed-change",!1)),r("points-change",g())},m=()=>{const N=p;return p+=1,N},h=N=>{l.value=[...l.value,{id:m(),coords:{lat:N.lat,lng:N.lng}}],b()},y=({id:N,coords:V})=>{const M=l.value.findIndex(B=>B.id===N);if(M===-1)return;const O=[...l.value];O[M]={id:N,coords:{...V}},l.value=O,b()},w=N=>{l.value=l.value.filter(V=>V.id!==N),b()},x=()=>{l.value=[],i.value&&(i.value=!1,r("shape-closed-change",!1)),b()},C=N=>{y(N)},S=N=>{w(N)},H=()=>{s.value=!0,r("add-request")},W=N=>{h(N),s.value=!1},T=()=>{s.value=!1},E=()=>{u.value&&(i.value=!0,r("complete"),r("shape-closed-change",!0))},$=()=>{x(),s.value=!1,r("close")};return t({addPoint:h,clearPoints:x}),(N,V)=>(e.openBlock(),e.createElementBlock("div",vd,[e.createElementVNode("div",Ed,[e.createElementVNode("div",Bd,[e.createElementVNode("div",Vd,[e.createElementVNode("div",Sd,[e.createVNode(e.unref(q.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),V[2]||(V[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",$d,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:V[0]||(V[0]=M=>d("general"))}," Загальна ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:V[1]||(V[1]=M=>d("topoint"))}," До точки ",2)]),c.value==="general"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.value?(e.openBlock(),e.createBlock(hd,{key:1,points:l.value,"is-shape-closed":i.value,onUpdatePoint:C,onDeletePoint:S},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createBlock(bd,{key:0}))],64)):(e.openBlock(),e.createElementBlock("div",Nd,[a.value?(e.openBlock(),e.createBlock(Cd,{key:0,points:l.value,"is-shape-closed":i.value},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createElementBlock("p",Ad,"Додайте точки на карті, щоб бачити відстані між ними."))])),e.createElementVNode("div",Md,[e.createElementVNode("div",Fd,[s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(qc,{key:0,onClick:H})),u.value?(e.openBlock(),e.createBlock(Wc,{key:1,onClick:E})):e.createCommentVNode("",!0)]),s.value?(e.openBlock(),e.createBlock(Hc,{key:0,onSubmit:W,onCancel:T})):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(Kc,{key:1,onClick:x})):e.createCommentVNode("",!0)])])]))}}),Xe="ruler-points",_t="ruler-line",Ct="ruler-polygon",vt="ruler-segments",Td=e.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(o){function t(m,h){const y=W=>W*Math.PI/180,w=y(h.lat-m.lat),x=y(h.lng-m.lng),C=y(m.lat),S=y(h.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(w/2)**2+Math.cos(C)*Math.cos(S)*Math.sin(x/2)**2)))}function n(m){return Wo(m)}const r=o;function l(){return{type:"FeatureCollection",features:[]}}function a(m,h,y){const w=y??"general",x=[];let C=0;x.push(0);for(let S=1;S<m.length;S++)C+=t(m[S-1].coords,m[S].coords),x.push(C);return h&&m.length>=2&&(C+=t(m[m.length-1].coords,m[0].coords)),{type:"FeatureCollection",features:m.map((S,H)=>{const W=w==="general"?H===0?"0":n(x[H]):H===0?"0":n(t(m[H-1].coords,m[H].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[S.coords.lng,S.coords.lat]},properties:{id:S.id,index:H+1,label:W}}})}}function s(m,h){if(m.length<2)return l();const y=[];for(let w=0;w<m.length;w++){const x=w===m.length-1&&h?0:w+1;if(x>=m.length)break;const C=m[w].coords,S=m[x].coords,H=t(C,S);y.push({type:"Feature",geometry:{type:"LineString",coordinates:[[C.lng,C.lat],[S.lng,S.lat]]},properties:{distance:n(H)}})}return{type:"FeatureCollection",features:y}}function i(m,h){if(m.length<2)return l();const y=m.map(w=>[w.coords.lng,w.coords.lat]);return h&&y.push(y[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:y},properties:{}}]}}function c(m){if(m.length<3)return l();const h=m.map(y=>[y.coords.lng,y.coords.lat]);return h.push(h[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[h]},properties:{}}]}}let d=!1;function u(m){m.getSource(Xe)||(m.addSource(Xe,{type:"geojson",data:l()}),m.addLayer({id:`${Xe}-circle`,type:"circle",source:Xe,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),m.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}})),m.getSource(vt)||(m.addSource(vt,{type:"geojson",data:l()}),m.addLayer({id:`${vt}-labels`,type:"symbol",source:vt,layout:{"text-field":["get","distance"],"text-size":13,"symbol-placement":"line-center","text-rotation-alignment":"map","text-pitch-alignment":"map"},paint:{"text-color":"#1e293b","text-halo-color":"#ffffff","text-halo-width":1.5}})),m.getSource(_t)||(m.addSource(_t,{type:"geojson",data:l()}),m.addLayer({id:`${_t}-layer`,type:"line",source:_t,paint:{"line-color":"#3b82f6","line-width":2}})),m.getSource(Ct)||(m.addSource(Ct,{type:"geojson",data:l()}),m.addLayer({id:`${Ct}-layer`,type:"fill",source:Ct,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function p(m){if(m){try{m.getLayer(`${Ct}-layer`)&&m.removeLayer(`${Ct}-layer`),m.getSource(Ct)&&m.removeSource(Ct),m.getLayer(`${_t}-layer`)&&m.removeLayer(`${_t}-layer`),m.getSource(_t)&&m.removeSource(_t),m.getLayer(`${vt}-labels`)&&m.removeLayer(`${vt}-labels`),m.getSource(vt)&&m.removeSource(vt),m.getLayer(`${Xe}-labels`)&&m.removeLayer(`${Xe}-labels`),m.getLayer(`${Xe}-circle`)&&m.removeLayer(`${Xe}-circle`),m.getSource(Xe)&&m.removeSource(Xe)}catch{}d=!1}}function g(m){if(!m)return;const h=m.getSource(Xe),y=m.getSource(_t),w=m.getSource(Ct),x=m.getSource(vt),C=r.points,S=r.labelMode??"general";h&&h.setData(a(C,r.isShapeClosed,S)),y&&y.setData(i(C,r.isShapeClosed)),w&&w.setData(c(C)),x&&x.setData(S==="topoint"?s(C,r.isShapeClosed):l())}function b(){const m=r.map;m&&(d||u(m),g(m))}return e.watch(()=>[r.points,r.isShapeClosed,r.labelMode],()=>b(),{deep:!0,immediate:!0}),e.watch(()=>r.map,()=>b(),{immediate:!0}),e.onBeforeUnmount(()=>{p(r.map)}),(m,h)=>null}});function Ld(o={}){const t=e.ref(!1),n=e.ref([]),r=e.ref(!1),l=e.ref("general"),a=e.ref(null);function s(){t.value?i():(t.value=!0,o.onActivate?.())}function i(){t.value=!1,n.value=[],r.value=!1,a.value?.clearPoints(),o.onDeactivate?.()}function c(b){n.value=b}function d(b){l.value=b}function u(b){r.value=b}function p(b){t.value&&a.value?.addPoint({lat:b.lat,lng:b.lng})}const g=e.computed(()=>n.value.length>0);return{isRulerActive:t,rulerPoints:n,rulerShapeClosed:r,rulerActiveTab:l,rulerPanelRef:a,hasRulerPoints:g,toggleRuler:s,closeRuler:i,onRulerPointsChange:c,onRulerTabChange:d,onRulerShapeClosedChange:u,handleRulerMapClick:p}}const Id={key:0,class:"absolute top-4 left-4 z-[1000] w-[calc(100%-20px)] sm:w-[350px]"},Rd={key:1,class:"form-geom__panel flex gap-1 items-start mt-2"},Od={class:"flex items-center gap-1"},Pd=["disabled"],zd={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"},jd=["disabled"],Ud=["disabled"],Hd={class:"mt-4 flex justify-end gap-2"},qd=["disabled"],Kd={class:"absolute top-4 right-4 z-[1000]"},Wd={class:"flex flex-col gap-[2px]"},Gd=["disabled"],Yd=["disabled"],Xd=["disabled"],Zd=["disabled"],Jd={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"},Qd={class:"space-y-0.5"},eu={class:"text-gray-500"},tu={class:"text-gray-900 text-right break-all"},nu={class:"absolute left-4 bottom-[36px] z-[1000]"},ou={class:"flex flex-col gap-2"},ru={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]"},lu={class:"flex flex-col gap-1"},au=["checked","disabled","onChange"],su={class:"text-gray-700 text-xs font-medium"},iu={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"},cu={key:0,class:"form-geom__feature flex items-center text-xs transition-all gap-2 w-full px-2 pb-1"},du={class:"mr-auto flex items-center gap-2 min-w-0 relative"},uu={class:"shrink-0"},pu={key:0,class:"font-bold"},fu=["onClick","disabled"],mu={key:0},hu={class:"flex items-center"},gu={class:"text-xs mr-2"},yu={key:0},bu={key:1},ku={key:0,class:"text-xs mr-2"},xu={key:1,class:"text-xs mr-2"},wu=["disabled"],_u=["disabled"],Cn="__vs_form_maplibre_loader__",vn="vs-global-bounds-src",En="vs-global-bounds-line",Go=ye(e.defineComponent({__name:"vs-input-map",props:{tools:{},multi:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},handleZoom:{type:Boolean,default:!0},ctrlZoom:{type:Boolean,default:!0},geomType:{default:()=>[]},prefix:{default:""},katottg:{default:""},layers:{default:()=>[]},bounds:{},api:{},center:{default:void 0},zoom:{default:void 0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue","valueSelected"],setup(o,{emit:t}){const n=o,r=t,l=e.useAttrs(),a=e.computed(()=>{const f=l?.multiple,k=l?.multi,v=F=>F===""||F===!0||F==="true"||F===1||F==="1";return!!n.multi||!!n.multiple||v(k)||v(f)}),s=e.computed(()=>!!n.disabled),i=e.ref(!1),c=e.ref(null),d=e.ref(0),u=e.ref(""),p=e.ref(null),g=e.ref([]),b=e.ref(null),m=e.ref(null),h=Ld({onActivate(){if(Y)try{Y.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""},onDeactivate(){}});function y(){h.toggleRuler()}const w=e.getCurrentInstance(),x=w?.appContext?.config?.globalProperties?.$settings??{},C=x?.map??{},S=w?.vnode?.props??{};function H(f){return Object.prototype.hasOwnProperty.call(S,f)||Object.prototype.hasOwnProperty.call(S,f.replace(/[A-Z]/g,k=>`-${k.toLowerCase()}`))}const W=Array.isArray(C.center)&&C.center.length===2?C.center:Array.isArray(x.center)&&x.center.length===2?x.center:[30,50],T=typeof C.zoom=="number"?C.zoom:typeof x.zoom=="number"?x.zoom:typeof x.defaultZoom=="number"?x.defaultZoom:10,E=e.computed(()=>H("center")?n.center:C.center??n.center),$=e.computed(()=>H("zoom")?n.zoom:C.zoom??n.zoom),N=e.computed(()=>H("katottg")?String(n.katottg??""):String(C.katottg??n.katottg??"")),V=e.computed(()=>H("layers")?n.layers??[]:C.layers??n.layers??[]),M=e.computed(()=>H("bounds")?n.bounds:C.bounds??n.bounds),O=e.ref(Array.isArray(E.value)&&E.value.length===2?[...E.value]:W),B=e.ref(typeof $.value=="number"?$.value:T),K=e.ref(n.modelValue),I=e.ref(null),G=e.ref(null),L=e.ref([]),Z=e.ref(!1),oe=e.ref(!1),be=e.ref([]),pe=e.ref({coordinates:"",format:"decimal",order:"lat-lon"}),ee={coordinates:{type:"Textarea",label:"Координати вершин полігону (3-100 точок)",placeholder:`50.4501, 30.5234
1
+ (function(ye,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):(ye=typeof globalThis<"u"?globalThis:ye||self,e(ye.FormBuilder={},ye.Vue,ye.OpenGISCore,ye.lucide))})(this,function(ye,e,pe,q){"use strict";const Bo=e.defineComponent({__name:"vs-info-tooltip",props:{text:{}},setup(o){const t=o,n=e.ref(!1),r=e.ref({top:"0px",left:"0px"});function l(s){if(!t.text)return;const i=s.currentTarget.getBoundingClientRect();r.value={top:`${i.bottom+4}px`,left:`${Math.min(i.left,window.innerWidth-230)}px`},n.value=!0}function a(){n.value=!1}return(s,i)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("span",{class:"inline-flex items-center",onMouseenter:l,onMouseleave:a},[e.renderSlot(s.$slots,"default",{},()=>[e.createVNode(e.unref(q.Info),{class:"h-4 w-4 text-gray-400 cursor-help"})])],32),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.value&&s.text?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle(r.value),class:"fixed z-[9999] max-w-xs p-2 bg-gray-900 text-white text-xs rounded-lg shadow-lg pointer-events-none"},e.toDisplayString(s.text),5)):e.createCommentVNode("",!0)]))],64))}}),Qr={class:"w-full relative"},el={key:0,class:"text-[14px] font-medium text-gray-900 mb-2 flex items-center gap-1"},tl={class:"opacity-100"},nl={key:0,class:"text-red-500 text-[14px]"},ol={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},rl=e.defineComponent({__name:"vs-layout-default",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.computed(()=>typeof t.item?.label=="string"&&t.item.label?t.item.label:t.item?.ua||t.label||t.ua),r=e.computed(()=>!!n.value),l=e.computed(()=>!!t.item?.rules?.includes("required")),a=e.computed(()=>t.item?.info||"");return(s,i)=>(e.openBlock(),e.createElementBlock("div",Qr,[r.value?(e.openBlock(),e.createElementBlock("div",el,[e.createElementVNode("span",tl,e.toDisplayString(n.value),1),l.value?(e.openBlock(),e.createElementBlock("span",nl,"*")):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(Bo,{key:1,text:a.value},null,8,["text"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(s.$slots,"default",e.mergeProps(s.$attrs,{class:{"opacity-60":s.item.disabled}})),s.error?(e.openBlock(),e.createElementBlock("span",ol,e.toDisplayString(s.error),1)):e.createCommentVNode("",!0)]))}}),ll={class:"w-full relative flex flex-row items-center gap-2"},al={key:0,class:"text-red-500 text-[14px]"},sl={key:1,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},il=e.defineComponent({__name:"vs-layout-horizontal",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{default:()=>({container:12,label:3})}},setup(o){const t=o,n=e.computed(()=>t.item?.label||t.label||t.ua),r=e.computed(()=>t.item?.info||""),l=e.computed(()=>t.columns??{container:12,label:3}),a=e.computed(()=>{const{container:d,label:u}=l.value;return!d||d<=0?0:Math.min(Math.max(u??0,0),d)/d}),s=e.computed(()=>t.item?.type==="html"||a.value<=0?!1:!!n.value),i=e.computed(()=>{if(!s.value)return{};const d=`${a.value*100}%`;return{flexBasis:d,maxWidth:d}}),c=e.computed(()=>{const{container:d,label:u}=l.value;if(!d||d<=0)return{};if(t.item?.type==="html")return{flexBasis:"100%",maxWidth:"100%"};if(!s.value)return{flexBasis:"100%",maxWidth:"100%"};const p=Math.max(d-Math.max(u??0,0),0)/d;if(!p)return{};const y=`${p*100}%`;return{flexBasis:y,maxWidth:y}});return(d,u)=>(e.openBlock(),e.createElementBlock("div",ll,[s.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"text-sm text-gray-900 font-medium flex shrink-0 items-center gap-1",style:e.normalizeStyle(i.value)},[e.createTextVNode(e.toDisplayString(n.value)+" ",1),d.item?.rules?.includes("required")&&n.value?(e.openBlock(),e.createElementBlock("span",al,"*")):e.createCommentVNode("",!0),r.value?(e.openBlock(),e.createBlock(Bo,{key:1,text:r.value},null,8,["text"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"flex-1 min-w-0",style:e.normalizeStyle(c.value)},[e.renderSlot(d.$slots,"default",e.normalizeProps(e.guardReactiveProps(d.$attrs)))],4),d.error?(e.openBlock(),e.createElementBlock("span",sl,e.toDisplayString(d.error),1)):e.createCommentVNode("",!0)]))}}),cl={class:"w-full relative"},dl={key:0,class:"text-red-500 text-[10px] absolute bottom-[-14px]"},ul=e.defineComponent({__name:"vs-layout-inline",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",cl,[e.renderSlot(t.$slots,"default",e.normalizeProps(e.guardReactiveProps(t.$attrs))),t.error?(e.openBlock(),e.createElementBlock("span",dl,e.toDisplayString(t.error),1)):e.createCommentVNode("",!0)]))}}),pl={class:"flex-1 min-w-0"},fl={key:0,class:"text-sm font-medium text-slate-700 dark:text-slate-200 flex items-center gap-1"},ml={class:"truncate"},hl={key:0,class:"text-red-500 text-[14px]"},gl=["innerHTML"],yl={key:0,class:"mt-1 text-xs text-red-500"},bl={default:rl,horizontal:il,inline:ul,settings:e.defineComponent({__name:"vs-layout-settings",props:{ua:{default:""},uk:{},en:{},de:{},es:{},fr:{},item:{default:()=>({})},error:{type:[String,Boolean],default:""},label:{default:""},columns:{}},setup(o){const t=o,n=e.ref("uk");e.computed(()=>(t.item??{})?.[n.value]??t.ua??t.label??"");const r=e.computed(()=>t.item?.description??""),l=e.computed(()=>Array.isArray(t.item?.rules)&&t.item.rules.includes("required")),a=e.computed(()=>(typeof t.error=="string"?t.error:"")??""),s=()=>{const i=typeof localStorage<"u"?localStorage.getItem("locale"):null;n.value=i||"uk"};return e.onMounted(()=>{try{typeof localStorage<"u"&&localStorage.locale&&(n.value=localStorage.locale)}catch{}window.addEventListener("storage",s)}),e.onUnmounted(()=>{window.removeEventListener("storage",s)}),(i,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["w-full relative",{"opacity-60":i.item?.disabled}])},[e.createElementVNode("div",{class:e.normalizeClass(["gap-2 md:flex-row md:items-center md:justify-between",[["switcher","native-select"].includes(i.item.type)?"flex flex-col":""]])},[e.createElementVNode("div",pl,[i.ua||i.label?(e.openBlock(),e.createElementBlock("p",fl,[e.createElementVNode("span",ml,e.toDisplayString(i.item[n.value]||i.ua||i.label),1),l.value?(e.openBlock(),e.createElementBlock("span",hl,"*")):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,gl)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["w-full",["select","native-select"].includes(i.item.type)?"md:w-[30%]":"md:w-auto"])},[e.renderSlot(i.$slots,"default",e.normalizeProps(e.guardReactiveProps(i.$attrs)))],2)],2),a.value?(e.openBlock(),e.createElementBlock("p",yl,e.toDisplayString(a.value),1)):e.createCommentVNode("",!0)],2))}})};function Ue(o){return{inputClass:e.computed(()=>{const n=`disabled:opacity-50 disabled:cursor-not-allowed outline-none focus:ring-2 focus:ring-ring focus:ring-${o?.primaryColor||"blue"}-500 border border-solid border-stone-200 rounded-md text-sm text-stone-800 placeholder:text-stone-400 `;return o?.size==="sm"?`${n}h-[32px]`:`${n}h-[38px]`})}}const kl=["placeholder","disabled"],xl=e.defineComponent({__name:"vs-input-password",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Ue(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");return(s,i)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"password","onUpdate:modelValue":i[0]||(i[0]=c=>r.value=c),placeholder:a.value,disabled:l.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":s.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,kl)),[[e.vModelText,r.value]])}}),wl=["placeholder","disabled","maxlength","minlength"],zt=e.defineComponent({__name:"vs-input-text",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Ue(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??""),s=e.computed(()=>t.maxlength??void 0),i=e.computed(()=>t.minlength??void 0);function c(){typeof r.value=="string"&&(r.value=r.value.trim())}return(d,u)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"text","onUpdate:modelValue":u[0]||(u[0]=p=>r.value=p),placeholder:a.value,disabled:l.value,maxlength:s.value,minlength:i.value,onBlur:c,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[d.customClass,e.unref(n),{"!border-red-600":d.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,wl)),[[e.vModelText,r.value]])}}),_l=["step","placeholder","disabled","min","max"],Vo=e.defineComponent({__name:"vs-input-number",props:e.mergeModels({style:{type:Object,default:()=>({})},placeholder:{type:String,default:""},disabled:{type:Boolean,default:!1},min:{type:Number,default:void 0},max:{type:Number,default:void 0},step:{type:[Number,String],default:void 0}},{modelValue:{default:null},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Ue(t.style),r=e.useAttrs(),l=e.useModel(o,"modelValue"),a=e.computed(()=>!!t.disabled),s=u=>{if(u==null||u==="")return;const p=typeof u=="string"?u.trim().replace(",","."):u,y=Number(p);return Number.isFinite(y)?y:void 0},i=e.computed(()=>s(t.min??r.min)),c=e.computed(()=>s(t.max??r.max)),d=e.computed(()=>{if(t.step!==void 0&&t.step!==null&&t.step!=="")return t.step;const u=r.step;return typeof u=="number"||typeof u=="string"?u:"any"});return(u,p)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:"number",step:d.value,"onUpdate:modelValue":p[0]||(p[0]=y=>l.value=y),placeholder:o.placeholder,disabled:a.value,class:e.normalizeClass(["py-1.5 px-3 block w-full bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"},min:i.value,max:c.value},null,10,_l)),[[e.vModelText,l.value]])}}),fn=o=>!!String(o??"").trim(),Bt=o=>o?.color?String(o.color):"",Kt=o=>{const t=o?.icon;if(typeof t=="string")return t;const n=o?.imgUrl;return typeof n=="string"?n:""},Wt=o=>{const t=o?.icon;return t&&typeof t!="string"?t:null},Cl={class:"flex items-center gap-[4px]"},vl=["value","id","disabled"],El=["for"],Bl=["innerHTML"],Vl={key:1,class:"text-[14px] text-gray-700 flex items-center gap-2 dark:text-neutral-400"},Sl=["src"],$l=e.defineComponent({__name:"vs-checkbox-default",props:{value:{default:""},label:{default:""},html:{default:""},disabled:{type:Boolean,default:!1},id:{},modelValue:{default:""},info:{},error:{},option:{default:null}},emits:["update:modelValue"],setup(o,{emit:t}){const n=t,r=o,l=e.computed({get:()=>r.modelValue,set:k=>n("update:modelValue",k)}),a=e.computed(()=>!!r.disabled),s=e.computed(()=>Kt(r.option)),i=e.computed(()=>Wt(r.option)),c=e.computed(()=>Bt(r.option)),d=e.computed(()=>!!(c.value&&!s.value&&!i.value)),u=e.computed(()=>!!(s.value&&c.value)),p=e.computed(()=>c.value?{color:c.value}:void 0),y=e.computed(()=>{if(!(!s.value||!c.value))return{backgroundColor:c.value,WebkitMaskImage:`url(${s.value})`,maskImage:`url(${s.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(k,m)=>(e.openBlock(),e.createElementBlock("div",Cl,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",value:k.value,"onUpdate:modelValue":m[0]||(m[0]=h=>l.value=h),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:k.id,disabled:a.value},null,10,vl),[[e.vModelCheckbox,l.value]]),e.createElementVNode("label",{for:k.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",k.error?"border-red-600":""]])},[e.createVNode(e.unref(q.Check),{class:"h-4 w-4"})],2),k.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:k.html},null,8,Bl)):(e.openBlock(),e.createElementBlock("span",Vl,[d.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:c.value})},null,4)):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(y.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,Sl)):i.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.value),{key:3,class:"h-4 w-4",style:e.normalizeStyle(p.value)},null,8,["style"])):e.createCommentVNode("",!0),e.renderSlot(k.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(k.label),1)])]))],10,El)]))}}),Nl=["name","value","disabled"],Al=["innerHTML"],Fl={key:1,class:"flex items-center gap-[6px] text-[14px]"},Ml={key:2,class:"text-[16px] inline-flex items-center justify-center"},Dl=["src"],Tl=e.defineComponent({__name:"vs-checkbox-buttons",props:{value:{type:[String,Number,Boolean],default:""},label:{default:""},html:{default:""},modelValue:{default:""},disabled:{type:Boolean},id:{},icon:{},imgUrl:{},style:{},option:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=e.computed({get:()=>n.modelValue,set:h=>{r("update:modelValue",h)}}),a=e.computed(()=>Array.isArray(l.value)?l.value.includes(n.value):l.value===!0||l.value===n.value),s=e.computed(()=>n.style?.size==="xs"?"p-1.5 text-xs":n.style?.size==="lg"?"p-3.5 text-[20px]":"p-2.5 text-xs"),i=e.computed(()=>({...n.option??{},icon:n.option?.icon??n.icon,imgUrl:n.option?.imgUrl??n.imgUrl,color:n.option?.color})),c=e.computed(()=>Kt(i.value)),d=e.computed(()=>Wt(i.value)),u=e.computed(()=>Bt(i.value)),p=e.computed(()=>!!(u.value&&!c.value&&!d.value)),y=e.computed(()=>!!(c.value&&u.value)),k=e.computed(()=>u.value?{color:u.value}:void 0),m=e.computed(()=>{if(!(!c.value||!u.value))return{backgroundColor:u.value,WebkitMaskImage:`url(${c.value})`,maskImage:`url(${c.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(h,b)=>(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:h.id,value:h.value,"onUpdate:modelValue":b[0]||(b[0]=_=>l.value=_),disabled:h.disabled},null,8,Nl),[[e.vModelCheckbox,l.value]]),h.html?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-full",innerHTML:h.html},null,8,Al)):(e.openBlock(),e.createElementBlock("span",Fl,[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),y.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(m.value)},null,4)):c.value||d.value?(e.openBlock(),e.createElementBlock("span",Ml,[c.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:c.value,width:"16",height:"16",alt:"icon"},null,8,Dl)):d.value?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),{key:1,class:"h-4 w-4",style:e.normalizeStyle(k.value)},null,8,["style"])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.renderSlot(h.$slots,"default",{},()=>[e.createTextVNode(e.toDisplayString(h.label),1)])]))],2))}}),Ll={class:"flex items-center"},Kn=e.defineComponent({__name:"vs-input-checkbox-item",props:{value:{default:""},label:{default:""},labelHtml:{default:""},disabled:{type:Boolean,default:!1},view:{default:"default"},modelValue:{type:[Boolean,Array],default:!1},icon:{},imgUrl:{},slots:{},option:{},style:{},error:{default:""}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=`radio-${Math.floor(Math.random()*1e4)}`,a=e.computed({get:()=>Array.isArray(n.modelValue)?Array.isArray(n.modelValue)&&n.modelValue.includes(n.value):n.modelValue,set:i=>{if(Array.isArray(n.modelValue)){let c=[...n.modelValue];i?c.includes(n.value)||c.push(n.value):c=c.filter(d=>d!==n.value),r("update:modelValue",c)}else r("update:modelValue",i)}}),s=e.ref(`vs-checkbox-${n.view||"default"}`);return(i,c)=>(e.openBlock(),e.createElementBlock("div",Ll,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(s.value==="vs-checkbox-buttons"?e.unref(Tl):e.unref($l)),{value:i.value,label:i.label,html:i.labelHtml,info:i.option?.info,disabled:i.disabled,modelValue:a.value,"onUpdate:modelValue":c[0]||(c[0]=d=>a.value=d),id:l,icon:i.icon,imgUrl:i.imgUrl,option:i.option,style:e.normalizeStyle(i.style),error:i.error},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(i.label),1)]),_:1},8,["value","label","html","info","disabled","modelValue","icon","imgUrl","option","style","error"]))]))}}),Il={key:0,class:"flex items-start gap-x-1"},Rl={key:0,class:"text-red-500 text-[14px]"},Ol=["title"],Pl=["disabled"],Wn=e.defineComponent({__name:"vs-input-switcher",props:e.mergeModels({rules:{default:()=>[]},view:{default:"checkbox"},label:{default:""},i:{default:""},text:{default:""},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{type:Boolean,default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue");return(r,l)=>t.view==="checkbox"?(e.openBlock(),e.createElementBlock("div",Il,[e.createVNode(Kn,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),error:r.error||""},null,8,["modelValue","error"]),r.rules?.includes("required")?(e.openBlock(),e.createElementBlock("span",Rl,"*")):e.createCommentVNode("",!0),r.i?(e.openBlock(),e.createElementBlock("button",{key:1,class:"cursor-pointer",title:r.i,onClick:l[1]||(l[1]=e.withModifiers(()=>{},["prevent"]))},[e.createVNode(e.unref(q.Info),{class:"h-4 w-4 text-gray-500"})],8,Ol)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:e.normalizeClass(["inline-flex h-5 w-9 shrink-0 px-[2px] cursor-pointer items-center rounded-full shadow-sm disabled:cursor-not-allowed disabled:opacity-50",[n.value?`bg-${r.style?.primaryColor||"blue"}-500`:"bg-stone-200",r.customClass]]),disabled:r.disabled,onClick:l[2]||(l[2]=a=>n.value=!n.value)},[e.createElementVNode("span",{"data-state":"checked",class:e.normalizeClass(["pointer-events-none block h-4 w-4 rounded-full bg-white shadow-lg ring-0 transition-transform",[n.value?"translate-x-4":"translate-x-0"]])},null,2)],10,Pl))}}),zl=["id","innerHTML"],Gn=e.defineComponent({__name:"vs-input-static",props:{text:{default:""},html:{default:""},style:{},customClass:{default:""},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",{id:t.name,class:e.normalizeClass(["text-gray-900",t.customClass]),innerHTML:t.html?t.html:t.text},null,10,zl))}}),jl=["placeholder","disabled","name"],mn=e.defineComponent({__name:"vs-input-mask",props:e.mergeModels({name:{},mask:{default:""},unmask:{type:Boolean,default:!1},placeholder:{default:"_"},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Ue(t.style),r=e.useModel(o,"modelValue"),l=e.ref(null);let a=null;function s(i){const c={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},d=new Set;let u=!1;for(let y=0;y<i.length;y+=1){const k=i[y];k==="{"?u=!0:k==="}"?u=!1:u&&d.add(k)}const p={};return Object.keys(c).forEach(y=>{d.has(y)||(p[y]=c[y])}),{mask:i,definitions:p,lazy:!1}}return e.onMounted(async()=>{if(l.value){const{default:i}=await Promise.resolve().then(()=>Pn),c=s(t.mask||"");a=i(l.value,c),a.on("accept",()=>{r.value=t.unmask?a.unmaskedValue:a.value}),a.on("complete",()=>{r.value=t.unmask?a.unmaskedValue:a.value}),a.value=r.value!=null?String(r.value):""}}),e.onBeforeUnmount(()=>{a?.destroy()}),e.watch(()=>t.mask,i=>{if(a){const c=s(i||"");a.updateOptions(c)}}),e.watch(r,i=>{a&&a.unmaskedValue!==i&&(a.value=i!=null?String(i):"")}),(i,c)=>(e.openBlock(),e.createElementBlock("input",{type:"text",ref_key:"inputEl",ref:l,placeholder:i.placeholder,disabled:i.disabled,name:i.name,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,10,jl))}}),Ul={class:"relative w-full bg-white rounded-lg"},Hl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},ql=["placeholder","disabled"],Yn=e.defineComponent({__name:"vs-input-email",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:null},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Ue(t.style),r=e.useModel(o,"modelValue");return(l,a)=>(e.openBlock(),e.createElementBlock("div",Ul,[e.createElementVNode("div",Hl,[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:l.placeholder,disabled:l.disabled,class:e.normalizeClass(["!pl-8 py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(n),{"!border-red-600":l.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,ql),[[e.vModelText,r.value]])]))}}),xt="+99(999)-999-99-99";function Vt(o){if(!o?.trim())return 0;const t=new Set(["9","0","a","A","*"]);let n=!1,r=0;for(let l=0;l<o.length;l+=1){const a=o[l];if(a==="{"){n=!0;continue}if(a==="}"){n=!1;continue}!n&&t.has(a)&&(r+=1)}return r}const Kl={class:"relative w-full bg-white rounded-lg"},Wl={class:"absolute bottom-2/4 translate-y-2/4 left-[10px] pointer-events-none"},Gl=["name","placeholder","disabled","pattern"],Xn=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:xt}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.computed(()=>`^\\+[1-9]\\d{${(Vt(t.mask||xt)||Vt(xt))-1}}$`),{inputClass:r}=Ue(t.style),l=e.useModel(o,"modelValue"),a=e.ref(null);let s=null;function i(u){const p={9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},y=new Set;let k=!1;for(let h=0;h<u.length;h+=1){const b=u[h];b==="{"?k=!0:b==="}"?k=!1:k&&y.add(b)}const m={};return Object.keys(p).forEach(h=>{y.has(h)||(m[h]=p[h])}),{mask:u,definitions:m,lazy:!1,disabled:t.disabled}}function c(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=i(t.mask||"");s=u(a.value,p),s.on("accept",d),s.on("complete",d);const y=c(l.value);s.unmaskedValue=y}),e.onBeforeUnmount(()=>{s?.destroy(),s=null}),e.watch(()=>t.mask,u=>{s&&s.updateOptions(i(u||""))}),e.watch(()=>t.disabled,u=>{s&&s.updateOptions({disabled:u})}),e.watch(l,u=>{if(!s)return;const p=c(u);s.unmaskedValue!==p&&(s.unmaskedValue=p)}),(u,p)=>(e.openBlock(),e.createElementBlock("div",Kl,[e.createElementVNode("div",Wl,[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:u.name,placeholder:u.placeholder,disabled:u.disabled,pattern:n.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":u.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,Gl)]))}}),Yl=["value","disabled"],Xl=["innerHTML"],Zl={key:1,class:"flex items-center gap-2"},Jl=["src"],Ql={class:"text-[13px] text-gray-700"},ea=e.defineComponent({__name:"vs-input-radio-default",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Kt(t.option)),a=e.computed(()=>Wt(t.option)),s=e.computed(()=>Bt(t.option)),i=e.computed(()=>!!(s.value&&!l.value&&!a.value)),c=e.computed(()=>!!(l.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),u=e.computed(()=>{if(!(!l.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${l.value})`,maskImage:`url(${l.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(p,y)=>(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":y[0]||(y[0]=k=>n.value=k),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,Yl),[[e.vModelRadio,n.value]]),e.createElementVNode("span",{class:e.normalizeClass(["w-[16px] shrink-0 h-[16px] border rounded-full flex items-center justify-center mr-[10px]",[`border-${t.style?.primaryColor||"blue"}-500`,r.value?"opacity-50 cursor-not-allowed":""]])},[n.value==t.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["w-[12px] h-[12px] shrink-0 rounded-full",[`bg-${t.style?.primaryColor||"blue"}-500`]])},null,2)):e.createCommentVNode("",!0)],2),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,Xl)):(e.openBlock(),e.createElementBlock("div",Zl,[i.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(u.value)},null,4)):l.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:l.value,alt:"icon"},null,8,Jl)):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",Ql,e.toDisplayString(t.text),1)]))],2))}}),ta=["value","disabled"],na=["innerHTML"],oa={key:1,class:"flex items-center gap-2"},ra=["src"],la={class:"text-[13px] text-gray-700"},aa={"vs-input-radio-default":ea,"vs-input-radio-buttons":e.defineComponent({__name:"vs-input-radio-buttons",props:e.mergeModels({style:{},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{},value:{},text:{},html:{default:""},option:{default:null}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>!!t.disabled),l=e.computed(()=>Kt(t.option)),a=e.computed(()=>Wt(t.option)),s=e.computed(()=>Bt(t.option)),i=e.computed(()=>!!(s.value&&!l.value&&!a.value)),c=e.computed(()=>!!(l.value&&s.value)),d=e.computed(()=>s.value?{color:s.value}:void 0),u=e.computed(()=>{if(!(!l.value||!s.value))return{backgroundColor:s.value,WebkitMaskImage:`url(${l.value})`,maskImage:`url(${l.value})`,WebkitMaskRepeat:"no-repeat",maskRepeat:"no-repeat",WebkitMaskSize:"contain",maskSize:"contain",WebkitMaskPosition:"center",maskPosition:"center"}});return(p,y)=>(e.openBlock(),e.createElementBlock("label",{class:e.normalizeClass(["flex h-full w-full items-center border rounded-lg px-2 py-1",[n.value==t.value?`ring-2 ring-ring ring-${t.style?.primaryColor||"blue"}-500`:"",t.customClass,r.value?"cursor-not-allowed opacity-60":""]])},[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":y[0]||(y[0]=k=>n.value=k),type:"radio",value:t.value,disabled:r.value,class:"hidden"},null,8,ta),[[e.vModelRadio,n.value]]),t.html?(e.openBlock(),e.createElementBlock("div",{key:0,class:"w-full",innerHTML:t.html},null,8,na)):(e.openBlock(),e.createElementBlock("div",oa,[i.value?(e.openBlock(),e.createElementBlock("span",{key:0,class:"inline-flex h-3 w-3 rounded-full border border-gray-200",style:e.normalizeStyle({background:s.value})},null,4)):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",{key:1,class:"inline-block h-4 w-4",style:e.normalizeStyle(u.value)},null,4)):l.value?(e.openBlock(),e.createElementBlock("img",{key:2,class:"block",height:"16",width:"16",src:l.value,alt:"icon"},null,8,ra)):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",la,e.toDisplayString(t.text),1)]))],2))}})},So=o=>Array.isArray(o)?o:Array.isArray(o?.data)?o.data:[],$o=o=>{const t=o.host??"",n=o.prefix??"api",r=o.api??`/${n}/suggest/${o.data}`;return`${t}${r}`},sa=o=>({fetchOptions:async(r="")=>{const l=o();if(!l.data)return l.options?[...l.options]:[];try{const a=new URLSearchParams;a.set("json","1"),r&&a.set("key",r),l.parentValue!==void 0&&l.parentValue!==null&&l.parentValue!==""&&a.set("parent",String(l.parentValue)),l.start===1&&a.set("start","1");const i=await(await fetch(`${$o(l)}?${a.toString()}`)).json();return So(i)}catch{return[]}},fetchOptionByValue:async r=>{if(r==null||r==="")return null;const l=o();if(!l.data)return(l.options??[]).find(s=>s?.id?.toString()===String(r))??null;try{const a=new URLSearchParams;a.set("json","1"),a.set("val",String(r)),l.parentValue!==void 0&&l.parentValue!==null&&l.parentValue!==""&&a.set("parent",String(l.parentValue)),l.start===1&&a.set("start","1");const i=await(await fetch(`${$o(l)}?${a.toString()}`)).json();return So(i)[0]??null}catch{return null}}}),hn=({props:o,formValues:t=null,watchParent:n=!0})=>{const r=e.ref([]),l=e.computed(()=>o.parent?t?.value?.[o.parent]?.toString?.()??null:null),{fetchOptions:a,fetchOptionByValue:s}=sa(()=>({data:o.data,options:o.options,api:o.api,prefix:o.prefix,host:o.host,start:o.start,parentValue:l.value})),i=async(c="")=>{const d=o.data?await a(c):o.options?[...o.options]:[];return r.value=d,r.value};return e.watch(()=>o.options,()=>{o.data||(r.value=o.options?[...o.options]:[])},{immediate:!0,deep:!0}),n&&e.watch(l,async()=>{o.data&&(r.value=await a())},{immediate:!1}),{optionsList:r,parentValue:l,fetchOptions:a,fetchOptionByValue:s,loadOptions:i}},ia=/\{\{\s*([^}]+?)\s*\}\}/g,ca=o=>(o?String(o):"").replace(/<[^>]*>/g,"").trim(),da=(o,t)=>t.split(".").reduce((n,r)=>n==null?n:n[r.trim()],o),gn=(o,t)=>{if(!o)return"";const n=(t??"").trim();return n?n.replace(ia,(r,l)=>{const a=String(l).trim(),s=o,c=(a.includes(".")?da(s,a):void 0)??s[a];return c!=null?String(c):""}):o.text??""},yn=(o,t)=>{if(!o)return"";const n=gn(o,t);return ca(n)||o.text||""},Zn=e.defineComponent({__name:"vs-input-radio",props:e.mergeModels({options:{},slot:{},data:{},api:{},prefix:{},host:{},start:{},parent:{},position:{default:"vertical"},view:{default:"default"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>aa[`vs-input-radio-${t.view}`]),l=e.computed(()=>t.slot??t?.optionTemplate??""),a=e.computed(()=>fn(l.value)),s=k=>gn(k,l.value),i=k=>yn(k,l.value),c=e.computed(()=>t.position==="horizontal"?"flex w-full flex-row flex-wrap gap-[10px]":"flex w-full flex-col gap-2"),d=e.computed(()=>{if(t.position==="horizontal"&&t.customClass?.includes("50%"))return{flex:"0 0 calc(50% - 5px)"}}),u=e.inject("values",null),{optionsList:p,loadOptions:y}=hn({props:t,formValues:u});return e.onMounted(async()=>{await y()}),(k,m)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(c.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(p),h=>(e.openBlock(),e.createElementBlock("div",{key:h?.id,class:e.normalizeClass(["flex items-stretch",k.position==="horizontal"?t.customClass:""]),style:e.normalizeStyle(d.value)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(r.value),e.mergeProps({text:i(h),html:a.value?s(h):"",option:h,value:h.id.toString(),checked:n.value?.toString?.()===h.id?.toString?.(),"custom-class":k.position==="horizontal"?"":t.customClass,modelValue:n.value,"onUpdate:modelValue":m[0]||(m[0]=b=>n.value=b)},{ref_for:!0},k.$attrs),null,16,["text","html","option","value","checked","custom-class","modelValue"]))],6))),128))],2))}}),ua={key:1,class:"w-full flex flex-col gap-4"},pa={key:0,class:"text-sm font-medium text-muted-foreground my-2"},fa="Без категорії",ma=e.defineComponent({__name:"vs-input-checkbox",props:{options:{default:()=>[]},position:{default:"vertical"},slots:{default:null},slot:{},colSpan:{default:0},data:{},api:{},prefix:{},host:{},start:{},parent:{},view:{},group:{default:void 0},values:{default:()=>[]},style:{},customClass:{},disabled:{type:Boolean},modelValue:{default:!1},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,l=e.reactive({}),a=e.inject("values",null),{optionsList:s,loadOptions:i}=hn({props:{...n,options:n.options},formValues:a}),c=e.computed(()=>s.value),d=x=>x?.value||x?.id||x?.text||x,u=e.computed(()=>n.slot??n?.optionTemplate??""),p=e.computed(()=>fn(u.value)),y=x=>gn(x,u.value),k=x=>yn(x,u.value),m=x=>`lg:col-span-${x||12}`,h=e.computed(()=>[n.position==="vertical"?"flex flex-col":"",n.colSpan?"grid":"flex justify-start"]),b=x=>x==null||x===""?null:typeof x=="string"||typeof x=="number"?x:String(x),_=e.computed(()=>{if(!n.group)return[];const x=new Map;c.value.forEach(L=>{const B=L[n.group],S=b(B);x.has(S)||x.set(S,[]),x.get(S)?.push(L)});const v=[];n.values?.length&&n.values.forEach(L=>{const B=b(L);v.push(B)});const N=new Set,U=L=>{const B=x.get(L)||[];if(!B.length)return null;const S=L===null?"group-null":`group-${String(L)}`,$=L===null?fa:String(L);return N.add(L),{key:S,label:$,options:B}},W=[];return v.forEach(L=>{const B=U(L);B&&W.push(B)}),x.forEach((L,B)=>{if(N.has(B))return;const S=U(B);S&&W.push(S)}),W});return e.watch(()=>n.modelValue,x=>{if(typeof x=="boolean"&&c.value.length===1){const v=d(c.value[0]);l[v]=x}else if(Array.isArray(x)){const v=new Set(x);c.value.forEach(N=>{if(!N.disabled){const U=d(N);l[U]=v.has(U)}})}},{immediate:!0}),e.watch(l,()=>{if(!c.value.length){r("update:modelValue",null);return}const x=Object.entries(l).filter(([,v])=>v).map(([v])=>v);r("update:modelValue",x.length===0?[]:x)},{deep:!0}),e.onMounted(async()=>{if(await i(),typeof n.modelValue=="boolean"&&c.value.length===1){const x=d(c.value[0]);l[x]=n.modelValue}else if(Array.isArray(n.modelValue)){const x=new Set(n.modelValue);c.value.forEach(v=>{if(!v.disabled){const N=d(v);l[N]=x.has(N)}})}}),(x,v)=>n.group?(e.openBlock(),e.createElementBlock("div",ua,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,N=>(e.openBlock(),e.createElementBlock("div",{key:N.key,class:"flex flex-col gap-2"},[N.label?(e.openBlock(),e.createElementBlock("span",pa,e.toDisplayString(N.label),1)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:e.normalizeClass(["p-0 w-full gap-[12px]",h.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.options,U=>(e.openBlock(),e.createBlock(Kn,{modelValue:l[d(U)],"onUpdate:modelValue":W=>l[d(U)]=W,value:d(U),class:e.normalizeClass(m(x.colSpan)),disabled:n.disabled||U.disabled,label:k(U),labelHtml:p.value?y(U):"",key:`${N.key}-${d(U)}`,icon:U?.icon,imgUrl:U?.imgUrl,option:U,view:x.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]",h.value])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,N=>(e.openBlock(),e.createBlock(Kn,{modelValue:l[d(N)],"onUpdate:modelValue":U=>l[d(N)]=U,value:d(N),class:e.normalizeClass(m(x.colSpan)),disabled:n.disabled||N.disabled,label:k(N),labelHtml:p.value?y(N):"",key:d(N),icon:N?.icon,imgUrl:N?.imgUrl,option:N,view:x.view},null,8,["modelValue","onUpdate:modelValue","value","class","disabled","label","labelHtml","icon","imgUrl","option","view"]))),128))],2))}}),xe=(o,t)=>{const n=o.__vccOpts||o;for(const[r,l]of t)n[r]=l;return n},No=xe(ma,[["__scopeId","data-v-9056e0ec"]]),ha=["type","placeholder","disabled"],ga=e.defineComponent({__name:"vs-input-date1",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},mode:{default:"date"}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o;function r(u){return u?n.mode==="datetime"?(u.includes("T")?u:null)||u+(u.includes(" ")?"":"T00:00"):u?.split(" ")[0]:null}const{inputClass:l}=Ue(n.style),a=t,s=e.computed({get:()=>r(n.modelValue),set:u=>a("update:modelValue",u)}),i=e.computed(()=>n.mode==="datetime"?"datetime-local":n.mode),c=e.computed(()=>!!n.disabled),d=e.computed(()=>n.placeholder??"");return(u,p)=>e.withDirectives((e.openBlock(),e.createElementBlock("input",{type:i.value,"onUpdate:modelValue":p[0]||(p[0]=y=>s.value=y),placeholder:d.value,disabled:c.value,ref:"date",class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[u.modelValue?"":"text-opacity-50",e.unref(l)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,ha)),[[e.vModelDynamic,s.value]])}}),ya=(o,t)=>{if(!t||!Object.keys(t).length)return o;const[n,r=""]=o.split("?"),l=new URLSearchParams(r);Object.entries(t).forEach(([s,i])=>{i==null||i===""||l.set(s,String(i))});const a=l.toString();return a?`${n}?${a}`:n},Ao=async(o,t={})=>{try{const n=new FormData;n.append("unique","true"),n.append("file",o);const{api:r,id:l="1",form:a="form",table:s="table",customParams:i}=t,c=r||`/file/upload/uploads?id=${l||""}&form=${a||""}&table=${s||""}`,d=ya(c,i);return(await fetch(d,{method:"POST",body:n}).then(p=>p.json()))?.result}catch(n){return pe.notify({type:"error",title:"Помилка!",message:"Сталась помилка під час завантаження файлу",position:"right-bottom"}),console.error("Сталась помилка завантаження файлу",n),null}},ba=async o=>{try{return await fetch(`file/delete${o}`),!0}catch(t){return console.error(t),!1}},Fo=async o=>{try{const t=await fetch(`/file/download${o}`);if(!t.ok)throw new Error(`Download failed with status ${t.status}`);const n=await t.blob(),l=(t.headers.get("content-disposition")||"").match(/filename\*?=(?:UTF-8''|")?([^\";]+)/i),a=l?.[1]?decodeURIComponent(l[1].replace(/"/g,"").trim()):"",s=o.split("/").filter(Boolean).pop()||"download",i=a||s,c=document.createElement("a");c.setAttribute("download",i),c.href=window.URL.createObjectURL(n),c.click(),window.URL.revokeObjectURL(c.href)}catch(t){console.error(t.message)}},ka=o=>{if(!o)return"";const t=o?.split(".");return t[t.length-1]},xa=o=>{const t=ka(o),n={imageFormat:["tiff","jpg","jpeg","png","svg","ico","webp"],sheetsFormat:["xls","csv","xlsx"],archivesFormat:["zip","rar"],textsFormat:["json","geojson","txt","yml","yaml","shp"],documentsFormat:["pdf"]};return n.imageFormat.includes(t)?"img":n.sheetsFormat.includes(t)?q.Table:n.textsFormat.includes(t)?q.FileCode:n.documentsFormat.includes(t)?q.FileText:n.archivesFormat.includes(t)?q.FileArchive:q.FileText},wa=["title"],_a={class:"absolute hidden top-0 right-0 flex items-center gap-x-2 w-full h-full justify-center"},Jn=xe(e.defineComponent({__name:"vs-input-file-list-item",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{value:{},valueModifiers:{},item:{},itemModifiers:{}}),emits:["update:value","update:item"],setup(o){const t=e.useModel(o,"value"),n=e.useModel(o,"item"),r=o,l=e.computed(()=>n.value?typeof n.value=="string"?n.value:n.value.file_path:""),a=c=>typeof c=="string"?c:c?.file_path||"",s=()=>{const c=l.value;ba(c),r.multiple&&Array.isArray(t.value)?t.value=t.value.filter(d=>a(d)!==c):t.value=""},i=()=>{l.value&&window.open(l.value,"_blank")};return(c,d)=>(e.openBlock(),e.createElementBlock("div",{title:l.value,class:"h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg overflow-hidden relative item-file"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(e.unref(xa)(l.value)),{src:l.value,alt:"file",class:"w-full h-full object-cover cursor-pointer",onClick:d[0]||(d[0]=u=>e.unref(Fo)(l.value))},null,8,["src"])),e.createElementVNode("div",_a,[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:i,class:"w-6 h-6 flex items-center justify-center text-gray-500 bg-gray-200 rounded-lg hover:text-emerald-600"},[e.createVNode(e.unref(q.Eye),{class:"w-4 h-4"})]),e.createElementVNode("button",{type:"button",onClick:d[1]||(d[1]=u=>e.unref(Fo)(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,wa))}}),[["__scopeId","data-v-89357cbb"]]),Ca={class:"flex items-center gap-x-2"},va=["accept","multiple","disabled"],Ea={key:1,class:"flex items-center flex-wrap gap-2"},Ba={key:1,class:"loader"},Va={key:1,class:"loader"},Mo=xe(e.defineComponent({__name:"vs-input-file",props:e.mergeModels({format:{},multiple:{type:Boolean},max_size:{},api:{},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["change"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),l=t,a=e.computed(()=>{const x=r.value;return!n.multiple||!Array.isArray(x)?[]:x}),s=e.ref(null),i=e.ref(!1),c=e.inject("values"),d=e.computed(()=>n.format?n.format.split(",").map(x=>x.trim().toLowerCase()).filter(Boolean):[]),u=x=>{if(n.max_size&&x.size>n.max_size*1024*1024){const v=(x.size/1048576).toFixed(2);return pe.notify({type:"error",title:"Помилка!",message:`Файл "${x.name}" занадто великий. Максимальний розмір: ${n.max_size} МБ, розмір файлу: ${v} МБ`,position:"right-bottom"}),!1}return!0},p=x=>{if(!d.value.length)return!0;const v=`.${x.name.split(".").pop()?.toLowerCase()||""}`,N=d.value.includes(v);return N||pe.notify({type:"error",title:"Помилка!",message:`Неприпустимий формат файлу "${x.name}". Дозволені формати: ${d.value.join(", ")}`,position:"right-bottom"}),N},y=e.computed(()=>{const x={},v=[];if(!n.customParams?.length)return{params:x,missingSources:v};const N=c?.value??{};return n.customParams.forEach(U=>{if(!U)return;const[W,L]=U.split("="),B=W?.trim(),S=L?.trim();if(!B||!S)return;const $=N[S];if($==null||$===""){v.push(S);return}x[B]=$}),{params:x,missingSources:v}}),k=()=>{const{params:x}=y.value;return{api:n.api,customParams:Object.keys(x).length?x:void 0}},m=()=>{const x=y.value.missingSources;if(!x.length)return!0;const v=x.join(", ");return pe.notify({type:"warning",title:"Заповніть поля",message:`Поля (${v}) необхідні для завантаження файлу`,position:"right-bottom"}),!1},h=x=>{pe.notify({type:"error",title:"Помилка завантаження",message:x||"Не вдалося завантажити файл. Спробуйте ще раз.",position:"right-bottom"})},b=()=>{n.disabled||i.value||m()&&s.value?.click()},_=async x=>{const{files:v}=x.target;if(!v||v.length===0)return;if(!m()){s.value&&(s.value.value="");return}const N=Array.from(v);if(n.max_size&&N.filter(L=>!u(L)).length>0){s.value&&(s.value.value="");return}if(N.filter(W=>!p(W)).length>0){s.value&&(s.value.value="");return}i.value=!0;try{if(n.multiple){const W=Array.from(v).map(async V=>await Ao(V,k())),L=await Promise.all(W),B=L.filter(V=>V?.file_path);if(B.length===0){h();return}B.length<L.length&&h("Деякі файли не вдалося завантажити. Перевірте їх та спробуйте знову.");const S=B.map(V=>V.file_path),$=Array.isArray(r.value)?r.value:[];r.value=[...$,...S],l("change",r.value)}else{const W=v[0],L=await Ao(W,k());if(!L?.file_path){h();return}const B=L.file_path;r.value=B,l("change",B)}}catch(W){const L=W?.message||void 0;h(L)}finally{i.value=!1,s.value&&(s.value.value="")}};return(x,v)=>(e.openBlock(),e.createElementBlock("div",Ca,[e.createElementVNode("input",{class:"hidden",ref_key:"fileInput",ref:s,type:"file",accept:n.format,multiple:x.multiple,onChange:_,disabled:i.value||x.disabled},null,40,va),!x.multiple&&r.value&&!Array.isArray(r.value)?(e.openBlock(),e.createBlock(Jn,{key:0,item:r.value,value:r.value,"onUpdate:value":v[0]||(v[0]=N=>r.value=N)},null,8,["item","value"])):x.multiple?(e.openBlock(),e.createElementBlock("div",Ea,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(N,U)=>(e.openBlock(),e.createBlock(Jn,{multiple:x.multiple,key:U,value:r.value,"onUpdate:value":v[1]||(v[1]=W=>r.value=W),item:N},null,8,["multiple","value","item"]))),128)),e.createElementVNode("div",{onClick:b,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",x.disabled||i.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500 hover:bg-blue-50"])},[i.value?(e.openBlock(),e.createElementBlock("div",Ba)):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:0,class:"h-4 w-4"}))],2)])):e.createCommentVNode("",!0),x.multiple?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:2,onClick:b,class:e.normalizeClass([x.disabled||i.value?"opacity-50 cursor-not-allowed":"cursor-pointer hover:border-blue-500","relative h-[120px] w-[120px] border text-gray-300 hover:text-blue-500 border-dashed border-gray-300 rounded-lg flex items-center justify-center cursor-pointer hover:border-blue-500 transition-all duration-300 hover:bg-blue-50"])},[i.value?(e.openBlock(),e.createElementBlock("div",Va)):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:0,class:"h-4 w-4"}))],2))]))}}),[["__scopeId","data-v-dda91e05"]]),Sa={class:"vs-input-file2 flex flex-col gap-4"},$a={class:"flex items-center gap-x-2"},Na=["accept","disabled"],Aa={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"},Fa={key:0,class:"rounded-lg border border-[#CFD9E0] bg-white p-4 shadow-sm"},Ma={class:"flex items-center justify-between text-sm"},Da={class:"truncate pr-4"},Ta={class:"font-medium text-slate-800 truncate"},La={class:"text-slate-500"},Ia={class:"text-slate-500 whitespace-nowrap"},Ra={class:"mt-3 h-2 rounded-full bg-slate-100 overflow-hidden"},Oa={class:"mt-3 flex flex-wrap gap-2 text-sm"},Pa={key:0,class:"mt-2 text-sm text-rose-600"},za=e.defineComponent({__name:"vs-input-file2",props:e.mergeModels({format:{},max_size:{},api:{},chunkSize:{default:5*1024*1024},subdir:{default:""},customParams:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(null),l=e.ref(null),a=e.ref(""),s=e.ref(0),i=e.ref(!1),c=e.ref(""),d=e.ref(null),u=e.inject("values"),p=e.computed(()=>t.format?t.format.split(",").map(M=>M.trim().toLowerCase()).filter(Boolean):[]),y=e.computed(()=>!l.value||!l.value.size?0:Math.min(100,Math.round(s.value/l.value.size*100))),k=e.computed(()=>l.value?`${b(s.value)} / ${b(l.value.size)}`:""),m=e.computed(()=>t.disabled?"opacity-50 cursor-not-allowed":i.value?"cursor-default text-blue-500":"cursor-pointer hover:border-blue-500 hover:bg-blue-50 hover:text-blue-500"),h=()=>{t.disabled||i.value||N()&&r.value?.click()},b=M=>{if(!Number.isFinite(M))return"0 B";const O=["B","KB","MB","GB"];let E=0,K=M;for(;K>=1024&&E<O.length-1;)K/=1024,E+=1;return`${K.toFixed(E===0?0:1)} ${O[E]}`},_=M=>{if(!t.max_size)return!0;const O=t.max_size*1024*1024;return M.size>O?(pe.notify({type:"error",title:"Файл занадто великий",message:`Максимальний розмір ${t.max_size} МБ`,position:"right-bottom"}),!1):!0},x=M=>{if(!p.value.length)return!0;const O=`.${M.name.split(".").pop()?.toLowerCase()||""}`;return p.value.includes(O)?!0:(pe.notify({type:"error",title:"Непідтримуваний формат",message:`Дозволені формати: ${p.value.join(", ")}`,position:"right-bottom"}),!1)},v=e.computed(()=>{const M={},O=[];if(!t.customParams?.length)return{params:M,missing:O};const E=u?.value??{};return t.customParams.forEach(K=>{if(!K)return;const[T,Y]=K.split("="),I=T?.trim(),X=Y?.trim();if(!I||!X)return;const Q=E[X];Q==null||Q===""?O.push(X):M[I]=Q}),{params:M,missing:O}}),N=()=>v.value.missing.length?(pe.notify({type:"warning",title:"Заповніть поля",message:`Потрібні значення: ${v.value.missing.join(", ")}`,position:"right-bottom"}),!1):!0,U=M=>{const O=M.target,E=O.files?.[0];if(E){if(!N()){O.value="";return}if(!_(E)||!x(E)){O.value="";return}l.value=E,s.value=0,a.value="",c.value=""}},W=async()=>{if(!l.value){h();return}try{c.value="";const M={id:a.value||"",fileName:l.value.name,subdir:t.subdir,size:l.value.size,...v.value.params},O=await fetch("/api/file/upload2/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M)});if(!O.ok)throw new Error("Не вдалося ініціалізувати завантаження");const E=await O.json();a.value=E.id||a.value,s.value=E.uploaded||0,await L()}catch(M){c.value=M?.message||"Помилка при старті завантаження"}},L=async()=>{if(!(!l.value||!a.value)){i.value=!0;try{for(;s.value<l.value.size;){const M=s.value,O=Math.min(M+t.chunkSize,l.value.size),E=l.value.slice(M,O);d.value=new AbortController;const K=await fetch(`/api/file/upload2/${a.value}`,{method:"PATCH",headers:{"Content-Range":`bytes ${M}-${O-1}/${l.value.size}`},body:E,signal:d.value.signal});if(!K.ok)throw new Error("Помилка завантаження частини");const T=await K.json().catch(()=>({}));if(T.uploaded!=null?s.value=Number(T.uploaded):s.value=O,T.finished||s.value>=l.value.size){i.value=!1;const Y=T.file_path||T.url||a.value;n.value={file_id:T.file_id??a.value??Y,file_path:Y},pe.notify({type:"success",title:"Файл завантажено",message:l.value.name,position:"right-bottom"}),V();return}}}catch(M){if(M?.name==="AbortError")return;c.value=M?.message||"Помилка при завантаженні",i.value=!1}finally{d.value=null,i.value=!1}}},B=()=>{i.value&&(d.value?.abort(),d.value=null,i.value=!1)},S=async()=>{if(l.value){if(!a.value){await W();return}await L()}},$=()=>{d.value?.abort(),d.value=null,V()},V=()=>{const M=r.value;M&&(M.value=""),l.value=null,a.value="",s.value=0,c.value=""};return(M,O)=>(e.openBlock(),e.createElementBlock("div",Sa,[e.createElementVNode("div",$a,[e.createElementVNode("input",{ref_key:"fileInput",ref:r,type:"file",class:"hidden",accept:t.format,disabled:i.value||t.disabled,onChange:U},null,40,Na),n.value?(e.openBlock(),e.createBlock(Jn,{key:0,item:n.value,"onUpdate:item":O[0]||(O[0]=E=>n.value=E),value:n.value,"onUpdate:value":O[1]||(O[1]=E=>n.value=E)},null,8,["item","value"])):(e.openBlock(),e.createElementBlock("div",{key:1,onClick:h,class:e.normalizeClass(["relative h-[120px] w-[120px] border text-gray-300 border-dashed border-[#CFD9E0] rounded-lg flex items-center justify-center transition-all duration-300",m.value])},[i.value?(e.openBlock(),e.createElementBlock("div",Aa,[O[2]||(O[2]=e.createElementVNode("div",{class:"loader"},null,-1)),e.createElementVNode("span",null,e.toDisplayString(y.value)+"%",1)])):(e.openBlock(),e.createBlock(e.unref(q.Plus),{key:1,class:"h-4 w-4"}))],2))]),l.value&&!n.value?(e.openBlock(),e.createElementBlock("div",Fa,[e.createElementVNode("div",Ma,[e.createElementVNode("div",Da,[e.createElementVNode("div",Ta,e.toDisplayString(l.value.name),1),e.createElementVNode("div",La,e.toDisplayString(b(l.value.size)),1)]),e.createElementVNode("div",Ia,e.toDisplayString(k.value),1)]),e.createElementVNode("div",Ra,[e.createElementVNode("div",{class:"h-full rounded-full bg-blue-500 transition-all duration-300",style:e.normalizeStyle({width:`${y.value}%`})},null,4)]),e.createElementVNode("div",Oa,[!i.value&&s.value>0&&s.value<(l.value?.size||0)?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:S}," Resume ")):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:B}," Pause ")):e.createCommentVNode("",!0),!i.value&&s.value===0?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",class:"rounded border border-slate-300 px-3 py-1",onClick:W}," Upload ")):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"rounded border border-rose-200 px-3 py-1 text-rose-600",onClick:$}," Cancel ")]),c.value?(e.openBlock(),e.createElementBlock("p",Pa,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0)]))}}),Qn=xe(za,[["__scopeId","data-v-19ea2129"]]),ja={class:"flex items-center justify-center h-[30px] w-[30px]"},Ua={class:"max-w-[55vw]"},Ha={class:"text-sm font-semibold text-gray-800 truncate dark:text-neutral-200"},qa={class:"flex items-center text-xs text-gray-500 truncate dark:text-neutral-500"},Ka={class:"px-[5px]"},Wa={class:""},bn=e.defineComponent({__name:"vs-widget-file-info",props:{item:{default:null}},setup(o){const t=o,n=e.computed(()=>{try{return new Date(t.item.cdate).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}});function r(l){if(l<1024)return`${l} B`;const a=l/1024;return a<1024?`${a.toFixed(2)} KB`:`${(a/1024).toFixed(2)} MB`}return(l,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("div",ja,[e.createVNode(e.unref(q.FileText),{class:"icon icon-tabler icons-tabler-outline icon-tabler-file h-4 w-4"})]),e.createElementVNode("div",Ua,[e.createElementVNode("p",Ha,e.toDisplayString(l.item?.uploaded_name),1),e.createElementVNode("p",qa,[e.createElementVNode("span",null,e.toDisplayString(l.item?.username),1),e.withDirectives(e.createElementVNode("span",Ka,"|",512),[[e.vShow,l.item?.username]]),e.createElementVNode("span",null,e.toDisplayString(n.value),1),a[0]||(a[0]=e.createElementVNode("span",{class:"px-[5px]"},"|",-1)),e.createElementVNode("span",Wa,e.toDisplayString(r(l.item?.size)),1)])])],64))}}),Ga={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-md w-full"},Ya={key:0,class:"flex w-full gap-x-3 items-center"},Xa={key:1,class:"flex gap-x-3 w-full items-center"},Za={key:2,class:"flex gap-x-3 w-full items-center"},Ja=["href"],Qa={key:3,class:"flex gap-x-3 w-full items-center"},es={class:"lg:absolute lg:top-3 lg:end-1 opacity-100"},ts={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"},ns={class:"inline-block"},os={class:"inline-block"},rs={class:"inline-block"},ls=e.defineComponent({__name:"vs-widget-file-item",props:{item:{default:null},index:{default:0},prefix:{default:"/api"}},emits:["update","openModal","openLightbox"],setup(o,{emit:t}){const n=o,r=t;function l(p){return["pdf","json"].includes(p.ext)}function a(p){return["ppt","pptx","doc","docx","xls","xlsx"].includes(p.ext)}function s(p){const y=document.createElement("a");y.setAttribute("download",p?.uploaded_name),y.href=p?.file_path,y.click()}function i(p){p?.file_path&&window.open(p.file_path,"_blank")}async function c(){try{await fetch(`${n.prefix}/widget/file/${n.item.entity_id}/${n.item.file_id}`),r("update")}catch(p){console.error(p)}}function d(){r("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:c,updateListOnConfirm:!0})}function u(p){(n.item.ext==="jpg"||n.item.ext==="png")&&r("openLightbox",{item:n.item,index:p})}return(p,y)=>(e.openBlock(),e.createElementBlock("div",Ga,[p.item.ext==="jpg"||p.item.ext==="png"?(e.openBlock(),e.createElementBlock("div",Ya,[e.createElementVNode("div",{class:"max-w-[55vw] cursor-pointer flex gap-x-3 w-full items-center",onClick:y[0]||(y[0]=k=>u(p.index))},[e.createVNode(bn,{item:p.item},null,8,["item"])])])):l(p.item)?(e.openBlock(),e.createElementBlock("div",Xa,[e.createVNode(bn,{item:p.item},null,8,["item"])])):a(p.item)?(e.openBlock(),e.createElementBlock("div",Za,[e.createElementVNode("a",{href:`/api/file-preview?id=${p.item.file_id}`,target:"_blank",class:"flex gap-x-3 w-full items-center"},[e.createVNode(bn,{item:p.item},null,8,["item"])],8,Ja)])):(e.openBlock(),e.createElementBlock("div",Qa,[e.createVNode(bn,{item:p.item},null,8,["item"])])),e.createElementVNode("div",es,[e.createElementVNode("div",ts,[e.createElementVNode("div",ns,[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:y[1]||(y[1]=k=>i(p.item))},[e.createVNode(e.unref(q.Eye),{class:"h-4 w-4"})])]),e.createElementVNode("div",os,[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:y[2]||(y[2]=k=>s(p.item))},[e.createVNode(e.unref(q.Download),{class:"h-4 w-4"})])]),y[4]||(y[4]=e.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),e.createElementVNode("div",rs,[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:y[3]||(y[3]=k=>d())},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})])])])])]))}}),as={class:"flex flex-col widget-file xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700 w-full"},ss={class:"flex w-full mb-[12px] items-center gap-x-2"},is={class:"font-semibold text-gray-800 dark:text-neutral-200 text-[14px]"},cs={class1:"ml-auto"},ds={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"},us={key:0,class:"py-4 mb-4 space-y-4 border-gray-200 border-y dark:border-neutral-700"},ps={class:"relative"},fs={class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-[1] ps-3.5"},ms={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"},hs={key:0},Do=e.defineComponent({__name:"vs-input-file-list",props:{id:{default:""},prefix:{default:"/api"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update"],setup(o,{emit:t}){const n=o,r=e.inject("form"),l=e.computed(()=>r.value.formId),a=e.ref(!1),s=e.ref(0),i=t,c=e.ref(!1),d=e.ref({}),u=e.ref([]),p=e.ref(""),y=e.computed(()=>Array.isArray(u.value)?u.value.filter(v=>v.ext==="jpg"||v.ext==="png").map(v=>v?.file_path):[]),k=e.computed(()=>p.value===""?u.value:u.value.filter(v=>v?.uploaded_name?.includes(p.value))),m=v=>{const N=y.value.findIndex(U=>U===v.item.file_path);N!==-1&&(a.value=!0,s.value=N)},h=async()=>{try{const v=await fetch(`${n.prefix}/widget/file/${l.value}`).then(N=>N.json());u.value=v?.rows}catch(v){console.error(v)}},b=async v=>{await Promise.all(Array.from(v.target.files).map(async N=>{const U=new FormData;U.append("file",N);try{const W=`${n.prefix}/widget/file/${l.value}`,L=await fetch(W,{method:"POST",body:U});return L.ok?(i("update","file-list"),N):(pe.notify({type:L.status>=400&&L.status<500?"warning":"error",title:"Error",message:`Error code: ${L.status}`}),null)}catch(W){return pe.notify({type:"error",title:"Error",message:W.message||"Unknown error"}),console.error(W),null}})),await h()},_=v=>{const N={...v};return v.cancel||(N.cancel=()=>{c.value=!1}),v.updateListOnConfirm&&(N.confirm=async()=>{await v.confirm(),c.value=!1,h()}),N},x=v=>{d.value=_(v),c.value=!0};return e.watch(l,v=>{v&&h()}),e.onMounted(()=>{l.value&&h()}),(v,N)=>{const U=e.resolveComponent("Lightbox"),W=e.resolveComponent("MessageBox");return e.openBlock(),e.createElementBlock("div",as,[e.createElementVNode("div",ss,[e.createElementVNode("h2",is," Файлів: "+e.toDisplayString(u.value?.length),1),e.createElementVNode("div",cs,[e.createElementVNode("label",null,[e.createElementVNode("input",{type:"file",class:"hidden",onChange:N[0]||(N[0]=L=>b(L))},null,32),e.createElementVNode("div",ds,[e.createVNode(e.unref(q.Upload),{class:"h-4 w-4"})])])])]),u.value?.length>4?(e.openBlock(),e.createElementBlock("div",us,[e.createElementVNode("div",null,[e.createElementVNode("div",ps,[e.createElementVNode("div",fs,[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":N[1]||(N[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",ms,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,(L,B)=>(e.openBlock(),e.createBlock(ls,{key:B,prefix:v.prefix,item:L,index:B,onUpdate:N[2]||(N[2]=S=>v.$emit("update","file-list")),onOpenModal:N[3]||(N[3]=S=>x(S)),onOpenLightbox:N[4]||(N[4]=S=>m(S))},null,8,["prefix","item","index"]))),128)),k.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",hs,N[8]||(N[8]=[e.createElementVNode("p",{class:"text-sm text-gray-600 font-sm"}," Файлів з такою назвою не існує, введіть інше пошукове слово ",-1)])))])):e.createCommentVNode("",!0),e.createVNode(U,{modelValue:a.value,"onUpdate:modelValue":N[5]||(N[5]=L=>a.value=L),startIndex:s.value,"onUpdate:index":N[6]||(N[6]=L=>s.value=L),images:y.value},null,8,["modelValue","startIndex","images"]),e.createVNode(W,e.mergeProps({modelValue:c.value,"onUpdate:modelValue":N[7]||(N[7]=L=>c.value=L),onConfirm:d.value.confirm},d.value),null,16,["modelValue","onConfirm"])])}}}),gs={class:"flex items-center justify-between"},ys={class:"text-[16px] text-gray-900 font-medium"},bs={class:"grid gap-3"},ks=xe(e.defineComponent({__name:"vs-container-switcher",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",gs,[e.createElementVNode("p",ys,e.toDisplayString(o.title),1),e.createVNode(Wn,{modelValue:n.value,"onUpdate:modelValue":l[0]||(l[0]=a=>n.value=a),style:e.normalizeStyle(o.style)},null,8,["modelValue","style"])]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",bs,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-90320b87"]]),xs={class:"text-[16px] text-gray-900 font-medium"},ws={class:"grid gap-3"},_s=xe(e.defineComponent({__name:"vs-container-accordion",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})},isOpen:{type:Boolean,default:!1}},setup(o){const t=o,n=e.ref(t.isOpen);return e.watch(()=>t.isOpen,r=>{n.value=r}),(r,l)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("button",{type:"button",onClick:l[0]||(l[0]=a=>n.value=!n.value),class:"flex items-center gap-2"},[e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 duration-300",[n.value?"-rotate-180":""]])},null,8,["class"]),e.createElementVNode("span",xs,e.toDisplayString(o.title),1)]),e.createVNode(e.Transition,{name:"slide-fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",ws,[e.renderSlot(r.$slots,"default",{},void 0,!0)],512),[[e.vShow,n.value]])]),_:3})]))}}),[["__scopeId","data-v-0c825d65"]]),Cs={class:"flex items-center justify-between"},vs={switcher:ks,accordion:_s,default:e.defineComponent({__name:"vs-container-default",props:{title:{type:String,default:""},style:{type:Object,default:()=>({})}},setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createElementVNode("div",Cs,[e.createElementVNode("p",null,e.toDisplayString(o.title),1)]),e.renderSlot(t.$slots,"default")]))}})},nt={Equal:"==",Inequal:"!=",Higer:">",HigerOrEqual:">=",Lower:"<",LowerOrEqual:"<=",Between:"between",StartWith:"^",EndWith:"$",Contain:"*",In:"in",NotIn:"not_in"},Es=(o,t)=>String(o)===String(t),Bs=(o,t)=>String(o)!==String(t),Vs=(o,t)=>o>t,Ss=(o,t)=>o>=t,$s=(o,t)=>o<t,Ns=(o,t)=>o<=t,As=(o,t)=>Array.isArray(t)&&t.length===2?o>=t[0]&&o<=t[1]:!1,Fs=(o,t)=>String(o).startsWith(String(t)),Ms=(o,t)=>String(o).endsWith(String(t)),Ds=(o,t)=>String(o).includes(String(t)),Ts=(o,t)=>Array.isArray(t)?t.includes(o):!1,Ls=(o,t)=>Array.isArray(t)?!t.includes(o):!0,Is=(o,t)=>{if(!t)return!0;switch(t?.[1]){case nt.Equal:return Es(o,t?.[2]);case nt.Inequal:return Bs(o,t?.[2]);case nt.Higer:return Vs(o,t?.[2]);case nt.HigerOrEqual:return Ss(o,t?.[2]);case nt.Lower:return $s(o,t?.[2]);case nt.LowerOrEqual:return Ns(o,t?.[2]);case nt.Between:return As(o,t?.[2]);case nt.StartWith:return Fs(o,t?.[2]);case nt.EndWith:return Ms(o,t?.[2]);case nt.Contain:return Ds(o,t?.[2]);case nt.In:return Ts(o,t?.[2]);case nt.NotIn:return Ls(o,t?.[2]);default:return!0}};function To(o,t,n){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=n?o?.[n]?.[a]??o?.[a]:o?.[a];return Is(s,l)})}const Lo=e.defineComponent({__name:"vs-input-container",props:{style:{type:Object,default:()=>({})},title:{type:String,default:""},view:{type:String,default:"default"},name:{type:String,default:""},schema:{type:Array,default:()=>[]}},setup(o){const t=o,n=e.inject("values",e.ref({})),r=e.inject("form"),l=e.computed(()=>t.schema?.filter(i=>To(n.value,i?.conditions,t.name||void 0))),a=e.computed(()=>vs[t.view]),s=e.computed(()=>{if(n.value||(n.value={}),!t.name)return n.value;const i=n.value[t.name];if(i)return i;const c={};return n.value={...n.value,[t.name]:c},c});return(i,c)=>o.schema?.length?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{key:0,title:o.title,style:e.normalizeStyle(o.style)},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,d=>(e.openBlock(),e.createBlock(lr,e.mergeProps({key:d.name},{ref_for:!0},d,{item:d,modelValue:s.value[d.name],"onUpdate:modelValue":u=>s.value[d.name]=u,style:o.style,error:e.unref(r)?.errors?.[d.name]}),null,16,["item","modelValue","onUpdate:modelValue","style","error"]))),128))]),_:1},8,["title","style"])):e.createCommentVNode("",!0)}}),Io=({props:o,fetchOptionByValue:t,optionsList:n,selectedOption:r,modelValue:l,onCreated:a})=>{const s=e.ref(!1),i=e.ref({}),c=e.ref([]),d=e.ref(null),u=e.computed(()=>o.add?.title||"Додати"),p=e.computed(()=>o.add?.token||o.add?.model||""),y=e.computed(()=>o.add?.pk||"id");return{isOpenAdd:s,addData:i,addSchema:c,addForm:d,addTitle:u,addOption:async()=>{if(!(!p.value||d?.value.validate()))try{const b=o.add?.api??`/api/table/${p.value}`,_=await fetch(b,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i.value)}),x=await _.json().catch(()=>({})),v=x?.error||x?.message,N=Number(x?.code)>=400;if(!_.ok||N){pe.notify({title:"Помилка",type:"error",message:v||`Код помилки: ${x?.code||_.status}`});return}const U=x?.[y.value]??x?.id;if(!U){pe.notify({title:"Помилка",type:"error",message:"Обʼєкт створено, але в відповіді відсутній ID."});return}const W=await t(U);W&&(n.value.some(B=>String(B?.id)===String(W.id))||n.value.push(W)),a?await a(W,U):W&&(r.value=W,l.value=U),s.value=!1,pe.notify({title:"Успіх",message:"Обʼєкт успішно створено."})}catch(b){pe.notify({title:"Помилка",type:"error",message:b?.message||"Не вдалося створити обʼєкт."})}},onAddValue:async()=>{if(!o.add)return null;const h=await fetch(`/api/template/form/${o.add.form}`).then(b=>b.json());return c.value=h.schema,i.value={},s.value=!0,null}}},Rs=["aria-expanded","data-focus"],Os={class:"relative flex flex-1 items-center gap-1 py-0.5 pl-1 pr-0 overflow-hidden h-full min-w-0"},Ps={key:0,class:"flex flex-nowrap items-center gap-1 overflow-x-auto overflow-y-hidden min-w-0 flex-1 py-0.5"},zs={class:"flex items-center gap-1 min-w-0"},js=["title"],Us=["innerHTML"],Hs=["onClick"],qs={class:"flex-1 min-w-[2px]"},Ks=["placeholder"],Ws=["title"],Gs=["innerHTML"],Ys={key:3,class:"truncate flex-1 min-w-0"},Xs={key:2,class:"flex-1 min-w-[2px]"},Zs=["placeholder"],Js={key:3,class:"flex-1 flex items-center min-h-[30px] py-0.5 pl-2 text-sm truncate text-inherit"},Qs={class:"flex items-center shrink-0"},ei=["disabled"],ti={key:1,class:"self-stretch w-px bg-[#ccc] my-[1px]"},ni=["disabled","title"],oi=e.defineComponent({__name:"vs-select-control",props:{disabled:{type:Boolean},isOpen:{type:Boolean},inputFocus:{type:Boolean},isMulti:{type:Boolean},selectedOptions:{},selectedIds:{},placeholder:{},search:{type:Boolean},optionTemplate:{default:""},iconWrapperClass:{},selectedOptionLabel:{},selectedOption:{},showClear:{type:Boolean},keyWord:{default:""},setTriggerRef:{},setInputRef:{},shouldShowColorDot:{},optionHasIcon:{},getIconColorStyle:{},resolveOptionIcon:{},renderTemplate:{},getLabel:{},onControlKeydown:{},onControlClick:{},onInputFocus:{},onInputBlur:{},onInputKeydown:{},onRemoveSelected:{},onClearSelected:{},onToggleSelect:{}},emits:["update:keyWord"],setup(o,{emit:t}){const n=o,r=t,l=e.computed({get:()=>n.keyWord,set:a=>r("update:keyWord",a)});return(a,s)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-input-select__control flex min-h-[38px] items-center justify-between rounded transition-colors bg-white",a.disabled?"bg-gray-100 text-gray-400 cursor-not-allowed":""]),role:"combobox","aria-expanded":a.isOpen,"aria-haspopup":"listbox",onKeydown:s[10]||(s[10]=(...i)=>a.onControlKeydown&&a.onControlKeydown(...i)),onClick:s[11]||(s[11]=(...i)=>a.onControlClick&&a.onControlClick(...i)),"data-focus":a.isOpen||a.inputFocus?"true":"false",ref:a.setTriggerRef},[e.createElementVNode("div",Os,[a.isMulti?(e.openBlock(),e.createElementBlock("div",Ps,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.selectedOptions,i=>(e.openBlock(),e.createElementBlock("div",{key:i.id,class:"flex min-w-0 bg-[rgb(230,230,230)] rounded-[2px] m-[2px] box-border max-w-full"},[e.createElementVNode("div",zs,[a.shouldShowColorDot(i)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[16px] h-[16px] rounded-md block ml-1.5 flex-shrink-0",style:e.normalizeStyle({backgroundColor:i?.color})},null,4)):e.createCommentVNode("",!0),!a.optionTemplate&&a.optionHasIcon(i)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(a.iconWrapperClass),style:e.normalizeStyle(a.getIconColorStyle(i)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.resolveOptionIcon(i)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",{class:"truncate text-[#172b4d] overflow-hidden max-w-[200px] px-0.5 pl-1.5",title:a.getLabel(i)},[a.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:a.renderTemplate(i)},null,8,Us)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(i.text),1)],64))],8,js)]),e.createElementVNode("div",{role:"button",class:"flex items-center rounded-sm px-1 box-border text-[#172b4d] hover:bg-[rgb(255,189,173)] hover:text-[rgb(222,53,11)] flex-shrink-0",onClick:e.withModifiers(c=>a.onRemoveSelected(i.id),["stop"])},[e.createVNode(e.unref(q.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Hs)]))),128)),e.createElementVNode("div",qs,[!a.disabled&&a.search?e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref:a.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:a.selectedIds.length?" ":a.placeholder,"onUpdate:modelValue":s[0]||(s[0]=i=>l.value=i),onFocus:s[1]||(s[1]=(...i)=>a.onInputFocus&&a.onInputFocus(...i)),onBlur:s[2]||(s[2]=(...i)=>a.onInputBlur&&a.onInputBlur(...i)),onKeydown:s[3]||(s[3]=(...i)=>a.onInputKeydown&&a.onInputKeydown(...i))},null,40,Ks)),[[e.vModelText,l.value]]):e.createCommentVNode("",!0)])])):!a.isMulti&&a.selectedOptionLabel&&l.value===""?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["truncate flex items-center gap-1 min-w-0 pl-2",a.disabled||!a.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:a.selectedOptionLabel},[a.shouldShowColorDot(a.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[14px] h-[14px] rounded-md block flex-shrink-0",style:e.normalizeStyle({backgroundColor:a.selectedOption?.color})},null,4)):e.createCommentVNode("",!0),!a.optionTemplate&&a.optionHasIcon(a.selectedOption)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(a.iconWrapperClass),style:e.normalizeStyle(a.getIconColorStyle(a.selectedOption)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.resolveOptionIcon(a.selectedOption)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),a.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:2,class:"truncate flex-1 min-w-0",innerHTML:a.renderTemplate(a.selectedOption)},null,8,Gs)):(e.openBlock(),e.createElementBlock("span",Ys,e.toDisplayString(a.selectedOption?.text),1))],10,Ws)):e.createCommentVNode("",!0),!a.isMulti&&!a.disabled&&a.search?(e.openBlock(),e.createElementBlock("div",Xs,[e.withDirectives(e.createElementVNode("input",{ref:a.setInputRef,class:"w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900 hover:cursor-pointer",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-autocomplete":"list",placeholder:a.selectedOptionLabel?" ":a.placeholder,"onUpdate:modelValue":s[4]||(s[4]=i=>l.value=i),onFocus:s[5]||(s[5]=(...i)=>a.onInputFocus&&a.onInputFocus(...i)),onBlur:s[6]||(s[6]=(...i)=>a.onInputBlur&&a.onInputBlur(...i)),onKeydown:s[7]||(s[7]=(...i)=>a.onInputKeydown&&a.onInputKeydown(...i))},null,40,Zs),[[e.vModelText,l.value]])])):!a.isMulti&&a.disabled&&(!a.selectedOptionLabel||l.value!=="")?(e.openBlock(),e.createElementBlock("div",Js,e.toDisplayString(a.placeholder),1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",Qs,[a.showClear?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.disabled,onClick:s[8]||(s[8]=e.withModifiers((...i)=>a.onClearSelected&&a.onClearSelected(...i),["stop"]))},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,ei)):e.createCommentVNode("",!0),a.showClear?(e.openBlock(),e.createElementBlock("div",ti)):e.createCommentVNode("",!0),e.createElementVNode("button",{type:"button",class:"px-2 text-gray-400 hover:text-gray-500 transition-colors disabled:opacity-50","aria-hidden":"true",disabled:a.disabled,onClick:s[9]||(s[9]=e.withModifiers((...i)=>a.onToggleSelect&&a.onToggleSelect(...i),["stop"])),title:a.isOpen?"Закрити список":"Відкрити список"},[e.createVNode(e.unref(q.ChevronDown),{class:"h-4 w-4"})],8,ni)])],42,Rs))}}),ri=["aria-disabled","onMousedown"],li={class:"leading-[19px]"},ai=["innerHTML"],si={key:1,class:"px-3 py-2 text-center text-gray-500"},ii=e.defineComponent({__name:"vs-select-dropdown",props:{isOpen:{type:Boolean},dropdownStyle:{},filteredOptionsList:{},selectedNavIndex:{},optionTemplate:{},iconWrapperClass:{},setDropdownRef:{type:Function},setListRef:{type:Function},setItemRef:{type:Function},isSelected:{type:Function},onOptionClick:{type:Function},shouldShowColorDot:{type:Function},optionHasIcon:{type:Function},getIconColorStyle:{type:Function},resolveOptionIcon:{type:Function},renderTemplate:{type:Function}},setup(o){return(t,n)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[t.isOpen?(e.openBlock(),e.createElementBlock("div",{key:0,ref:t.setDropdownRef,class:"fixed z-[3000] rounded bg-white shadow-[0_0_0_1px_rgba(0,0,0,0.1),0_4px_11px_rgba(0,0,0,0.1)]",style:e.normalizeStyle(t.dropdownStyle),role:"listbox"},[e.createElementVNode("div",{class:"overflow-y-auto py-1",style:e.normalizeStyle({maxHeight:t.dropdownStyle.maxHeight||"300px"}),ref:t.setListRef},[t.filteredOptionsList.length?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(t.filteredOptionsList,(r,l)=>(e.openBlock(),e.createElementBlock("div",{key:r.id,ref_for:!0,ref:a=>t.setItemRef(a,l),class:e.normalizeClass(["flex px-3 py-2 gap-2 cursor-pointer select-none text-gray-900",t.isSelected(r.id)?"bg-[#2684ff] text-white":"bg-white hover:bg-[#deebff] hover:text-[#172b4d]",t.selectedNavIndex===l&&!t.isSelected(r.id)?"bg-[#deebff] text-[#172b4d]":""]),"aria-disabled":t.isSelected(r.id)?"true":"false",role:"option",tabindex:"-1",onMousedown:e.withModifiers(a=>t.onOptionClick(r),["prevent","stop"])},[t.shouldShowColorDot(r)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"w-[11px] h-[11px] rounded-full block flex-shrink-0",style:e.normalizeStyle({backgroundColor:r?.color})},null,4)):e.createCommentVNode("",!0),!t.optionTemplate&&t.optionHasIcon(r)?(e.openBlock(),e.createElementBlock("span",{key:1,class:e.normalizeClass(t.iconWrapperClass),style:e.normalizeStyle(t.getIconColorStyle(r)),"aria-hidden":"true"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.resolveOptionIcon(r)),{class:"w-full h-full",focusable:"false"}))],6)):e.createCommentVNode("",!0),e.createElementVNode("div",li,[t.optionTemplate?(e.openBlock(),e.createElementBlock("div",{key:0,innerHTML:t.renderTemplate(r)},null,8,ai)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(e.toDisplayString(r.text),1)],64))])],42,ri))),128)):(e.openBlock(),e.createElementBlock("div",si," No options "))],4)],4)):e.createCommentVNode("",!0)]))}}),ci=["disabled"],Ro="w-[16px] h-[16px] flex items-center justify-center flex-shrink-0 text-current",eo=xe(e.defineComponent({__name:"vs-input-select",props:{multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean,default:!0},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{default:400},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{default:0},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t,l=e.computed(()=>n.multiple),a=e.computed(()=>n.disabled),s=e.computed(()=>n.search);Ue(n.style);const i=e.computed({get:()=>n.modelValue,set:P=>r("update:modelValue",P)});!i.value&&n.defaultValue&&(i.value=n.defaultValue);const c=e.ref(null),d=e.ref(null),u=e.ref(null),p=e.ref(null),y=e.ref(!1),k=e.ref(!1),m=e.ref(null),h=e.ref(-1),b=e.ref([]),_=e.ref(""),x=e.ref(null),v=P=>{d.value=P},N=P=>{x.value=P},U=P=>{p.value=P},W=P=>{u.value=P},L=(P,ee)=>{b.value[ee]=P},B=e.ref({}),S=e.ref([]),$=e.computed(()=>{if(!S.value.length)return[];const P=fe.value,ee=new Map(P.map(ie=>[ie.id?.toString(),ie]));return S.value.map(ie=>ee.get(ie?.toString())).filter(ie=>!!ie)}),V=e.computed(()=>n.placeholder||"Select..."),M=e.computed(()=>Q(m.value)),O=e.computed(()=>a.value?!1:l.value?S.value.length>0:!!i.value),E=P=>l.value?S.value.some(ee=>ee?.toString()===P?.toString()):i.value?.toString()===P?.toString(),K=e.computed(()=>{let P=fe.value??[];if(!n.data&&_.value.trim()!==""){const ee=_.value.toLowerCase();P=P.filter(ie=>{const Be=Q(ie).toLowerCase(),De=ie.text?.toLowerCase?.()||"";return Be.includes(ee)||De.includes(ee)})}if(l.value&&S.value.length){const ee=new Set(S.value.map(ie=>ie?.toString()));P=P.filter(ie=>!ee.has(ie.id?.toString()))}return P}),T=e.inject("values"),Y=e.inject("field-props"),I=e.computed(()=>n.slot??n?.optionTemplate??""),X=P=>gn(P,I.value),Q=P=>yn(P,I.value),ke=e.computed(()=>fn(I.value)),he=P=>Wt(P),J=P=>!!(!ke.value&&Bt(P)&&!he(P)),me=P=>{const ee=Bt(P);return ee?{color:ee}:void 0},de=P=>!!(!ke.value&&(Kt(P)||he(P))),ne=(P,ee,ie)=>{if(!Y)return!1;const Be=Y.value?.[P]??{},De=(Le,st,ft)=>{if(!st.length)return Le;const[it,...bt]=st,ct={...Le};if(!bt.length)return ct[it]=ft,ct;const dn=typeof Le[it]=="object"&&Le[it]!==null?Le[it]:{};return ct[it]=De(dn,bt,ft),ct},je=De(Be,ee,ie);return Y.value={...Y.value||{},[P]:je},!0},ae=P=>{if(!n.set)return;const ee=T?.value;!ee&&!Y||Object.entries(n.set).forEach(([ie,Be])=>{if(!ie)return;const De=P?P[Be]:null,je=ie.split(".").map(ft=>ft.trim()).filter(Boolean);if(!je.length)return;const[Le,...st]=je;st.length&&ne(Le,st,De??null)||ee&&(ee[Le]=De??null)})},{optionsList:fe,parentValue:Se,fetchOptions:Ve,fetchOptionByValue:Oe,loadOptions:Te}=hn({props:n,formValues:T,watchParent:!1}),Ne=P=>P==null?"":String(P),Ce=P=>{if(l.value){if(!S.value.length){fe.value=P;return}}else if(!m.value){fe.value=P;return}const ee=new Set(P.map(Be=>Ne(Be.id)).filter(Boolean));if(l.value){const Be=new Set(S.value.map(je=>Ne(je)).filter(Boolean)),De=(fe.value??[]).filter(je=>{const Le=Ne(je.id);return!Le||!Be.has(Le)?!1:!ee.has(Le)});fe.value=[...De,...P];return}const ie=Ne(m.value?.id);if(ie&&!ee.has(ie)){fe.value=[m.value,...P];return}fe.value=P},Ee=e.ref(0),Pe=async P=>{const ee=++Ee.value,ie=await Ve(P);return ee!==Ee.value?null:ie},Me=async()=>{if(n.data){const P=await Pe(_.value);return P&&Ce(P),fe.value}return Te()},ze=async P=>{if(P==null||P==="")return null;const ee=fe.value?.find(ie=>ie?.id?.toString()===String(P));return ee||Oe(P)},Ye=async P=>{const ee=new Set(fe.value.map(Be=>Be.id?.toString())),ie=P.filter(Be=>!ee.has(Be?.toString()));ie.length&&await ie.reduce(async(Be,De)=>{await Be;const je=await ze(De);je&&fe.value.push(je)},Promise.resolve())},H=()=>{if(!K.value.length){h.value=-1;return}let P=0;if(!l.value&&m.value){const ee=m.value.id?.toString(),ie=K.value.findIndex(Be=>Be.id?.toString()===ee);ie>=0&&(P=ie)}h.value=P,e.nextTick(()=>{A(b.value[P],u.value)})},Z=async()=>{a.value||(y.value=!0,await e.nextTick(()=>{re()}),await Me(),await e.nextTick(()=>{re(),x.value?.focus()}),H())},te=()=>{y.value=!1,h.value=-1,e.nextTick(()=>{x.value?.blur()})},ce=async P=>{if(a.value)return;(P!==void 0?P:!y.value)?await Z():te()},z=async()=>{if(!a.value){if(y.value){te();return}await Z()}},oe=()=>{l.value?(S.value=[],i.value=[],r("change",[]),ve(null,[])):(m.value=null,i.value=null,r("change",null),ve(null,null)),ae(null),_.value="",e.nextTick(()=>{x.value?.focus(),y.value||Z()})},_e=P=>{l.value&&(S.value=S.value.filter(ee=>ee?.toString()!==P?.toString()),i.value=[...S.value],r("change",i.value),ve(null),e.nextTick(()=>x.value?.focus()))},ve=(P,ee)=>{const ie=ee??(l.value?[...S.value]:P?.id??null);r("value-selected",{name:n.name,value:ie,option:P})},j=P=>{l.value?(E(P.id)||(S.value=[...S.value,P.id],i.value=[...S.value],r("change",i.value),ve(P)),_.value="",e.nextTick(()=>{x.value?.focus(),h.value=Math.min(h.value,K.value.length-1)}),ae(null)):(m.value=P,i.value=P.id,r("change",i.value),ve(P),_.value="",te(),ae(P))},w=P=>{if(E(P.id)){l.value||te();return}j(P)},A=(P,ee)=>{if(!P||!ee)return;const ie=P.offsetTop,Be=ie+P.offsetHeight,De=ee.scrollTop,je=De+ee.clientHeight;let Le=ee.scrollTop;ie<De?Le=ie-80:Be>je&&(Le=Be-ee.clientHeight+4);const st=ee;st.scrollTop=Le},R=P=>{let ee=P.parentElement;for(;ee;){if(ee.classList.contains("ui-dialog__content"))return ee;const ie=window.getComputedStyle(ee),Be=ie.overflow+ie.overflowY+ie.overflowX;if(Be.includes("auto")||Be.includes("scroll")||ee===document.body||ee===document.documentElement)return ee;ee=ee.parentElement}return document.body},re=()=>{if(!d.value)return;const P=d.value.getBoundingClientRect(),ee=window.innerHeight||document.documentElement.clientHeight,ie=window.innerWidth||document.documentElement.clientWidth,Be=8,De=8,je=n.maxHeight||300,Le=ee-P.bottom-De-Be,st=P.top-De-Be,ft=Le>=st,it=Math.max(ie-Be*2,0);let{width:bt}=P;it>0&&bt>it&&(bt=it);let{left:ct}=P;ct+bt+Be>ie&&(ct=ie-bt-Be),ct=Math.max(ct,Be);const dn=Math.min(je,Math.max(ft?Le:st,50));B.value={position:"fixed",left:`${ct}px`,width:`${bt}px`,maxHeight:`${dn}px`,transform:ft?"none":"translateY(-100%)",top:ft?`${P.bottom+De}px`:`${P.top-De}px`}},ge=async P=>{a.value||!y.value&&(P.key==="ArrowDown"||P.key==="ArrowUp")&&(P.preventDefault(),await Z())},Ae=P=>{if(!y.value)return;const{key:ee}=P;if(ee==="ArrowDown")P.preventDefault(),h.value+1<K.value.length&&(h.value+=1,A(b.value[h.value],u.value));else if(ee==="ArrowUp")P.preventDefault(),h.value>0&&(h.value-=1,A(b.value[h.value],u.value));else if(ee==="Enter"){P.preventDefault();const ie=K.value[h.value];ie&&j(ie),x.value?.blur()}else ee==="Escape"?(P.preventDefault(),te()):ee==="Backspace"?l.value&&_.value===""&&S.value.length&&(S.value=S.value.slice(0,-1),i.value=[...S.value],r("change",i.value)):ee==="Home"?(h.value=0,A(b.value[0],u.value)):ee==="End"?(h.value=K.value.length-1,A(b.value[h.value],u.value)):ee==="Tab"&&te()},$e=()=>{a.value||(k.value=!0)},We=()=>{k.value=!1,_.value=""},rt=P=>{P.key==="Escape"&&y.value&&te()},pt=P=>{const ee=P.target;c.value?.contains(ee)||p.value?.contains(ee)||te()},Fe=P=>{y.value&&u.value&&!u.value.contains(P.target)&&re()},lt=()=>{y.value&&re()},Ot=()=>{y.value&&re()};async function an(){if(l.value)Array.isArray(i.value)?S.value=[...i.value]:(S.value=i.value==null?[]:[i.value],i.value=[...S.value]),n.data&&S.value.length&&(await Ye(S.value),await e.nextTick());else{if(Array.isArray(i.value)){const P=i.value[0]??null;i.value=P??null}i.value!=null&&(m.value=await ze(i.value)),ae(m.value??null)}}e.watch(i,()=>{an()}),e.onMounted(async()=>{if(addEventListener("keydown",rt),addEventListener("scroll",Fe,!0),addEventListener("resize",lt),document.addEventListener("click",pt,!0),d.value&&R(d.value).addEventListener("scroll",Ot,!0),n.options?.length&&!n.data)fe.value=[...n.options];else if(n.data){const P=await Pe("");P&&Ce(P)}await an(),Ht.value=!1}),e.onUnmounted(()=>{removeEventListener("keydown",rt),removeEventListener("scroll",Fe,!0),removeEventListener("resize",lt),document.removeEventListener("click",pt,!0),d.value&&R(d.value).removeEventListener("scroll",Ot,!0)});const{isOpenAdd:Ft,addData:sn,addSchema:Mt,addForm:Pt,addTitle:wo,addOption:vt,onAddValue:jn}=Io({props:n,fetchOptionByValue:Oe,optionsList:fe,selectedOption:m,modelValue:i});function cn(P,ee=200){let ie;return(...Be)=>{ie&&clearTimeout(ie),ie=window.setTimeout(()=>P(...Be),ee)}}const at=cn(async P=>{const ee=await Pe(P);ee&&Ce(ee)},200);e.watch(_,P=>{n.data&&at(P.trim())}),e.watch(()=>n.options,P=>{!n.data&&P?.length&&(fe.value=[...P],an())},{immediate:!0});const Ht=e.ref(!0);return e.watch(Se,async()=>{if(n.data&&(Ht.value||(l.value?(S.value=[],i.value=[],r("change",[])):(m.value=null,i.value=null,r("change",null))),await Me(),n.auto===1&&Se.value&&fe.value.length>0)){const P=fe.value[0];P&&j(P)}}),(P,ee)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(pe.VsModal),{visible:e.unref(Ft),"onUpdate:visible":ee[1]||(ee[1]=ie=>e.isRef(Ft)?Ft.value=ie:null),class:"z-[1000]",title:e.unref(wo),buttonText:"Додати",onDone:e.unref(vt),teleport:P.teleport},{default:e.withCtx(()=>[e.createVNode(ot,{schema:e.unref(Mt),modelValue:e.unref(sn),"onUpdate:modelValue":ee[0]||(ee[0]=ie=>e.isRef(sn)?sn.value=ie:null),ref_key:"addForm",ref:Pt},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone","teleport"]),e.createElementVNode("div",{class:"flex gap-1 w-full",ref_key:"selectRoot",ref:c,onClick:ee[4]||(ee[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.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(oi,{keyWord:_.value,"onUpdate:keyWord":ee[2]||(ee[2]=ie=>_.value=ie),disabled:a.value,"is-open":y.value,"input-focus":k.value,"is-multi":l.value,"selected-options":$.value,"selected-ids":S.value,placeholder:V.value,search:s.value,"option-template":I.value,"icon-wrapper-class":Ro,"selected-option-label":M.value,"selected-option":m.value,"show-clear":O.value,"set-trigger-ref":v,"set-input-ref":N,"should-show-color-dot":J,"option-has-icon":de,"get-icon-color-style":me,"resolve-option-icon":he,"render-template":X,"get-label":Q,"on-control-keydown":ge,"on-control-click":z,"on-input-focus":$e,"on-input-blur":We,"on-input-keydown":Ae,"on-remove-selected":_e,"on-clear-selected":oe,"on-toggle-select":ce},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(ii,{"is-open":y.value,"dropdown-style":B.value,"filtered-options-list":K.value,"selected-nav-index":h.value,"option-template":I.value,"icon-wrapper-class":Ro,"set-dropdown-ref":U,"set-list-ref":W,"set-item-ref":L,"is-selected":E,"on-option-click":w,"should-show-color-dot":J,"option-has-icon":de,"get-icon-color-style":me,"resolve-option-icon":he,"render-template":X},null,8,["is-open","dropdown-style","filtered-options-list","selected-nav-index","option-template"])],2),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:ee[3]||(ee[3]=(...ie)=>e.unref(jn)&&e.unref(jn)(...ie)),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,ci)):e.createCommentVNode("",!0)],512)],64))}}),[["__scopeId","data-v-47aa1c50"]]),to=(o="")=>`${o}${Math.floor(Math.random()*1e4)}`,di=["disabled","aria-expanded"],ui={class:"truncate"},pi={class:"py-2 px-4"},fi={class:"block font-medium text-[13px] text-foreground"},mi={class:"truncate"},hi={class:"p-1 border-t border-gray-200"},gi={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"},yi=["onClick"],bi=["checked"],ki={class:"shrink-0 size-3.5 flex justify-center items-center"},xi={key:1,class:"shrink-0 size-2 block mx-auto rounded-full bg-secondary/60"},wi={class:"truncate"},_i={key:0,class:"px-3 py-2 text-xs text-stone-500"},kn=e.defineComponent({__name:"vs-input-inline-select",props:{multiple:{type:Boolean},disabled:{type:Boolean,default:!1},mode:{},defaultValue:{},search:{type:Boolean},placeholder:{default:"Оберіть значення"},prefix:{default:"api"},host:{default:""},data:{default:""},options:{default:()=>[]},api:{default:null},maxHeight:{},parent:{},set:{},slot:{},add:{},teleport:{default:"body"},auto:{},start:{default:0},style:{default:()=>({})},customClass:{default:""},modelValue:{},error:{default:null},name:{},maxlength:{},minlength:{}},emits:["change","update:modelValue","value-selected"],setup(o,{emit:t}){const n=o,r=t;Ue(n.style);const l=e.computed({get:()=>Array.isArray(n.modelValue)?n.modelValue[0]??null:n.modelValue??null,set:ne=>r("update:modelValue",ne)});l.value==null&&n.defaultValue!=null&&(l.value=n.defaultValue);const a=e.inject("values"),s=e.inject("field-props"),i=e.computed(()=>!!n.disabled),c=e.ref(null),d=e.ref(!1),u=e.ref(null),p=e.ref(null),y=e.ref(null),k=e.ref({}),m=`vs-input-inline-select-${to()}`,h=e.computed(()=>n.placeholder||"Оберіть значення"),b=e.computed(()=>U(c.value)||n.placeholder||"Оберіть значення"),_=e.computed(()=>n.slot??""),x=e.computed(()=>fn(_.value)),v=e.computed(()=>n.teleport||"body"),N=/^#(?:[\da-fA-F]{3}|[\da-fA-F]{6}|[\da-fA-F]{8})$/,U=ne=>yn(ne,_.value),W=ne=>!!(!x.value&&Bt(ne)),L=e.computed(()=>{const ne=Bt(c.value).trim();return ne?N.test(ne)?`bg-[${ne}] border-[${ne}]`:`bg-${ne.toLowerCase()}-500 border-${ne.toLowerCase()}-500`:""}),{optionsList:B,parentValue:S,fetchOptions:$,fetchOptionByValue:V,loadOptions:M}=hn({props:n,formValues:a,watchParent:!1}),O=(ne,ae,fe)=>{if(!s)return!1;const Se=s.value?.[ne]??{},Ve=(Te,Ne,Ce)=>{if(!Ne.length)return Te;const[Ee,...Pe]=Ne,Me={...Te};if(!Pe.length)return Me[Ee]=Ce,Me;const ze=typeof Te[Ee]=="object"&&Te[Ee]!==null?Te[Ee]:{};return Me[Ee]=Ve(ze,Pe,Ce),Me},Oe=Ve(Se,ae,fe);return s.value={...s.value||{},[ne]:Oe},!0},E=ne=>{if(!n.set)return;const ae=a?.value;!ae&&!s||Object.entries(n.set).forEach(([fe,Se])=>{if(!fe)return;const Ve=ne?ne[Se]:null,Oe=fe.split(".").map(Ce=>Ce.trim()).filter(Boolean);if(!Oe.length)return;const[Te,...Ne]=Oe;Ne.length&&O(Te,Ne,Ve??null)||ae&&(ae[Te]=Ve??null)})},K=ne=>l.value?.toString?.()===ne?.toString?.(),T=()=>{if(!p.value||typeof window>"u")return;const ne=p.value.getBoundingClientRect(),ae=8,fe=8,Se=window.innerHeight||document.documentElement.clientHeight,Ve=window.innerWidth||document.documentElement.clientWidth,Oe=y.value?.offsetHeight||260,Te=Math.max(ne.width,176),Ne=Math.max(Ve-ae*2,120),Ce=Math.min(Te,Ne);let Ee=ne.left;Ee+Ce+ae>Ve&&(Ee=Ve-Ce-ae),Ee=Math.max(Ee,ae);const Pe=Se-ne.bottom-fe-ae,Me=ne.top-fe-ae,ze=Pe<Math.min(Oe,260)&&Me>Pe,Ye=Math.max(120,Math.min(320,ze?Me:Pe));k.value={position:"fixed",left:`${Ee}px`,top:ze?`${ne.top-fe}px`:`${ne.bottom+fe}px`,transform:ze?"translateY(-100%)":"none",width:`${Ce}px`,maxHeight:`${Ye}px`}},Y=async()=>{if(n.data){B.value=await $("");return}await M()},I=async()=>{if(l.value==null||l.value===""){c.value=null,E(null);return}const ne=B.value.find(ae=>ae.id?.toString()===String(l.value));if(ne){c.value=ne,E(ne);return}c.value=await V(l.value),E(c.value??null)},X=async()=>{i.value||(d.value=!0,await e.nextTick(),T(),await Y(),await e.nextTick(),T())},Q=()=>{d.value=!1},ke=async()=>{if(d.value){Q();return}await X()},he=ne=>{r("value-selected",{name:n.name,value:ne?.id??null,option:ne})},J=ne=>{c.value=ne,l.value=ne.id,r("change",ne.id),he(ne),E(ne),Q()},me=ne=>{const ae=ne.target;u.value?.contains(ae)||y.value?.contains(ae)||Q()},de=()=>{d.value&&T()};return e.watch(()=>n.options,ne=>{n.data||(B.value=ne?[...ne]:[],I())},{immediate:!0,deep:!0}),e.watch(l,()=>{I()}),e.watch(S,async()=>{n.data&&(await Y(),c.value&&!B.value.some(ne=>ne.id?.toString()===c.value?.id?.toString())&&(c.value=null,l.value=null,r("change",null),he(null),E(null)))}),e.onMounted(async()=>{document.addEventListener("click",me,!0),window.addEventListener("resize",de),window.addEventListener("scroll",de,!0),await Y(),await I()}),e.onUnmounted(()=>{document.removeEventListener("click",me,!0),window.removeEventListener("resize",de),window.removeEventListener("scroll",de,!0)}),(ne,ae)=>(e.openBlock(),e.createElementBlock("div",{class:"relative inline-flex w-full max-w-full",ref_key:"rootRef",ref:u,onClick:ae[0]||(ae[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("button",{ref_key:"triggerRef",ref:p,type:"button",disabled:i.value,"aria-expanded":d.value?"true":"false","aria-haspopup":"menu",class:e.normalizeClass(["py-1.5 px-2.5 inline-flex items-center gap-2 text-nowrap text-xs sm:text-[13px] rounded-lg focus:outline-hidden disabled:opacity-50 disabled:pointer-events-none max-w-full border",L.value?`${L.value} text-white`:"bg-secondary text-secondary-foreground hover:bg-secondary-hover focus:bg-secondary-focus border-gray-300 hover:border-gray-400"]),onClick:ke},[e.createElementVNode("span",ui,e.toDisplayString(b.value),1)],10,di),(e.openBlock(),e.createBlock(e.Teleport,{to:v.value},[d.value?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"dropdownRef",ref:y,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(k.value),role:"menu","aria-orientation":"vertical"},[e.createElementVNode("div",pi,[e.createElementVNode("span",fi,[e.createElementVNode("span",mi,e.toDisplayString(h.value),1)])]),e.createElementVNode("div",hi,[e.createElementVNode("div",gi,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(B),fe=>(e.openBlock(),e.createElementBlock("label",{key:fe.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(Se=>J(fe),["prevent"])},[e.createElementVNode("input",{type:"radio",class:"hidden",name:m,checked:K(fe.id),tabindex:"-1"},null,8,bi),e.createElementVNode("span",ki,[W(fe)?(e.openBlock(),e.createElementBlock("span",{key:0,class:"shrink-0 size-2 block mx-auto rounded-full",style:e.normalizeStyle({backgroundColor:fe.color})},null,4)):(e.openBlock(),e.createElementBlock("span",xi))]),e.createElementVNode("span",wi,e.toDisplayString(U(fe)),1),e.createVNode(e.unref(q.Check),{class:e.normalizeClass(["shrink-0 size-3.5 ms-auto transition-opacity",K(fe.id)?"opacity-100":"opacity-0"])},null,8,["class"])],8,yi))),128))]),e.unref(B).length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",_i,"Немає варіантів"))])],4)):e.createCommentVNode("",!0)],8,["to"]))],512))}}),Ci=["placeholder","disabled"],Oo=e.defineComponent({__name:"vs-input-textarea",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,{inputClass:n}=Ue(t.style),r=e.useModel(o,"modelValue"),l=e.computed(()=>!!t.disabled),a=e.computed(()=>t.placeholder??"");function s(){typeof r.value=="string"&&(r.value=r.value.trim())}return(i,c)=>e.withDirectives((e.openBlock(),e.createElementBlock("textarea",{"onUpdate:modelValue":c[0]||(c[0]=d=>r.value=d),placeholder:a.value,disabled:l.value,row:"2",onBlur:s,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] h-auto bg-white",[e.unref(n)]]),style:{border:"1px solid #CFD9E0"}},null,42,Ci)),[[e.vModelText,r.value]])}}),Po=e.defineComponent({__name:"vs-input-richtext",props:e.mergeModels({style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},format:{default:"html"},richtextProps:{default:()=>({})}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.defineAsyncComponent(()=>Promise.resolve().then(()=>y0)),n=o,{inputClass:r}=Ue(n.style),l=e.useModel(o,"modelValue"),a=e.computed(()=>!!n.disabled),s=e.computed(()=>n.placeholder??""),i=e.computed(()=>({height:n.richtextProps.height||"300px",format:n.format,...n.richtextProps}));return(c,d)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["!h-full",[c.customClass,e.unref(r)]]),style:e.normalizeStyle(a.value?{pointerEvents:"none",opacity:.6}:{})},[e.createVNode(e.unref(t),e.mergeProps({modelValue:l.value,"onUpdate:modelValue":d[0]||(d[0]=u=>l.value=u),placeholder:s.value},i.value),null,16,["modelValue","placeholder"])],6))}}),vi={},Ei={viewBox:"0 0 178 90",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function Bi(o,t){return e.openBlock(),e.createElementBlock("svg",Ei,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 Vi=xe(vi,[["render",Bi]]),Si={class:"bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden flex flex-col"},$i={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"},Ni={key:0,class:"relative flex-1 min-w-0"},Ai={class:"flex flex-nowrap items-center justify-end gap-2 shrink-0"},Fi={class:"w-full overflow-x-auto"},Mi={class:"w-full min-w-[640px] table-auto divide-y divide-gray-200"},Di={class:"bg-gray-50"},Ti={class:"border-b border-gray-200"},Li={class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 w-12 text-center"},Ii=["onClick"],Ri={key:0,class:"text-gray-400"},Oi={key:0,colspan:"100%",class:"text-center"},Pi={class:"w-full"},zi={class:"p-5 min-h-[200px] flex flex-col justify-center items-center text-center"},ji=["data-row-index","onDragstart","onDragover","onDrop"],Ui=["onPointerdown"],Hi={class:"flex items-center justify-center"},qi=["innerHTML"],Ki={key:0,class:"flex items-center gap-3 text-sm text-gray-700"},Wi={key:0},Gi=["src"],Yi={key:1,class:"rounded-md max-w-[45px] w-[45px] max-h-[45px] h-[45px] bg-gray-200 flex items-center justify-center"},Xi={key:1,class:"flex items-center justify-center"},Zi={key:2,class:"text-sm font-medium text-gray-900"},Ji={class:"px-4 py-3 text-right whitespace-nowrap"},Qi={class:"flex items-center justify-end gap-2"},ec=["onClick"],tc=["onClick"],nc={class:"vs-form__head mr-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},zo=e.defineComponent({__name:"vs-input-datatable",props:e.mergeModels({actions:{},colModel:{},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useSlots(),r=H=>t.actions===void 0?!0:t.actions.includes(H),l=["search","import","export","add"],a=e.computed(()=>l.some(H=>r(H))),s=e.useModel(o,"modelValue"),i=e.ref({}),c=e.ref(""),d=e.ref(null),u=e.ref("asc"),p=e.computed(()=>{const H=s.value??[],Z=c.value?H.filter(z=>y.value?.some(oe=>{const _e=oe.key||oe.name;if(!_e)return!1;const ve=z[_e];return ve?Array.isArray(ve)?ve.join(", ").toLowerCase().includes(c.value.toLowerCase()):String(ve).toLowerCase().includes(c.value.toLowerCase()):!1})):H;if(!d.value)return Z;const te=d.value,ce=[...Z].sort((z,oe)=>{const _e=Ve(z?.[te]),ve=Ve(oe?.[te]);return typeof _e=="number"&&typeof ve=="number"?_e-ve:String(_e).localeCompare(String(ve))});return u.value==="asc"?ce:ce.reverse()}),y=e.computed(()=>(t.colModel??[]).filter(H=>!H.tableHidden)),k=e.ref(null),m=e.ref(null),h=e.ref(null);function b(H){return H.pointerType==="touch"||H.pointerType==="pen"}function _(H,Z){const ce=document.elementFromPoint(H,Z)?.closest?.("[data-row-index]")??null;if(!ce)return null;const z=ce.getAttribute("data-row-index");if(z==null)return null;const oe=Number.parseInt(z,10);return Number.isNaN(oe)?null:oe}function x(H,Z){b(H)&&(H.preventDefault(),H.currentTarget.setPointerCapture(H.pointerId),k.value=Z,m.value=Z)}function v(H){if(k.value===null||!b(H))return;H.preventDefault();const Z=_(H.clientX,H.clientY);Z!==null&&(m.value=Z)}function N(H){if(k.value===null||!b(H))return;H.preventDefault();const Z=_(H.clientX,H.clientY);B(Z??k.value);try{H.currentTarget.releasePointerCapture(H.pointerId)}catch{}}function U(H){if(b(H)){k.value=null,m.value=null;try{H.currentTarget.releasePointerCapture(H.pointerId)}catch{}}}const W=H=>{k.value=H},L=H=>{m.value=H},B=H=>{if(k.value===null||k.value===H){k.value=null,m.value=null;return}const Z=[...s.value],[te]=Z.splice(k.value,1);Z.splice(H,0,te),s.value=Z,k.value=null,m.value=null},S=()=>{h.value&&h.value.click()},$=H=>{const Z=[".jpg",".jpeg",".png",".gif",".bmp",".webp",".svg",".ico",".tiff",".tif"],te=H.toLowerCase();return Z.some(ce=>te.endsWith(ce))},V=H=>{const te=H.target.files?.[0];if(!te)return;const ce=new FileReader;ce.onload=z=>{try{const oe=z.target?.result;if(typeof oe=="string"){const _e=JSON.parse(oe);Array.isArray(_e)&&s.value.push(..._e)}}catch(oe){console.error("Error parsing file:",oe)}},ce.readAsText(te)},M=()=>{const H=JSON.stringify(s.value,null,2),Z=new Blob([H],{type:"application/json"}),te=URL.createObjectURL(Z),ce=document.createElement("a");ce.href=te,ce.download="data.json",ce.click(),URL.revokeObjectURL(te)},O=new Set(["autocomplete","select","radio","checkbox","combobox"]),E=new Map,K=(H,Z)=>{const te=`/api/suggest/${H}`,ce=te.includes("?")?"&":"?",z=Z?`&val=${Z}`:"";return`${te}${ce}json=1${z}`},T=H=>H==null||H===""?null:typeof H=="object"?H?.id!==void 0&&H.id!==null&&H.id!==""?H.id:null:H,Y=H=>{const Z=new Set;return Array.isArray(s.value)&&s.value.forEach(te=>{const ce=te?.[H];if(ce==null||ce==="")return;if(Array.isArray(ce)){ce.forEach(oe=>{const _e=T(oe);_e!==null&&Z.add(_e)});return}const z=T(ce);z!==null&&Z.add(z)}),Z},I=async()=>{if(!t.colModel?.length)return;const H=t.colModel.filter(Z=>Z.data&&O.has(Z.type?.toLowerCase()||""));H.length&&await Promise.all(H.map(async Z=>{const te=Z.key||Z.name;if(!te)return;const ce=Y(te),z=Array.from(ce).map(ve=>String(ve)).sort(),oe=z.join(",");if(!z.length||E.get(te)===oe)return;E.set(te,oe);const _e=z.map(encodeURIComponent).join(",");try{const j=await(await fetch(K(Z.data,_e))).json();i.value[te]=j?.data??j}catch(ve){console.error("Failed to fetch column values",ve)}}))};e.watch([()=>t.colModel,()=>s.value],()=>{I()},{immediate:!0,deep:!0});const X=e.ref(""),Q=e.ref(!1);let ke="edit",he=0;const J=H=>(H?.format||H?.type||"").toString().toLowerCase(),me=e.computed(()=>(t.colModel?.filter(Z=>J(Z)!=="slot")??[]).map(Z=>{const te=Z.key||Z.name;return te?{...Z,name:te,key:te}:Z})),de=e.ref({}),ne=e.ref({}),ae=H=>typeof H!="string"?!1:!!n[H],fe=(H,Z)=>Z?Z.split(".").reduce((te,ce)=>te==null?te:te[ce.trim()],H):H,Se=(H,Z)=>typeof H!="string"?"":H.replace(/{{\s*([^}]+)\s*}}/g,(te,ce)=>{const z=fe(Z,ce.trim());return z??""}),Ve=H=>{if(H==null||H==="")return"";if(typeof H=="number")return H;if(typeof H=="boolean")return H?1:0;if(typeof H=="string")return H.toLowerCase();if(Array.isArray(H))return H.map(Z=>Ve(Z)).join(", ");if(typeof H=="object"){if(H.text!==void 0)return String(H.text).toLowerCase();if(H.label!==void 0)return String(H.label).toLowerCase();if(H.id!==void 0)return String(H.id).toLowerCase()}return String(H).toLowerCase()},Oe=H=>{const Z=H.key||H.name;if(Z){if(d.value===Z){u.value=u.value==="asc"?"desc":"asc";return}d.value=Z,u.value="asc"}};async function Te(){X.value="Додати",Q.value=!0,ke="add",de.value={}}function Ne(H,Z){if(!H?.length)return null;const te=typeof Z=="object"?Z?.id:Z;return te==null||te===""?null:H.find(ce=>ce?.id?.toString()===te.toString())?.text??null}function Ce(H){return H==null||H===""?"-":Array.isArray(H)?H.map(Z=>typeof Z=="object"?Z?.text??Z?.id??"-":Z).join(", "):typeof H=="object"?H?.text??H?.id??"-":H}function Ee(H,Z){const te=Z.key||Z.name,ce=H?.[te],z=i.value[te];if(!ce)return"-";if(Array.isArray(ce)){const _e=ce.map(ve=>Ne(z,ve)).filter(Boolean);return _e.length?_e.join(", "):Ce(ce)}const oe=Ne(z,ce);return oe||Ce(ce)}async function Pe(H,Z){X.value="Редагувати",Q.value=!0,ke="edit",he=Z,de.value={...H}}function Me(){const H=ne.value.validate();if(H){pe.notify({type:"warning",title:"Помилка валідації",message:Object.entries(H).map(([Z,te])=>`${Z}: ${te}`).join(`
2
+ `)});return}ke==="add"?Array.isArray(s.value)?s.value=[...s.value,de.value]:s.value=[de.value]:s.value=s.value.map((Z,te)=>te===he?de.value:Z),Q.value=!1}function ze(H){s.value=s.value.filter((Z,te)=>te!==H)}function Ye(){Q.value=!1}return(H,Z)=>(e.openBlock(),e.createElementBlock("div",Si,[a.value?(e.openBlock(),e.createElementBlock("div",$i,[r("search")?(e.openBlock(),e.createElementBlock("div",Ni,[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":Z[0]||(Z[0]=te=>c.value=te),placeholder:"Пошук",class:"w-full rounded-md border border-gray-200 bg-white pl-10 pr-3 py-2 text-sm text-gray-900 placeholder:text-gray-400 focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-100"},null,512),[[e.vModelText,c.value]])])):e.createCommentVNode("",!0),e.createElementVNode("div",Ai,[r("import")?(e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"fileInput",ref:h,onChange:V,class:"hidden",accept:".json",type:"file"},null,544)):e.createCommentVNode("",!0),r("import")?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",onClick:S,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"}),Z[4]||(Z[4]=e.createTextVNode(" Імпорт ",-1))])):e.createCommentVNode("",!0),r("export")?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:M,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"}),Z[5]||(Z[5]=e.createTextVNode(" Експорт ",-1))])):e.createCommentVNode("",!0),r("add")?(e.openBlock(),e.createElementBlock("button",{key:3,onClick:Te,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"}),Z[6]||(Z[6]=e.createTextVNode(" Додати ",-1))])):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0),e.createElementVNode("div",Fi,[e.createElementVNode("table",Mi,[e.createElementVNode("thead",Di,[e.createElementVNode("tr",Ti,[e.createElementVNode("th",Li,[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(y.value,te=>(e.openBlock(),e.createElementBlock("th",{key:te.key,class:"px-4 py-3 text-left text-xs font-semibold text-gray-900"},[e.createElementVNode("button",{type:"button",onClick:ce=>Oe(te),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(te.ua||te.label),1),d.value===(te.key||te.name)?(e.openBlock(),e.createElementBlock("span",Ri,e.toDisplayString(u.value==="asc"?"▲":"▼"),1)):e.createCommentVNode("",!0)],8,Ii)]))),128)),Z[7]||(Z[7]=e.createElementVNode("th",{class:"px-4 py-3 text-left text-xs font-semibold text-gray-900 text-center w-[1%] whitespace-nowrap"}," Дії ",-1))])]),e.createElementVNode("tbody",{class:e.normalizeClass(["divide-y divide-gray-200",{"[&_tr:last-child]:border-0":!m.value}])},[p.value.length===0?(e.openBlock(),e.createElementBlock("td",Oi,[e.createElementVNode("div",Pi,[e.createElementVNode("div",zi,[e.createVNode(Vi,{class:"w-48 mx-auto"}),Z[8]||(Z[8]=e.createElementVNode("div",{class:"max-w-sm mx-auto mt-6"},[e.createElementVNode("p",{class:"font-medium text-gray-800 dark:text-neutral-200"},"Нічого не знайдено"),e.createElementVNode("p",{class:"mt-2 text-sm text-gray-500 dark:text-neutral-500"})],-1))])])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(te,ce)=>(e.openBlock(),e.createElementBlock("tr",{key:te.id,"data-row-index":ce,class:e.normalizeClass(["border-b transition-colors hover:bg-gray-50 cursor-move text-sm text-gray-700",{"opacity-50":k.value===ce,"border-t-2 border-b-2 border-blue-500 bg-blue-50 dark:bg-blue-900/20":m.value===ce}]),draggable:"true",onDragstart:z=>W(ce),onDragover:e.withModifiers(z=>L(ce),["prevent"]),onDrop:z=>B(ce)},[e.createElementVNode("td",{class:"px-4 py-3 text-center align-middle touch-none select-none",onPointerdown:z=>x(z,ce),onPointermove:v,onPointerup:N,onPointercancel:U},[e.createElementVNode("div",Hi,[e.createVNode(e.unref(q.GripVertical),{class:"mx-auto h-4 w-4 text-slate-400 dark:text-slate-500"})])],40,Ui),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(y.value,z=>(e.openBlock(),e.createElementBlock("td",{key:z.key,class:"px-4 py-3 align-middle"},[J(z)==="slot"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[ae(z.slot)?e.renderSlot(H.$slots,z.slot,{key:0,row:te,value:te[z.key],column:z}):(e.openBlock(),e.createElementBlock("div",{key:1,class:"text-sm text-gray-900",innerHTML:Se(z.slot,te)},null,8,qi))],64)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[J(z)==="file"?(e.openBlock(),e.createElementBlock("div",Ki,[$(Ee(te,z))?(e.openBlock(),e.createElementBlock("div",Wi,[e.createElementVNode("img",{src:Ee(te,z),alt:"alt",width:"45",class:"rounded-md max-w-[45px] h-[45px] object-cover"},null,8,Gi)])):(e.openBlock(),e.createElementBlock("div",Yi,[e.createVNode(e.unref(q.FileText),{class:"h-4 w-4 min-w-4"})]))])):J(z)==="color"?(e.openBlock(),e.createElementBlock("div",Xi,[e.createElementVNode("span",{class:"inline-flex h-6 w-6 rounded border border-gray-200",style:e.normalizeStyle({backgroundColor:Ee(te,z)||"#ffffff"})},null,4)])):(e.openBlock(),e.createElementBlock("div",Zi,e.toDisplayString(Ee(te,z)),1))],64))]))),128)),e.createElementVNode("td",Ji,[e.createElementVNode("div",Qi,[e.createElementVNode("button",{onClick:z=>Pe(te,ce),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,ec),e.createElementVNode("button",{onClick:z=>ze(ce),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,tc)])])],42,ji))),128))],2)])]),e.createVNode(e.unref(pe.VsModal),{visible:Q.value,title:X.value,size:"lg",onClose:Ye,teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(ot,{schema:me.value,"form-id":"datatable-row",values:de.value,"onUpdate:values":Z[1]||(Z[1]=te=>de.value=te),form:ne.value,"onUpdate:form":Z[2]||(Z[2]=te=>ne.value=te)},null,8,["schema","values","form"]),e.createElementVNode("div",nc,[e.createElementVNode("button",{type:"button",onClick:Z[3]||(Z[3]=te=>Q.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:Me,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"])]))}}),oc={},rc={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 lc(o,t){return e.openBlock(),e.createElementBlock("svg",rc,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 ac=xe(oc,[["render",lc]]),sc={},ic={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 cc(o,t){return e.openBlock(),e.createElementBlock("svg",ic,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 dc=xe(sc,[["render",cc]]),uc={},pc={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 fc(o,t){return e.openBlock(),e.createElementBlock("svg",pc,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 mc=xe(uc,[["render",fc]]),hc={class:"bg-white/30 p-1 rounded-md shadow w-fit"},gc={class:"flex gap-2"},yc=["onClick","title"],bc=["src"],kc=e.defineComponent({__name:"map-layers",props:{basemaps:{}},emits:["onLayerChange"],setup(o,{emit:t}){const n=o,r=e.ref(Object.keys(n.basemaps)[0]),l=t;function a(c){l("onLayerChange",c),r.value=c}const s={z:13,x:4790,y:2762};function i(c){if(c?.preview)return c.preview;if(!c?.url)return;const d={"{z}":s.z,"{x}":s.x,"{y}":s.y};let u=c.url;return Object.entries(d).forEach(([p,y])=>{u=u.replace(new RegExp(p,"gi"),String(y))}),u}return(c,d)=>(e.openBlock(),e.createElementBlock("div",hc,[e.createElementVNode("div",gc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.basemaps,(u,p)=>(e.openBlock(),e.createElementBlock("div",{key:p,class:e.normalizeClass(["cursor-pointer border rounded-lg overflow-hidden hover:shadow-sm",{"ring-2 ring-blue-500 border-blue-300":r.value===p}]),onClick:y=>a(p),title:u.name||p,role:"button",tabindex:"0"},[e.createElementVNode("img",{src:i(u),alt:"",class:"w-10 h-10 object-cover"},null,8,bc)],10,yc))),128))])]))}}),Tt=1e-10,xn=/([+-]?\d{1,3})\s*[°º˚]\s*(\d{1,2})\s*['’′`]\s*(\d{1,2}(?:\.\d+)?)\s*["”″]\s*([NSEW])/gi,xc=/^[+-]?\d+(?:\.\d+)?$/;function wc(o,t,n){const r=o.split(/\r?\n/).map(d=>d.trim()).filter(Boolean);if(r.length<3)return{ok:!1,errors:[{line:0,message:"Має бути щонайменше 3 рядки координат."}]};if(r.length>100)return{ok:!1,errors:[{line:0,message:"Допускається не більше 100 рядків координат."}]};const l=[],a=[];if(r.forEach((d,u)=>{const p=u+1,y=t==="decimal"?_c(d,p,n):Uo(d,p,n);if(!y.ok){l.push(...y.errors);return}const k=a[a.length-1];if(k&&qo(k,y.point)){l.push({line:p,message:"Послідовні точки не повинні дублюватися."});return}a.push(y.point)}),l.length)return{ok:!1,errors:l};if(new Set(a.map(vc)).size<3)return{ok:!1,errors:[{line:0,message:"Полігон повинен містити мінімум 3 унікальні точки."}]};const i=[...a];let c=!1;return qo(i[0],i[i.length-1])||(i.push(i[0]),c=!0),Ec(i)?{ok:!1,errors:[{line:0,message:"Полігон має самоперетин."}]}:{ok:!0,ring:i,wasClosedAutomatically:c}}function _c(o,t,n){return jo(o,"decimal",n,t)}function jo(o,t,n,r=1){return t==="decimal"?Cc(o,r,n):Uo(o,r,n)}function Cc(o,t,n){const r=[];if(/[A-Za-zА-Яа-яІіЇїЄєҐґ]/.test(o))return{ok:!1,errors:[{line:t,message:"У десятковому форматі не допускаються літери."}]};const l=o.split(/[\s,;]+/).filter(Boolean);if(l.length<2)return{ok:!1,errors:[{line:t,message:"Кожен рядок має містити дві координати."}]};if(l.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(!l.every(d=>xc.test(d)))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const a=Number(l[0]),s=Number(l[1]);if(!Number.isFinite(a)||!Number.isFinite(s))return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати десяткові координати."}]};const i=n==="lat-lon"?a:s,c=n==="lat-lon"?s:a;return(i<-90||i>90)&&r.push({line:t,message:"Широта поза діапазоном (-90..90)."}),(c<-180||c>180)&&r.push({line:t,message:"Довгота поза діапазоном (-180..180)."}),r.length?{ok:!1,errors:r}:{ok:!0,point:[c,i]}}function Uo(o,t,n){xn.lastIndex=0;const r=[...o.matchAll(xn)];if(r.length<2)return{ok:!1,errors:[{line:t,message:"Не вдалося розпізнати DMS-координати."}]};if(r.length>2)return{ok:!1,errors:[{line:t,message:"У рядку дозволено лише одну пару координат."}]};if(xn.lastIndex=0,o.replace(xn," ").replace(/[\s,;]+/g,"").trim().length)return{ok:!1,errors:[{line:t,message:"У рядку виявлено зайві символи або значення."}]};const a=Ho(r[0],t,n==="lat-lon"?"lat":"lon"),s=Ho(r[1],t,n==="lat-lon"?"lon":"lat"),i=[];if(a.ok||i.push(a.error),s.ok||i.push(s.error),i.length)return{ok:!1,errors:i};const c=n==="lat-lon"?a.value:s.value;return{ok:!0,point:[n==="lat-lon"?s.value:a.value,c]}}function Ho(o,t,n){const r=Number(o[1]),l=Number(o[2]),a=Number(o[3]),s=String(o[4]).toUpperCase();if(!Number.isFinite(r)||!Number.isFinite(l)||!Number.isFinite(a))return{ok:!1,error:{line:t,message:"Невірні значення DMS-координат."}};if(n==="lat"&&!(s==="N"||s==="S")||n==="lon"&&!(s==="E"||s==="W"))return{ok:!1,error:{line:t,message:n==="lat"?"Для широти напрям повинен бути N або S.":"Для довготи напрям повинен бути E або W."}};if(l<0||l>59)return{ok:!1,error:{line:t,message:"Хвилини повинні бути в діапазоні 0..59."}};if(a<0||a>60)return{ok:!1,error:{line:t,message:"Секунди повинні бути в діапазоні 0..60."}};const d=Math.abs(r),u=n==="lat"?90:180;if(d>u)return{ok:!1,error:{line:t,message:n==="lat"?"Градуси широти повинні бути в діапазоні 0..90.":"Градуси довготи повинні бути в діапазоні 0..180."}};if(d===u&&(l!==0||a!==0))return{ok:!1,error:{line:t,message:n==="lat"?"Для 90° широти хвилини й секунди мають бути 0.":"Для 180° довготи хвилини й секунди мають бути 0."}};const p=d+l/60+a/3600;return{ok:!0,value:s==="S"||s==="W"?-p:p}}function vc(o){return`${o[0].toFixed(12)}:${o[1].toFixed(12)}`}function qo(o,t){return Math.abs(o[0]-t[0])<Tt&&Math.abs(o[1]-t[1])<Tt}function Ec(o){if(o.length<4)return!1;for(let t=0;t<o.length-1;t+=1){const n=o[t],r=o[t+1];for(let l=t+1;l<o.length-1;l+=1){if(Math.abs(t-l)<=1||t===0&&l===o.length-2)continue;const a=o[l],s=o[l+1];if(Bc(n,r,a,s))return!0}}return!1}function Bc(o,t,n,r){const l=wn(o,t,n),a=wn(o,t,r),s=wn(n,r,o),i=wn(n,r,t);return!!(l!==a&&s!==i||l===0&&_n(o,n,t)||a===0&&_n(o,r,t)||s===0&&_n(n,o,r)||i===0&&_n(n,t,r))}function wn(o,t,n){const r=(t[1]-o[1])*(n[0]-t[0])-(t[0]-o[0])*(n[1]-t[1]);return Math.abs(r)<Tt?0:r>0?1:2}function _n(o,t,n){return t[0]<=Math.max(o[0],n[0])+Tt&&t[0]+Tt>=Math.min(o[0],n[0])&&t[1]<=Math.max(o[1],n[1])+Tt&&t[1]+Tt>=Math.min(o[1],n[1])}const Vc=["title"],Sc={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"},$c=["onClick"],Nc=["placeholder"],Ac={class:"absolute inset-y-0 right-2 flex items-center gap-1"},Fc={class:"flex items-center justify-between gap-2 px-3 py-2 border-b border-gray-100"},Mc={class:"text-xs font-semibold uppercase tracking-wide text-gray-500"},Dc={class:"max-h-[260px] overflow-auto"},Tc={key:0,class:"divide-y divide-gray-100"},Lc=["onClick"],Ic={key:1,class:"px-3 py-3 text-xs text-gray-500"},Ko="formMapSearchAddressHistory",Rc=12,Oc="https://geo.rv.ua/api-user/dzk.api",Pc="https://nominatim.openstreetmap.org/search",zc=xe(e.defineComponent({__name:"map-search",props:{config:{}},emits:["goToCoordinates"],setup(o,{emit:t}){const n={mounted(j,w){if(typeof document>"u")return;let A=null;const R=8,re=()=>{const Ae=String(w?.value??"");if(!Ae)return;A=document.createElement("div"),A.textContent=Ae,Object.assign(A.style,{position:"absolute",background:"#333",color:"#fff",padding:"4px 8px",borderRadius:"4px",fontSize:"12px",whiteSpace:"nowrap",pointerEvents:"none",zIndex:"9999"}),document.body.appendChild(A);const $e=j.getBoundingClientRect();A.style.left=`${$e.right+window.scrollX+R}px`,A.style.top=`${$e.top+window.scrollY+($e.height-A.offsetHeight)/2}px`},ge=()=>{A?.parentNode&&A.parentNode.removeChild(A),A=null};j.addEventListener("mouseenter",re),j.addEventListener("mouseleave",ge),Object.assign(j,{tooltipRightHandlers:{show:re,hide:ge}})},unmounted(j){if(typeof document>"u")return;const w=j.tooltipRightHandlers;w&&(j.removeEventListener("mouseenter",w.show),j.removeEventListener("mouseleave",w.hide))}},r=o,l=t,a=e.getCurrentInstance();function s(){return typeof globalThis<"u"&&globalThis.proxy?globalThis.proxy:typeof window<"u"&&window.proxy?window.proxy:null}function i(){const w=a?.appContext.config.globalProperties?.$settings?.map?.searchViewbox;if(w)return Array.isArray(w)?w.join(","):String(w);const R=s()?.map?.searchViewbox;if(R)return Array.isArray(R)?R.join(","):String(R)}function c(){const w=a?.appContext.config.globalProperties?.$settings?.map?.addressSuggest;if(typeof w=="string"&&w.trim())return w.trim();const R=s()?.map?.addressSuggest;if(typeof R=="string"&&R.trim())return R.trim()}function d(){if(typeof r.config?.cadastreSuggest=="string"&&r.config.cadastreSuggest.trim())return r.config.cadastreSuggest.trim();const j=a?.appContext.config.globalProperties?.$settings,w=j?.map?.cadastreSuggest??j?.map?.parcelSuggest??j?.map?.parcelSearch;if(typeof w=="string"&&w.trim())return w.trim();const A=s(),R=A?.map?.cadastreSuggest??A?.map?.parcelSuggest??A?.map?.parcelSearch;if(typeof R=="string"&&R.trim())return R.trim()}const u=!!c(),p=!!i(),y=e.computed(()=>{const j=["nominatim","xy","parcel"];return u&&j.unshift("address"),p?j:j.filter(w=>w!=="nominatim")}),k=e.computed(()=>{const j=y.value,w=r.config?.tools?.filter(A=>j.includes(A));return w&&w.length?w:j}),m=e.computed(()=>r.config?.placeholder?.trim()||"Пошук…"),h=e.ref(k.value[0]);e.watch(k,j=>{j.includes(h.value)||(h.value=j[0])});const b=e.ref(""),_=e.ref(!1),x=e.ref(null),v=e.ref(null),N=e.ref(null),U=e.ref(null),W=e.ref([]),L=e.ref(null),B=e.ref(!1),S=e.ref([]),$=e.computed(()=>(h.value==="address"||h.value==="nominatim")&&B.value),V=e.computed(()=>r.config?.addressDebounceMs??1e3);let M=null;const O=e.ref(!1),E=e.computed(()=>b.value.trim().length>0?W.value:S.value),K=e.computed(()=>b.value.trim().length?`Знайдено ${W.value.length}`:"Історія пошуку"),T=e.computed(()=>b.value.trim().length?"Нічого не знайдено":"Історія порожня");function Y(){if(typeof window>"u")return[];try{const j=window.localStorage?.getItem?.(Ko);if(!j)return[];const w=JSON.parse(j);return Array.isArray(w)?w:[]}catch{return[]}}function I(j){typeof window>"u"||window.localStorage?.setItem?.(Ko,JSON.stringify(j))}function X(j){const A=[j,...S.value.filter(R=>R.id!==j.id)].slice(0,10);S.value=A,I(A)}const Q=e.reactive({position:"absolute",left:"0px",top:"0px",width:"100%",display:"none"});function ke(){if(!U.value)return;const j=U.value.getBoundingClientRect(),w=N.value?.getBoundingClientRect(),A=w?.width??j.width,R=(w?.left??j.left)+window.scrollX,re=j.bottom+window.scrollY+Rc;Q.left=`${R}px`,Q.top=`${re}px`,Q.width=`${A}px`,Q.display="block"}const he=()=>{$.value&&ke()};function J(){M&&(clearTimeout(M),M=null)}e.watch(h,()=>{b.value="",_.value=!1,W.value=[],B.value=!1,J(),O.value=!1}),e.watch($,j=>{j?e.nextTick(()=>{ke()}):Q.display="none"}),e.watch(b,j=>{if(h.value!=="address"&&h.value!=="nominatim"){W.value=[],J();return}if(!j.trim()){W.value=[],B.value=S.value.length>0,J();return}J(),B.value=!0,M=window.setTimeout(()=>{te(j).catch(w=>{const A=w?.message||"Помилка пошуку адреси";pe.notify({type:"error",title:"Пошук адреси",message:A})})},V.value)});function me(j){const w=[];v.value&&w.push(v.value),j instanceof HTMLElement&&w.push(j),x.value?.querySelectorAll("li")?.forEach(R=>{w.push(R)}),w.forEach(R=>{R.dispatchEvent(new MouseEvent("mouseleave",{bubbles:!0}))})}function de(j){_.value&&me(j.target),_.value=!_.value}function ne(j,w){me(w?.target),h.value=j}function ae(){b.value="",W.value=[],B.value=!1,O.value=!1}function fe(j){const w=j.target;if(_.value){const A=x.value;A&&!A.contains(w)&&(me(w),_.value=!1)}if($.value){const A=L.value,R=U.value;A&&!A.contains(w)&&(!R||!R.contains(w))&&(B.value=!1)}}e.onMounted(()=>{S.value=Y(),window.addEventListener("click",fe,!0),window.addEventListener("scroll",he,!0),window.addEventListener("resize",he)}),e.onBeforeUnmount(()=>{window.removeEventListener("click",fe,!0),window.removeEventListener("scroll",he,!0),window.removeEventListener("resize",he),J()});function Se(j){return j==="xy"?"Координати":j==="parcel"?"Кадастр":j==="nominatim"?"Адреса":"Адресний"}function Ve(j){switch(j){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 Oe(j){const w=jo(j.trim(),"dms","lat-lon");if(w.ok){const[Fe,lt]=w.point;return{lat:lt,lng:Fe}}const A=j.replace(/[,]+/g," ").trim();if(!A)return null;const R=A.split(/\s+/).filter(Boolean);if(R.length<2)return null;const re=R.slice(0,2).map(Number);if(!re.every(Fe=>Number.isFinite(Fe)))return null;let[ge,Ae]=re,$e=ge,We=Ae;const rt=Fe=>Math.abs(Fe)<=90,pt=Fe=>Math.abs(Fe)<=180;if(!rt($e)||!pt(We))if(rt(We)&&pt($e))$e=Ae,We=ge;else return null;return{lat:$e,lng:We}}function Te(j){const w=j?.result||j?.data||j;return(Array.isArray(w)?w:w?[w]:[]).map((R,re)=>{const ge=R?.geom_centroid,Ae=Array.isArray(ge?.coordinates)?ge.coordinates:null;if(!Ae||Ae.length<2)return null;const $e=Number(Ae[0]),We=Number(Ae[1]);return!Number.isFinite(We)||!Number.isFinite($e)?null:{id:String(R?.parcel_id??R?.cad_num??re),title:R?.cadnum||R?.cad_num||"Земельна ділянка",lat:We,lng:$e}}).filter(R=>!!R)}function Ne(j){return(Array.isArray(j?.features)?j.features:[]).map((A,R)=>{const re=A?.geometry?.coordinates,ge=Number(re?.[0]),Ae=Number(re?.[1]);if(!Number.isFinite(Ae)||!Number.isFinite(ge))return null;const $e=A?.properties||{},We=$e?.geocoding?.label||$e?.display_name||$e?.label||"Адреса";return{id:String($e?.geocoding?.place_id||$e?.place_id||R),title:We,lat:Ae,lng:ge}}).filter(A=>!!A)}function Ce(j){return Number.isFinite(j.lat)&&Number.isFinite(j.lng)}function Ee(j){if(j==null||typeof j=="string"&&!j.trim())return null;const w=Number(j);return Number.isFinite(w)?w:null}function Pe(j){const w=Ee(j.lng)??Ee(j.lon)??Ee(j.longitude)??Ee(j.x),A=Ee(j.lat)??Ee(j.latitude)??Ee(j.y);if(w!=null&&A!=null)return{lat:A,lng:w};const R=j?.geometry?.coordinates??j?.geom_centroid?.coordinates??j?.centroid?.coordinates??j?.geojson?.geometry?.coordinates??j?.geom?.coordinates;if(Array.isArray(R)&&R.length>=2){const re=Ee(R[0]),ge=Ee(R[1]);if(re!=null&&ge!=null)return{lat:ge,lng:re}}return null}function Me(j){return(Array.isArray(j?.data)?j.data:[]).map((A,R)=>{const re=Pe(A),ge=String(A.text??A.title??A.label??A.name??A.address??A.display_name??A.id??"Адреса"),Ae=String(A.id??A.code??A.value??R);return re?{id:Ae,title:ge,...re}:{id:Ae,title:ge}}).filter(A=>!!A?.title)}function ze(j){const w=d()||Oc;if(w.includes(":id"))return w.replace(":id",encodeURIComponent(j));if(w.includes(":name"))return w.replace(":name",encodeURIComponent(j));try{const A=new URL(w,window.location.origin),R=r.config?.parcelQueryParam?.trim()||"cad_num";return A.searchParams.set(R,j),A.toString()}catch{return w}}function Ye(j){const w=c();if(!w)return null;if(w.includes(":name"))return w.replace(":name",encodeURIComponent(j));try{const A=new URL(w,window.location.origin);return j.trim()&&A.searchParams.set("q",j),A.toString()}catch{return w}}async function H(j){const w=Ye(j);if(!w)return[];const A=await fetch(w);if(!A.ok)throw new Error(`HTTP ${A.status}`);const R=await A.json();return Me(R)}async function Z(j){const w=new URL(Pc);w.searchParams.set("format","geojson"),w.searchParams.set("q",j),w.searchParams.set("addressdetails","1"),w.searchParams.set("bounded","1");const A=i();A&&w.searchParams.set("viewbox",A);const R=await fetch(w.toString());if(!R.ok)throw new Error(`HTTP ${R.status}`);const re=await R.json();return Ne(re)}async function te(j){if(W.value=[],J(),h.value==="address"){if(!c()){pe.notify({type:"warning",title:"Пошук адреси",message:"Не налаштовано addressSuggest"});return}const R=await H(j);if(!R.length){pe.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}W.value=R;return}const w=await Z(j);if(!w.length){pe.notify({type:"warning",title:"Пошук адреси",message:"Не знайдено результатів"});return}W.value=w}async function ce(j){if(Ce(j)){_e(j),X(j);return}pe.notify({type:"warning",title:"Пошук адреси",message:"Геометрія для обраної адреси відсутня"})}function z(){h.value!=="address"&&h.value!=="nominatim"||(B.value=!0,e.nextTick(()=>{ke()}))}function oe(j){const A=j.replace(/\s+/g,"").split(":");if(A.length!==4)return!1;const R=[10,2,3,4];return A.every((re,ge)=>re.length===R[ge]&&/^\d+$/.test(re))}function _e(j){l("goToCoordinates",[j.lat,j.lng]),O.value=!0}async function ve(){const j=b.value.trim();if(j){if(h.value==="xy"){const w=Oe(j);if(!w){pe.notify({type:"warning",title:"Пошук координат",message:"Використайте `lat lon` або DMS у форматі `50°27'00\"N 30°31'24\"E`."});return}_e(w);return}if(h.value==="address"||h.value==="nominatim"){try{await te(j)}catch(w){const A=w?.message||"Помилка пошуку адреси";pe.notify({type:"error",title:"Пошук адреси",message:A})}return}try{if(!oe(j)){pe.notify({type:"warning",title:"Пошук кадастру",message:"Кадастровий номер має формат ХХХХХХХХХХ:ХХ:ХХХ:ХХХХ"});return}const w=await fetch(ze(j));if(!w.ok)throw new Error(`HTTP ${w.status}`);const A=await w.json(),R=Te(A);if(!R.length)pe.notify({type:"warning",title:"Пошук",message:"Не знайдено результатів"});else{const re=R.find(Ce);if(!re){pe.notify({type:"warning",title:"Пошук",message:"Геометрія ділянки відсутня"});return}_e(re)}}catch(w){const A=w?.message||"Помилка пошуку";pe.notify({type:"error",title:"Пошук",message:A})}}}return(j,w)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"widgetRef",ref:N,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(ve,["prevent"])},[k.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:de},[e.withDirectives((e.openBlock(),e.createElementBlock("span",{ref_key:"selectedToolLabelRef",ref:v,class:"block w-full truncate",title:Se(h.value)},[e.createTextVNode(e.toDisplayString(Se(h.value)),1)],8,Vc)),[[n,Ve(h.value)]]),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["w-4 h-4 text-gray-500 transition-transform",{"rotate-180":_.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))]),_.value?(e.openBlock(),e.createElementBlock("div",Sc,[e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,A=>e.withDirectives((e.openBlock(),e.createElementBlock("li",{key:A,class:"px-3 py-2 cursor-pointer hover:bg-gray-100 text-gray-900",onClick:R=>ne(A,R)},[e.createTextVNode(e.toDisplayString(Se(A)),1)],8,$c)),[[n,Ve(A)]])),128))])])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),e.createElementVNode("div",{ref_key:"searchWrapperRef",ref:U,class:"relative flex-1 min-w-[140px]"},[h.value==="parcel"?(e.openBlock(),e.createBlock(mn,{key:0,modelValue:b.value,"onUpdate:modelValue":w[0]||(w[0]=A=>b.value=A),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",O.value?"!pr-14":"!pr-8"])},null,8,["modelValue","class"])):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:1,"onUpdate:modelValue":w[1]||(w[1]=A=>b.value=A),placeholder:m.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",O.value?"!pr-14":"!pr-8"]),onFocus:z},null,42,Nc)),[[e.vModelText,b.value,void 0,{trim:!0}]]),e.createElementVNode("div",Ac,[O.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"flex items-center text-gray-400 hover:text-gray-600","aria-label":"Очистити",onClick:ae},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(Q)},[e.createElementVNode("div",Fc,[e.createElementVNode("span",Mc,e.toDisplayString(K.value),1),e.createElementVNode("button",{type:"button",class:"text-gray-400 hover:text-gray-600","aria-label":"Закрити",onClick:w[2]||(w[2]=A=>B.value=!1)}," ✕ ")]),e.createElementVNode("div",Dc,[E.value.length?(e.openBlock(),e.createElementBlock("ul",Tc,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,A=>(e.openBlock(),e.createElementBlock("li",{key:A.id,class:"px-3 py-2 cursor-pointer hover:bg-gray-50",onClick:R=>ce(A)},e.toDisplayString(A.title),9,Lc))),128))])):(e.openBlock(),e.createElementBlock("div",Ic,e.toDisplayString(T.value),1))])],4)])):e.createCommentVNode("",!0)],512)],32)],512))}}),[["__scopeId","data-v-4d528cf7"]]),jc={class:"pt-1 border-t border-gray-100"},Uc={class:"space-y-1"},Hc=e.defineComponent({__name:"AddCoordinates",emits:["submit","cancel"],setup(o,{emit:t}){const n=t,r=e.ref(null),l=e.ref(null),a=(c,d,u)=>Math.min(Math.max(c,d),u),s=()=>{if(r.value===null||l.value===null||!Number.isFinite(r.value)||!Number.isFinite(l.value))return;const c=a(r.value,-90,90),d=a(l.value,-180,180);n("submit",{lat:c,lng:d}),r.value=null,l.value=null},i=()=>{r.value=null,l.value=null,n("cancel")};return(c,d)=>(e.openBlock(),e.createElementBlock("div",jc,[d[2]||(d[2]=e.createElementVNode("p",{class:"text-xs text-gray-600 mb-1"},"Додати точку за координатами:",-1)),e.createElementVNode("div",Uc,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[0]||(d[0]=u=>r.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта (50.4501)"},null,512),[[e.vModelText,r.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":d[1]||(d[1]=u=>l.value=u),type:"number",step:"0.0001",class:"w-full px-2 py-1 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота (30.5234)"},null,512),[[e.vModelText,l.value,void 0,{number:!0}]]),e.createElementVNode("div",{class:"flex gap-1.5"},[e.createElementVNode("button",{class:"flex-1 px-2 py-1 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors",type:"button",onClick:s}," Додати "),e.createElementVNode("button",{class:"px-2 py-1 bg-gray-200 hover:bg-gray-300 text-gray-700 text-xs font-medium rounded transition-colors",type:"button",onClick:i}," Скасувати ")])])]))}}),qc=e.defineComponent({__name:"BtnAdd",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Plus),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Додати ",-1))]))}}),Kc=e.defineComponent({__name:"BtnClear",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"w-full px-2 py-1.5 bg-rose-500 hover:bg-rose-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Trash2),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode(" Очистити ",-1))]))}}),Wc=e.defineComponent({__name:"BtnComplete",emits:["click"],setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("button",{class:"flex-1 px-2 py-1.5 bg-emerald-500 hover:bg-emerald-600 text-white text-xs font-medium rounded transition-colors duration-150 flex items-center justify-center gap-1",onClick:n[0]||(n[0]=r=>t.$emit("click"))},[e.createVNode(e.unref(q.Circle),{size:12,"stroke-width":2}),n[1]||(n[1]=e.createTextVNode("Замкнути ",-1))]))}}),Gc=new Intl.NumberFormat("uk-UA",{minimumFractionDigits:2,maximumFractionDigits:2});function Lt(o){return Gc.format(o)}function Wo(o){return o>=1e3?`${Lt(o/1e3)} км`:`${Lt(o)} м`}const Yc={class:"flex items-center gap-1.5 text-xs bg-gray-50 rounded p-1.5"},Xc={key:0,class:"flex-1 flex gap-1"},Zc={key:1,class:"flex-1 font-mono text-gray-700"},Jc=e.defineComponent({__name:"DotListItem",props:{id:{},index:{},coords:{}},emits:["update","delete"],setup(o,{emit:t}){const n=o,r=t,l=e.computed(()=>`${n.coords.lat.toFixed(4)}°, ${n.coords.lng.toFixed(4)}°`),a=e.ref(!1),s=e.ref(n.coords.lat),i=e.ref(n.coords.lng);e.watch(()=>n.coords,y=>{s.value=y.lat,i.value=y.lng},{deep:!0,immediate:!0});const c=(y,k,m)=>Math.min(Math.max(y,k),m),d=()=>{a.value=!0},u=()=>{if(!Number.isFinite(s.value)||!Number.isFinite(i.value))return;const y=c(s.value,-90,90),k=c(i.value,-180,180);r("update",{id:n.id,coords:{lat:y,lng:k}}),a.value=!1},p=()=>{r("delete",n.id)};return(y,k)=>(e.openBlock(),e.createElementBlock("div",Yc,[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",Xc,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":k[0]||(k[0]=m=>s.value=m),type:"number",step:"0.0001",min:"-90",max:"90",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Широта"},null,512),[[e.vModelText,s.value,void 0,{number:!0}]]),e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":k[1]||(k[1]=m=>i.value=m),type:"number",step:"0.0001",min:"-180",max:"180",class:"flex-1 px-1.5 py-0.5 text-xs border border-gray-300 rounded focus:outline-none focus:border-blue-500",placeholder:"Довгота"},null,512),[[e.vModelText,i.value,void 0,{number:!0}]]),e.createElementVNode("button",{class:"px-1.5 py-0.5 bg-emerald-500 text-white rounded hover:bg-emerald-600 text-xs",type:"button",onClick:u}," ✓ ")])):(e.openBlock(),e.createElementBlock("span",Zc,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}," ✕ ")]))}}),Qc={class:"ruler-control px-3 py-2.5 space-y-2"},ed={type:"button",class:"ruler-row w-full flex items-center gap-2 cursor-pointer group text-left"},td={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"},nd={class:"text-sm font-semibold text-slate-700"},od={class:"ruler-row"},rd={type:"button",class:"w-full flex items-center gap-2 cursor-pointer group text-left"},ld={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"},ad={class:"inline-flex rounded-md overflow-hidden border border-gray-200 bg-gray-100"},sd=["onClick"],id={class:"flex items-center gap-2 mt-0.5 pl-7"},cd={key:0,class:"text-base font-semibold text-green-600"},dd={key:1,class:"text-xs text-gray-400"},ud={class:"ruler-row flex items-center gap-2 cursor-pointer"},pd={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"},fd={class:"text-xs font-medium text-gray-600 flex-1"},md={key:0,class:"pt-1.5 border-t border-gray-100 max-h-32 overflow-y-auto space-y-1"},hd=e.defineComponent({__name:"ControlPanel",props:{points:{},isShapeClosed:{type:Boolean}},emits:["update-point","delete-point"],setup(o){const t=o,n=e.ref(!1),r=e.ref("km2"),l=[{id:"km2",label:"км²"},{id:"ha",label:"га"},{id:"m2",label:"м²"}],a=()=>{n.value=!n.value},s=(m,h)=>{const b=S=>S*Math.PI/180,_=b(h.lat-m.lat),x=b(h.lng-m.lng),v=b(m.lat),N=b(h.lat),U=Math.sin(_/2),W=Math.sin(x/2);return 6371e3*(2*Math.asin(Math.sqrt(U*U+Math.cos(v)*Math.cos(N)*W*W)))},i=e.computed(()=>{if(t.points.length<2)return 0;let m=0;for(let h=1;h<t.points.length;h+=1)m+=s(t.points[h-1].coords,t.points[h].coords);return t.isShapeClosed&&t.points.length>=2&&(m+=s(t.points[t.points.length-1].coords,t.points[0].coords)),m}),c=e.computed(()=>i.value>=1e3?`${Lt(i.value/1e3)} км`:`${Lt(i.value)} м`);function d(m){if(m.length<3)return 0;const h=m[0].lat,b=m[0].lng,_=(v,N)=>{const U=(v-h)*110574;return{x:(N-b)*111320*Math.cos(h*Math.PI/180),y:U}};let x=0;for(let v=0;v<m.length;v++){const N=(v+1)%m.length,U=_(m[v].lat,m[v].lng),W=_(m[N].lat,m[N].lng);x+=U.x*W.y-U.y*W.x}return Math.abs(x)*.5}const u=e.computed(()=>{if(!t.isShapeClosed||t.points.length<3)return 0;const m=t.points.map(h=>h.coords);return d(m)}),p=e.computed(()=>u.value>0),y=e.computed(()=>{const m=u.value;if(m===0)return"—";if(r.value==="km2"){const b=m/1e6;return`${Lt(b)} км²`}if(r.value==="ha"){const b=m/1e4;return`${Lt(b)} га`}const h=m>=1?Math.round(m):m;return`${Lt(h)} м²`}),k=e.computed(()=>{const m=t.points.length;return m===1?"1 точка":m>=2&&m<=4?`${m} точки`:`${m} точок`});return e.watch(()=>t.points.length,()=>{t.points.length===0&&(n.value=!1)}),(m,h)=>(e.openBlock(),e.createElementBlock("div",Qc,[e.createElementVNode("button",ed,[e.createElementVNode("span",td,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),h[1]||(h[1]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Загальна відстань",-1)),e.createElementVNode("span",nd,e.toDisplayString(c.value),1)]),e.createElementVNode("div",od,[e.createElementVNode("button",rd,[e.createElementVNode("span",ld,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),h[2]||(h[2]=e.createElementVNode("span",{class:"text-xs font-medium text-gray-600 flex-1"},"Площа",-1)),e.createElementVNode("div",ad,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(l,(b,_)=>e.createElementVNode("button",{key:b.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",_===0&&"rounded-l-md",_===l.length-1&&"rounded-r-md",r.value===b.id?"bg-white text-green-600 font-semibold shadow-sm":"text-gray-600 hover:bg-gray-50"]),onClick:e.withModifiers(x=>r.value=b.id,["stop"])},e.toDisplayString(b.label),11,sd)),64))])]),e.createElementVNode("div",id,[p.value?(e.openBlock(),e.createElementBlock("span",cd,e.toDisplayString(y.value),1)):(e.openBlock(),e.createElementBlock("span",dd,"—"))])]),e.createElementVNode("div",ud,[e.createElementVNode("span",pd,[e.createVNode(e.unref(q.Info),{size:12,"stroke-width":2.5})]),e.createElementVNode("span",fd,e.toDisplayString(k.value),1),e.createElementVNode("button",{type:"button",class:"text-xs text-blue-500 hover:text-blue-600 font-medium transition-colors",onClick:e.withModifiers(a,["stop"])}," Координати ")]),n.value?(e.openBlock(),e.createElementBlock("div",md,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.points,(b,_)=>(e.openBlock(),e.createBlock(Jc,{key:b.id,id:b.id,index:_+1,coords:b.coords,onUpdate:h[0]||(h[0]=x=>m.$emit("update-point",x)),onDelete:x=>m.$emit("delete-point",b.id)},null,8,["id","index","coords","onDelete"]))),128))])):e.createCommentVNode("",!0)]))}}),gd={class:"px-3 py-3 bg-blue-50/50 border-b border-blue-100"},yd={class:"flex items-start gap-2"},bd=e.defineComponent({__name:"InfoHint",setup(o){return(t,n)=>(e.openBlock(),e.createElementBlock("div",gd,[e.createElementVNode("div",yd,[e.createVNode(e.unref(q.Info),{size:16,"stroke-width":2,class:"text-blue-600 flex-shrink-0 mt-0.5"}),n[0]||(n[0]=e.createElementVNode("div",{class:"space-y-1"},[e.createElementVNode("p",{class:"text-xs font-medium text-blue-900"}," Натискайте на карту, щоб додати точки вимірювання "),e.createElementVNode("p",{class:"text-[10px] text-blue-700"},' Або скористайтесь кнопкою "Додати" внизу для введення координат вручну ')],-1))])]))}}),kd={class:"space-y-1.5"},xd={class:"space-y-1 max-h-40 overflow-y-auto"},wd={class:"text-gray-700"},_d={class:"font-semibold text-slate-800"},Cd=e.defineComponent({__name:"ToPointList",props:{points:{},isShapeClosed:{type:Boolean}},setup(o){const t=o;function n(a,s){const i=k=>k*Math.PI/180,c=i(s.lat-a.lat),d=i(s.lng-a.lng),u=i(a.lat),p=i(s.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(c/2)**2+Math.cos(u)*Math.cos(p)*Math.sin(d/2)**2)))}function r(a){return Wo(a)}const l=e.computed(()=>{const a=[],s=t.points;if(s.length<2)return a;for(let i=0;i<s.length;i++){const c=i===s.length-1&&t.isShapeClosed?0:i+1;if(c>=s.length)break;const d=n(s[i].coords,s[c].coords);a.push({from:i+1,to:c+1,label:r(d)})}return a});return(a,s)=>(e.openBlock(),e.createElementBlock("div",kd,[s[0]||(s[0]=e.createElementVNode("p",{class:"text-xs font-medium text-gray-600 mb-1.5"},"Відстань між точками:",-1)),e.createElementVNode("div",xd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(i,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"flex items-center justify-between text-xs py-1 px-2 rounded bg-gray-50"},[e.createElementVNode("span",wd,"Точка "+e.toDisplayString(i.from)+" → Точка "+e.toDisplayString(i.to),1),e.createElementVNode("span",_d,e.toDisplayString(i.label),1)]))),128))])]))}}),vd={class:"ruler-panel-wrap absolute bottom-12 right-4 z-[1001] animate-slide-up"},Ed={class:"bg-white rounded-xl shadow-2xl border border-gray-200 overflow-hidden w-72"},Bd={class:"bg-gradient-to-r from-blue-400 to-blue-500 px-3 py-2 flex items-center justify-between"},Vd={class:"flex items-center gap-2"},Sd={class:"w-6 h-6 bg-white/20 rounded-lg flex items-center justify-center"},$d={class:"flex border-b border-gray-200"},Nd={key:1,class:"px-3 py-2.5"},Ad={key:1,class:"text-xs text-gray-500"},Fd={class:"px-2.5 py-1.5 bg-gray-50 border-t border-gray-200 space-y-1.5"},Md={class:"flex gap-1.5"},Dd=e.defineComponent({name:"RulerPanel",__name:"RulerPanel",emits:["close","tab-change","points-change","add-request","complete","shape-closed-change"],setup(o,{expose:t,emit:n}){const r=n,l=e.ref([]),a=e.computed(()=>l.value.length>0),s=e.ref(!1),i=e.ref(!1),c=e.ref("general");function d($){c.value=$,r("tab-change",$)}e.onMounted(()=>{r("tab-change",c.value)});const u=e.computed(()=>l.value.length>=3&&!i.value);let p=1;const y=()=>l.value.map($=>({id:$.id,coords:{...$.coords}})),k=()=>{l.value.length<3&&i.value&&(i.value=!1,r("shape-closed-change",!1)),r("points-change",y())},m=()=>{const $=p;return p+=1,$},h=$=>{l.value=[...l.value,{id:m(),coords:{lat:$.lat,lng:$.lng}}],k()},b=({id:$,coords:V})=>{const M=l.value.findIndex(E=>E.id===$);if(M===-1)return;const O=[...l.value];O[M]={id:$,coords:{...V}},l.value=O,k()},_=$=>{l.value=l.value.filter(V=>V.id!==$),k()},x=()=>{l.value=[],i.value&&(i.value=!1,r("shape-closed-change",!1)),k()},v=$=>{b($)},N=$=>{_($)},U=()=>{s.value=!0,r("add-request")},W=$=>{h($),s.value=!1},L=()=>{s.value=!1},B=()=>{u.value&&(i.value=!0,r("complete"),r("shape-closed-change",!0))},S=()=>{x(),s.value=!1,r("close")};return t({addPoint:h,clearPoints:x}),($,V)=>(e.openBlock(),e.createElementBlock("div",vd,[e.createElementVNode("div",Ed,[e.createElementVNode("div",Bd,[e.createElementVNode("div",Vd,[e.createElementVNode("div",Sd,[e.createVNode(e.unref(q.Ruler),{size:14,"stroke-width":2,class:"text-white"})]),V[2]||(V[2]=e.createElementVNode("h3",{class:"text-white font-semibold text-xs"},"Вимірювання",-1))]),e.createElementVNode("button",{class:"w-5 h-5 flex items-center justify-center rounded hover:bg-white/20 transition-colors","aria-label":"Закрити",onClick:S},[e.createVNode(e.unref(q.X),{size:14,"stroke-width":2,class:"text-white"})])]),e.createElementVNode("div",$d,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="general"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:V[0]||(V[0]=M=>d("general"))}," Загальна ",2),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["flex-1 px-3 py-2 text-xs font-medium transition-colors",c.value==="topoint"?"text-blue-600 border-b-2 border-blue-500 bg-blue-50/50":"text-gray-500 hover:text-gray-700"]),onClick:V[1]||(V[1]=M=>d("topoint"))}," До точки ",2)]),c.value==="general"?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[a.value?(e.openBlock(),e.createBlock(hd,{key:1,points:l.value,"is-shape-closed":i.value,onUpdatePoint:v,onDeletePoint:N},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createBlock(bd,{key:0}))],64)):(e.openBlock(),e.createElementBlock("div",Nd,[a.value?(e.openBlock(),e.createBlock(Cd,{key:0,points:l.value,"is-shape-closed":i.value},null,8,["points","is-shape-closed"])):(e.openBlock(),e.createElementBlock("p",Ad,"Додайте точки на карті, щоб бачити відстані між ними."))])),e.createElementVNode("div",Fd,[e.createElementVNode("div",Md,[s.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(qc,{key:0,onClick:U})),u.value?(e.openBlock(),e.createBlock(Wc,{key:1,onClick:B})):e.createCommentVNode("",!0)]),s.value?(e.openBlock(),e.createBlock(Hc,{key:0,onSubmit:W,onCancel:L})):e.createCommentVNode("",!0),a.value?(e.openBlock(),e.createBlock(Kc,{key:1,onClick:x})):e.createCommentVNode("",!0)])])]))}}),Xe="ruler-points",wt="ruler-line",_t="ruler-polygon",Ct="ruler-segments",Td=e.defineComponent({__name:"RulerLayer",props:{map:{},points:{},isShapeClosed:{type:Boolean},labelMode:{}},setup(o){function t(m,h){const b=W=>W*Math.PI/180,_=b(h.lat-m.lat),x=b(h.lng-m.lng),v=b(m.lat),N=b(h.lat);return 6371e3*(2*Math.asin(Math.sqrt(Math.sin(_/2)**2+Math.cos(v)*Math.cos(N)*Math.sin(x/2)**2)))}function n(m){return Wo(m)}const r=o;function l(){return{type:"FeatureCollection",features:[]}}function a(m,h,b){const _=b??"general",x=[];let v=0;x.push(0);for(let N=1;N<m.length;N++)v+=t(m[N-1].coords,m[N].coords),x.push(v);return h&&m.length>=2&&(v+=t(m[m.length-1].coords,m[0].coords)),{type:"FeatureCollection",features:m.map((N,U)=>{const W=_==="general"?U===0?"0":n(x[U]):U===0?"0":n(t(m[U-1].coords,m[U].coords));return{type:"Feature",geometry:{type:"Point",coordinates:[N.coords.lng,N.coords.lat]},properties:{id:N.id,index:U+1,label:W}}})}}function s(m,h){if(m.length<2)return l();const b=[];for(let _=0;_<m.length;_++){const x=_===m.length-1&&h?0:_+1;if(x>=m.length)break;const v=m[_].coords,N=m[x].coords,U=t(v,N);b.push({type:"Feature",geometry:{type:"LineString",coordinates:[[v.lng,v.lat],[N.lng,N.lat]]},properties:{distance:n(U)}})}return{type:"FeatureCollection",features:b}}function i(m,h){if(m.length<2)return l();const b=m.map(_=>[_.coords.lng,_.coords.lat]);return h&&b.push(b[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"LineString",coordinates:b},properties:{}}]}}function c(m){if(m.length<3)return l();const h=m.map(b=>[b.coords.lng,b.coords.lat]);return h.push(h[0]),{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Polygon",coordinates:[h]},properties:{}}]}}let d=!1;function u(m){m.getSource(Xe)||(m.addSource(Xe,{type:"geojson",data:l()}),m.addLayer({id:`${Xe}-circle`,type:"circle",source:Xe,paint:{"circle-radius":5,"circle-color":"#1e293b","circle-stroke-width":2,"circle-stroke-color":"#ffffff"}}),m.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}})),m.getSource(Ct)||(m.addSource(Ct,{type:"geojson",data:l()}),m.addLayer({id:`${Ct}-labels`,type:"symbol",source:Ct,layout:{"text-field":["get","distance"],"text-size":13,"symbol-placement":"line-center","text-rotation-alignment":"map","text-pitch-alignment":"map"},paint:{"text-color":"#1e293b","text-halo-color":"#ffffff","text-halo-width":1.5}})),m.getSource(wt)||(m.addSource(wt,{type:"geojson",data:l()}),m.addLayer({id:`${wt}-layer`,type:"line",source:wt,paint:{"line-color":"#3b82f6","line-width":2}})),m.getSource(_t)||(m.addSource(_t,{type:"geojson",data:l()}),m.addLayer({id:`${_t}-layer`,type:"fill",source:_t,paint:{"fill-color":"#93c5fd","fill-opacity":.25}})),d=!0}function p(m){if(m){try{m.getLayer(`${_t}-layer`)&&m.removeLayer(`${_t}-layer`),m.getSource(_t)&&m.removeSource(_t),m.getLayer(`${wt}-layer`)&&m.removeLayer(`${wt}-layer`),m.getSource(wt)&&m.removeSource(wt),m.getLayer(`${Ct}-labels`)&&m.removeLayer(`${Ct}-labels`),m.getSource(Ct)&&m.removeSource(Ct),m.getLayer(`${Xe}-labels`)&&m.removeLayer(`${Xe}-labels`),m.getLayer(`${Xe}-circle`)&&m.removeLayer(`${Xe}-circle`),m.getSource(Xe)&&m.removeSource(Xe)}catch{}d=!1}}function y(m){if(!m)return;const h=m.getSource(Xe),b=m.getSource(wt),_=m.getSource(_t),x=m.getSource(Ct),v=r.points,N=r.labelMode??"general";h&&h.setData(a(v,r.isShapeClosed,N)),b&&b.setData(i(v,r.isShapeClosed)),_&&_.setData(c(v)),x&&x.setData(N==="topoint"?s(v,r.isShapeClosed):l())}function k(){const m=r.map;m&&(d||u(m),y(m))}return e.watch(()=>[r.points,r.isShapeClosed,r.labelMode],()=>k(),{deep:!0,immediate:!0}),e.watch(()=>r.map,()=>k(),{immediate:!0}),e.onBeforeUnmount(()=>{p(r.map)}),(m,h)=>null}});function Ld(o={}){const t=e.ref(!1),n=e.ref([]),r=e.ref(!1),l=e.ref("general"),a=e.ref(null);function s(){t.value?i():(t.value=!0,o.onActivate?.())}function i(){t.value=!1,n.value=[],r.value=!1,a.value?.clearPoints(),o.onDeactivate?.()}function c(k){n.value=k}function d(k){l.value=k}function u(k){r.value=k}function p(k){t.value&&a.value?.addPoint({lat:k.lat,lng:k.lng})}const y=e.computed(()=>n.value.length>0);return{isRulerActive:t,rulerPoints:n,rulerShapeClosed:r,rulerActiveTab:l,rulerPanelRef:a,hasRulerPoints:y,toggleRuler:s,closeRuler:i,onRulerPointsChange:c,onRulerTabChange:d,onRulerShapeClosedChange:u,handleRulerMapClick:p}}const Id={key:0,class:"absolute top-4 left-4 z-[1000] w-[calc(100%-20px)] sm:w-[350px]"},Rd={key:1,class:"form-geom__panel flex gap-1 items-start mt-2"},Od={class:"flex items-center gap-1"},Pd=["disabled"],zd={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"},jd=["disabled"],Ud=["disabled"],Hd={class:"mt-4 flex justify-end gap-2"},qd=["disabled"],Kd={class:"absolute top-4 right-4 z-[1000]"},Wd={class:"flex flex-col gap-[2px]"},Gd=["disabled"],Yd=["disabled"],Xd=["disabled"],Zd=["disabled"],Jd={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"},Qd={class:"space-y-0.5"},eu={class:"text-gray-500"},tu={class:"text-gray-900 text-right break-all"},nu={class:"absolute left-4 bottom-[36px] z-[1000]"},ou={class:"flex flex-col gap-2"},ru={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]"},lu={class:"flex flex-col gap-1"},au=["checked","disabled","onChange"],su={class:"text-gray-700 text-xs font-medium"},iu={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"},cu={key:0,class:"form-geom__feature flex items-center text-xs transition-all gap-2 w-full px-2 pb-1"},du={class:"mr-auto flex items-center gap-2 min-w-0 relative"},uu={class:"shrink-0"},pu={key:0,class:"font-bold"},fu=["onClick","disabled"],mu={key:0},hu={class:"flex items-center"},gu={class:"text-xs mr-2"},yu={key:0},bu={key:1},ku={key:0,class:"text-xs mr-2"},xu={key:1,class:"text-xs mr-2"},wu=["disabled"],_u=["disabled"],Cn="__vs_form_maplibre_loader__",vn="vs-global-bounds-src",En="vs-global-bounds-line",Go=xe(e.defineComponent({__name:"vs-input-map",props:{tools:{},multi:{type:Boolean,default:!1},multiple:{type:Boolean,default:!1},handleZoom:{type:Boolean,default:!0},ctrlZoom:{type:Boolean,default:!0},geomType:{default:()=>[]},prefix:{default:""},katottg:{default:""},layers:{default:()=>[]},bounds:{},api:{},center:{default:void 0},zoom:{default:void 0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},emits:["update:modelValue","valueSelected"],setup(o,{emit:t}){const n=o,r=t,l=e.useAttrs(),a=e.computed(()=>{const f=l?.multiple,g=l?.multi,C=F=>F===""||F===!0||F==="true"||F===1||F==="1";return!!n.multi||!!n.multiple||C(g)||C(f)}),s=e.computed(()=>!!n.disabled),i=e.ref(!1),c=e.ref(null),d=e.ref(0),u=e.ref(""),p=e.ref(null),y=e.ref([]),k=e.ref(null),m=e.ref(null),h=Ld({onActivate(){if(oe)try{oe.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""},onDeactivate(){}});function b(){h.toggleRuler()}const _=e.getCurrentInstance(),x=_?.appContext?.config?.globalProperties?.$settings??{},v=x?.map??{},N=_?.vnode?.props??{};function U(f){return Object.prototype.hasOwnProperty.call(N,f)||Object.prototype.hasOwnProperty.call(N,f.replace(/[A-Z]/g,g=>`-${g.toLowerCase()}`))}const W=Array.isArray(v.center)&&v.center.length===2?v.center:Array.isArray(x.center)&&x.center.length===2?x.center:[30,50],L=typeof v.zoom=="number"?v.zoom:typeof x.zoom=="number"?x.zoom:typeof x.defaultZoom=="number"?x.defaultZoom:10;function B(f){if(f!=null){if(Array.isArray(f)&&f.length>=2){const g=Number(f[0]),C=Number(f[1]);return!Number.isFinite(g)||!Number.isFinite(C)?void 0:[g,C]}if(typeof f=="object"){const g=f,C=g.geom;if(g.type==="Point"&&Array.isArray(g.coordinates)){const G=g.coordinates,le=Number(G[0]),se=Number(G[1]);if(Number.isFinite(le)&&Number.isFinite(se))return[le,se]}if(C?.type==="Point"&&Array.isArray(C.coordinates)){const G=C.coordinates,le=Number(G[0]),se=Number(G[1]);if(Number.isFinite(le)&&Number.isFinite(se))return[le,se]}const F=Number(g.lat),D=Number(g.lng??g.lon);if(Number.isFinite(F)&&Number.isFinite(D))return[D,F]}}}const S=e.computed(()=>{const f=B(n.center);if(f)return f;if(!U("center"))return B(v.center)??B(x.center)}),$=e.computed(()=>U("zoom")?n.zoom:v.zoom??n.zoom),V=e.computed(()=>U("katottg")?String(n.katottg??""):String(v.katottg??n.katottg??"")),M=e.computed(()=>U("layers")?n.layers??[]:v.layers??n.layers??[]),O=e.computed(()=>U("bounds")?n.bounds:v.bounds??n.bounds),E=e.ref(Array.isArray(S.value)&&S.value.length===2?[...S.value]:W),K=e.ref(typeof $.value=="number"?$.value:L),T=e.ref(n.modelValue),Y=e.ref(null),I=e.ref(null),X=e.ref([]),Q=e.ref(!1),ke=e.ref(!1),he=e.ref([]),J=e.ref({coordinates:"",format:"decimal",order:"lat-lon"}),me={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 ae=!1,me=!1;const Q=e.reactive({}),ie=e.ref([]),fe=e.computed(()=>ie.value.map(f=>Q[f]).filter(Boolean)),Ee=e.ref(null),$e=e.computed(()=>Ee.value?.entries??[]),Pe=e.computed(()=>{if(Ee.value)return{left:`${Ee.value.point.x+12}px`,top:`${Ee.value.point.y+12}px`}}),Fe=e.computed(()=>{if(Array.isArray(n.tools)&&n.tools.length)return n.tools;const f=l?.tools;return Array.isArray(f)?f.map(k=>String(k)):typeof f=="string"?f.split(",").map(k=>k.trim()).filter(Boolean):[]}),_e=e.computed(()=>{const f={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Fe.value.length)return{...f,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const k=new Set(Fe.value.map(v=>v.toLowerCase()));return{search:k.has("search"),import:k.has("import"),export:k.has("export"),point:k.has("point"),line:k.has("line"),polygon:k.has("polygon"),rectangle:k.has("rectangle"),ruler:k.has("ruler")}});function Ne(f){if(typeof f!="string"||!f.trim())return"";if(/^https?:\/\//i.test(f))return f;const k=window?.location?.origin??"",v=f.replace(/^\/+/,"");return v?k?`${k}/${v}`:`/${v}`:k}function Be(){const f=Array.isArray(C.basemaps)&&C.basemaps.length?C.basemaps:x.basemaps;if(Array.isArray(f)&&f.length){const v=f.map((F,D)=>{const X=String(F?.key??F?.id??F?.name??`b${D}`),le=Ne(String(F?.url??""));if(!le)return null;const ce=typeof F?.preview=="string"&&F.preview?Ne(F.preview):"";return[X,{...F,url:le,preview:ce}]}).filter(F=>Array.isArray(F)&&F.length===2).reduce((F,[D,X])=>(F[D]=X,F),{});if(Object.keys(v).length)return v}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 Ae=Be(),Re=Object.keys(Ae),Oe=e.ref(Re.length?Re[0]:"");async function tt(){if(typeof window>"u")return null;const f=window;if(f[Cn])return f[Cn];const k=X=>{if(Array.from(document.styleSheets).some(Le=>Le?.href?.includes(X)))return;const ce=document.createElement("link");ce.rel="stylesheet",ce.href=X,document.head.appendChild(ce)},v=async()=>{const X=new Function("u","return import(u)"),le=await X("https://esm.sh/maplibre-gl@3.6.2"),ce=le?.default??le;if(!ce)throw new Error("maplibre esm fallback failed");window.maplibregl=ce,window.mapboxgl=ce;const Le=await X("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),rt=Le?.default??Le;if(!rt)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=rt},D=(async()=>{k("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),k("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await v();const X=window.maplibregl,le=window.MapboxDraw;if(!X)throw new Error("maplibregl not available after load");if(!le)throw new Error("MapboxDraw not available after load");return{maplibregl:X,MapboxDraw:le}})().catch(X=>{throw delete f[Cn],X});return f[Cn]=D,D}function U(f){return{version:8,sources:{rasterSource:{type:"raster",tiles:[f],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let J=null,ne=null,P=null,Y=null,we=[],Ve=null,Ce=null,R=null,_=!1,A=!1,z=!1,re=null;function ke(){return{onSetup(){const f=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(f),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:f,startPoint:null,hasCoordinates:!1}},onMouseMove(f,k){if(!f.startPoint)return;const[v,F]=f.startPoint,D=k.lngLat.lng,X=k.lngLat.lat;f.rectangle.setCoordinates([[[v,F],[D,F],[D,X],[v,X],[v,F]]])},onClick(f,k){if(!f.startPoint){f.startPoint=[k.lngLat.lng,k.lngLat.lat],f.hasCoordinates=!0,f.rectangle.setCoordinates([[[k.lngLat.lng,k.lngLat.lat],[k.lngLat.lng,k.lngLat.lat],[k.lngLat.lng,k.lngLat.lat],[k.lngLat.lng,k.lngLat.lat],[k.lngLat.lng,k.lngLat.lat]]]);return}const[v,F]=f.startPoint,D=k.lngLat.lng,X=k.lngLat.lat;return Math.abs(v-D)>0&&Math.abs(F-X)>0?(f.rectangle.setCoordinates([[[v,F],[D,F],[D,X],[v,X],[v,F]]]),this.map.fire("draw.create",{features:[f.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[f.rectangle.id]})):(this.deleteFeature([f.rectangle.id],{silent:!0}),f.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(f){this.deleteFeature([f.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(f,k,v){const F=k.properties.id===f.rectangle.id;F&&!f.hasCoordinates||(k.properties.active=F?"true":"false",v(k))}}}const Me=[{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 Se(){const f=Oe.value;return!f||!Ae[f]?.url?"":Ae[f].url}function We(f,k){return f?.id?String(f.id):f?.url?`${f.url}-${k}`:`layer-${k}`}function st(f){const k=String(f?.url??"").trim();if(!k)return"";if(/^https?:\/\//i.test(k))return k;const v=window.location?.origin??"",F=k.replace(/^\/+/,"");return`${v}/${F}`}function Ge(f){f&&Ee.value?.layerId!==f||(Ee.value=null)}function ze(f,k={}){return f.popup===!1?[]:Array.isArray(f.popup)?f.popup.length?f.popup.map(v=>{const F=v?.field||v?.name;if(!F)return null;const D=k[F];return D==null||D===""?null:{key:v.label||F,value:String(D)}}).filter(Boolean):[]:Object.entries(k).slice(0,5).map(([v,F])=>({key:v,value:F==null?"—":String(F)}))}function nt(f){if(!Array.isArray(f))return[];const k=F=>Array.isArray(F)&&F.length>=2&&Number.isFinite(Number(F[0]))&&Number.isFinite(Number(F[1])),v=F=>{if(!F.length)return F;const D=F[0],X=F[F.length-1];return!X||D[0]!==X[0]||D[1]!==X[1]?[...F,D]:F};if(f.length&&k(f[0])){const F=f.map(D=>[Number(D[0]),Number(D[1])]).filter(k);return F.length?[v(F)]:[]}return f.length&&Array.isArray(f[0])&&k(f[0][0])?f.map(D=>Array.isArray(D)?D.map(X=>[Number(X[0]),Number(X[1])]):[]).filter(D=>D.length).map(v):f.length&&Array.isArray(f[0])&&Array.isArray(f[0][0])&&k(f[0][0][0])?f.flatMap(D=>Array.isArray(D)?D:[]).map(D=>Array.isArray(D)?D.map(X=>[Number(X[0]),Number(X[1])]):[]).filter(D=>D.length).map(v):[]}function Ht(f){const k=f.style??{},v=k.color??"#3b82f6";if(!k.colorAttr||!k.colorSet)return v;const F=Object.keys(k.colorSet);if(!F.length)return v;const D=["match",["to-string",["get",k.colorAttr]]];return F.forEach(X=>{D.push(String(X),k.colorSet?.[X]??v)}),D.push(v),D}function Ft(f){if(!P)return;f.handlers.forEach(v=>{try{P.off(v.type,v.layerId,v.handler)}catch{}}),f.handlers=[],[...f.layerIds,...f.boundsIds].forEach(v=>{P.getLayer(v)&&P.removeLayer(v)}),P.getSource(f.sourceId)&&P.removeSource(f.sourceId);const k=`vs-ov-bounds-src-${f.id}`;P.getSource(k)&&P.removeSource(k),Ge(f.id)}function sn(f,k){if(!P)return[];const v=`vs-ov-bounds-src-${k}`,F=`vs-ov-bounds-line-${k}`,D=f.bounds??M.value??L.value,X=nt(D);if(!X.length)return[];const le={type:"FeatureCollection",features:X.map(ce=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:ce}}))};return P.getSource(v)&&P.removeSource(v),P.addSource(v,{type:"geojson",data:le}),P.addLayer({id:F,type:"line",source:v,paint:{"line-color":f.style?.stroke??f.style?.color??"#2563eb","line-width":f.style?.width??2,"line-opacity":f.style?.opacity??.8,"line-dasharray":[2,2]}}),[F]}function bt(f){if(!P)return;Ft(f);const k=f.config,v=st(k);if(!v)return;const F=[],D=[];if(/\.v(?:m)?t(?:\?|$)/i.test(v)||/\.pbf(?:\?|$)/i.test(v)){const ce=k.sourceLayer||k.layer||k.service_layer||k.dataset?.layer||k.id;P.addSource(f.sourceId,{type:"vector",tiles:[v]});const Le=String(k.style?.type??"polygon").toLowerCase(),rt=Ht(k),mt=k.style?.opacity??.5;if(Le==="point"){const xt=`vs-ov-point-${f.id}`;P.addLayer({id:xt,type:"circle",source:f.sourceId,"source-layer":ce,paint:{"circle-color":rt,"circle-radius":5,"circle-opacity":mt}}),F.push(xt)}else if(Le==="polyline"||Le==="line"){const xt=`vs-ov-line-${f.id}`;P.addLayer({id:xt,type:"line",source:f.sourceId,"source-layer":ce,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":rt,"line-width":k.style?.width??2,"line-opacity":mt}}),F.push(xt)}else{const xt=`vs-ov-fill-${f.id}`,pn=`vs-ov-border-${f.id}`;P.addLayer({id:xt,type:"fill",source:f.sourceId,"source-layer":ce,paint:{"fill-color":rt,"fill-opacity":mt}}),P.addLayer({id:pn,type:"line",source:f.sourceId,"source-layer":ce,paint:{"line-color":k.style?.stroke??k.style?.color??"#2563eb","line-width":k.style?.width??1,"line-opacity":mt}}),F.push(xt,pn)}}else{P.addSource(f.sourceId,{type:"raster",tiles:[v],tileSize:256});const ce=`vs-ov-raster-${f.id}`;P.addLayer({id:ce,type:"raster",source:f.sourceId,paint:{"raster-opacity":k.style?.opacity??1}}),F.push(ce)}F.forEach(ce=>{const Le=mt=>{if(!mt?.features?.length){Ge(f.id);return}const xt=mt.features[0]?.properties??{},pn=ze(f.config,xt);if(!pn.length){Ge(f.id);return}Ee.value={layerId:f.id,entries:pn,point:{x:mt.point.x,y:mt.point.y}}},rt=()=>Ge(f.id);P.on("mousemove",ce,Le),P.on("mouseleave",ce,rt),D.push({layerId:ce,type:"mousemove",handler:Le},{layerId:ce,type:"mouseleave",handler:rt})}),f.layerIds=F,f.boundsIds=sn(f.config,f.id),f.handlers=D;const le=f.visible?"visible":"none";[...f.layerIds,...f.boundsIds].forEach(ce=>{P.getLayer(ce)&&P.setLayoutProperty(ce,"visibility",le)})}function Pt(){if(!P)return;const k={type:"FeatureCollection",features:nt(M.value??L.value).map(v=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:v}}))};P.getSource(vn)?P.getSource(vn).setData(k):P.addSource(vn,{type:"geojson",data:k}),P.getLayer(En)||P.addLayer({id:En,type:"line",source:vn,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function xo(f){if(!P||s.value)return;const k=Q[f];if(!k)return;k.visible=!k.visible;const v=k.visible?"visible":"none";[...k.layerIds,...k.boundsIds].forEach(F=>{P.getLayer(F)&&P.setLayoutProperty(F,"visibility",v)}),Et(),k.visible||Ge(f)}function Et(){if(!P)return;const f=[],k=[],v=[],F=[];ie.value.forEach(le=>{const ce=Q[le];if(!ce)return;const Le=String(ce.config?.url??""),rt=/\.v(?:m)?t(?:\?|$)/i.test(Le),mt=/\.png(?:\?|$)/i.test(Le);rt?v.push(...ce.layerIds):mt?f.push(...ce.layerIds):k.push(...ce.layerIds),F.push(...ce.boundsIds)}),[...f,...k,...v,...F].forEach(le=>{P.getLayer(le)&&P.moveLayer(le)}),P.getLayer(En)&&P.moveLayer(En),(P.getStyle?.()?.layers??[]).map(le=>String(le?.id??"")).filter(le=>le.startsWith("gl-draw-")).forEach(le=>{P.getLayer(le)&&P.moveLayer(le)})}function wo(f){if(!Ae[f]||(Oe.value=f,!P))return;const k=Se();if(!k)return;const v=P.getCenter?.(),F=P.getZoom?.(),D=Y?.getAll?.();P.setStyle(U(k)),P.once("style.load",()=>{if(P&&(v&&Number.isFinite(F)&&P.jumpTo({center:[v.lng,v.lat],zoom:F}),Pt(),ie.value.forEach(X=>{const le=Q[X];le&&bt(le)}),Et(),D?.features?.length&&Y))try{D.features.forEach(X=>Y.add(X)),d.value=D.features.length}catch{d.value=0}})}function qt(f){return{type:"Feature",properties:{},geometry:f}}function it(f){if(!f)return null;try{return JSON.parse(JSON.stringify(f))}catch{return null}}function cn(f){if(!f)return null;const k=it(f.geometry);return k?{...f.id!==void 0?{id:f.id}:{},type:"Feature",properties:{...f.properties??{}},geometry:k}:null}function Dt(f){if(!f)return[];const k=(D,X)=>{if(!D?.type)return[];const le={...X??{}};return D.type==="MultiPoint"&&Array.isArray(D.coordinates)?D.coordinates.map(ce=>qt({type:"Point",coordinates:ce})).map(ce=>({...ce,properties:le})):D.type==="MultiLineString"&&Array.isArray(D.coordinates)?D.coordinates.map(ce=>qt({type:"LineString",coordinates:ce})).map(ce=>({...ce,properties:le})):D.type==="MultiPolygon"&&Array.isArray(D.coordinates)?D.coordinates.map(ce=>qt({type:"Polygon",coordinates:ce})).map(ce=>({...ce,properties:le})):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?D.geometries.flatMap(ce=>k(ce,le)):[{type:"Feature",properties:le,geometry:it(D)}]},v=D=>{if(!D)return null;if(D.type==="Feature"){const X=cn(D);return X?k(X.geometry,X.properties):null}return D.geom?.type&&Array.isArray(D.geom.coordinates)?k({type:D.geom.type,coordinates:D.geom.coordinates},D.properties??{}):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?k(D,D.properties??{}):typeof D.type=="string"&&Array.isArray(D.coordinates)?k(it(D),D.properties??{}):null};if(f.type==="FeatureCollection")return(f.features??[]).flatMap(v).filter(Boolean);if(Array.isArray(f))return f.flatMap(D=>D?.type==="FeatureCollection"?Dt(D):[v(D)]).flat().filter(Boolean);const F=v(f);return F?Array.isArray(F)?F:[F]:[]}function j(f){if(!f.length)return null;if(!a.value)return it(f[0]?.geometry??null);const k=f.map(X=>it(X?.geometry)).filter(Boolean);return k.every(X=>X?.type==="Point")?{type:"MultiPoint",coordinates:k.map(X=>X.coordinates)}:k.every(X=>X?.type==="LineString")?{type:"MultiLineString",coordinates:k.map(X=>X.coordinates)}:k.every(X=>X?.type==="Polygon")?{type:"MultiPolygon",coordinates:k.map(X=>X.coordinates)}:{type:"GeometryCollection",geometries:k}}function te(f){if(!f)return"__null__";try{return JSON.stringify(f)}catch{return"__invalid__"}}function se(f,k){if(!Array.isArray(f)||!Array.isArray(k)||f.length<2||k.length<2)return!1;const v=1e-12;return Math.abs(Number(f[0])-Number(k[0]))<v&&Math.abs(Number(f[1])-Number(k[1]))<v}function ve(f,k){if(!Array.isArray(f)||f.length<4)return null;const F=se(f[0],f[f.length-1])?f.slice(0,-1):f.slice();return!Number.isInteger(k)||k<0||k>=F.length||F.length<=3||(F.splice(k,1),F.length<3)?null:[...F,[...F[0]]]}function De(f,k){if(!Array.isArray(f)||f.length<2||!Number.isInteger(k)||k<0||k>=f.length||f.length<=2)return null;const v=f.slice();return v.splice(k,1),v.length<2?null:v}function Ke(f,k){const v=it(f);if(!v||!Array.isArray(k))return null;if(v.type==="LineString"){const[F]=k,D=De(v.coordinates,F);return D?(v.coordinates=D,v):null}if(v.type==="MultiLineString"){const[F,D]=k,X=v.coordinates?.[F],le=De(X,D);return le?(v.coordinates[F]=le,v):null}if(v.type==="Polygon"){const[F,D]=k,X=v.coordinates?.[F],le=ve(X,D);return le?(v.coordinates[F]=le,v):null}if(v.type==="MultiPolygon"){const[F,D,X]=k,le=v.coordinates?.[F]?.[D],ce=ve(le,X);return ce?(v.coordinates[F][D]=ce,v):null}return null}function Te(f){return f?f.split(".").map(k=>Number(k)).filter(k=>Number.isInteger(k)&&k>=0):[]}function ot(f){return!Y||!f?null:typeof Y.get=="function"?Y.get(f)??null:Y.getAll?.()?.features?.find(v=>String(v?.id??"")===f)??null}function pt(f){const k=f?.properties?.id??f?.id;return k==null||k===""?null:String(k)}function ft(f){if(!P||!f)return null;const k=[[f.x-8,f.y-8],[f.x+8,f.y+8]],F=P.queryRenderedFeatures(k).find(D=>{const X=String(D?.properties?.meta??"");return X&&X!=="feature"?!1:!!pt(D)});return pt(F)}function kt(f,k){if(!Y||!f||!k.length)return;const v=ot(f);if(!v?.geometry)return;const F=Ke(v.geometry,k);if(!F)return;const D={...v,id:v.id??f,geometry:F};me=!0,ae=!0;try{Y.delete(f),Y.add(D)}finally{ae=!1,me=!1}Tt(),Bt()}function ct(f){if(!P||!Y||s.value||h.isRulerActive.value||u.value!=="edit")return;const k=f?.point;if(!k)return;const v=[[k.x-8,k.y-8],[k.x+8,k.y+8]],D=P.queryRenderedFeatures(v).find(le=>le?.properties?.meta==="vertex"&&le?.properties?.parent&&le?.properties?.coord_path);if(!D)return;f?.originalEvent?.preventDefault?.(),f?.originalEvent?.stopPropagation?.();const X=Te(String(D.properties.coord_path));X.length&&kt(String(D.properties.parent),X)}function dn(f){const k=Xr(f);if(!k)return null;const[[v,F],[D,X]]=k;return{lat:(F+X)/2,lng:(v+D)/2}}function Wr(f){if(!Array.isArray(f)||f.length<3)return 0;const k=(F,D)=>{const X=F*2003750834e-2/180,le=Math.log(Math.tan((90+D)*Math.PI/360))/(Math.PI/180);return[X,le*2003750834e-2/180]};let v=0;for(let F=0;F<f.length-1;F+=1){const[D,X]=k(Number(f[F][0]),Number(f[F][1])),[le,ce]=k(Number(f[F+1][0]),Number(f[F+1][1]));v+=D*ce-le*X}return Math.abs(v/2)/1e6}function b0(f){if(!f?.type||!f?.coordinates)return null;if(f.type==="Polygon"){const k=f.coordinates?.[0];return Array.isArray(k)?Wr(k):null}return f.type==="MultiPolygon"?f.coordinates.reduce((k,v)=>{const F=v?.[0];return Array.isArray(F)?k+Wr(F):k},0):null}function _o(f){if(!f){p.value=null;return}const k=dn(f);if(!k){p.value=null;return}p.value={type:String(f.type??"Feature"),center:k,areaKm2:b0(f)}}function Co(f){if(!f){const F=we[we.length-1],D=it(F?.geometry??null);Ve=D,_o(D);return}const k=we.find(F=>String(F?.id??"")===String(f))??null,v=it(k?.geometry??null);Ve=v,_o(v)}function vo(f){g.value=(f??[]).map((k,v)=>{const F=String(k?.id??`feature-${v+1}`),D=Gr(String(k?.geometry?.type??"Feature"));return{id:F,label:`${D} ${v+1}`}})}function Gr(f){switch(String(f)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(f||"Невідомо")}}function Yr(f,k){if(!Array.isArray(f)||!Array.isArray(k)||f.length!==2||k.length!==2)return!1;const v=1e-9;return Math.abs(Number(f[0])-Number(k[0]))<v&&Math.abs(Number(f[1])-Number(k[1]))<v}function Xr(f){if(!f)return null;let k=1/0,v=1/0,F=-1/0,D=-1/0;const X=le=>{if(Array.isArray(le)){if(le.length>=2&&Number.isFinite(le[0])&&Number.isFinite(le[1])){const ce=Number(le[0]),Le=Number(le[1]);k=Math.min(k,ce),v=Math.min(v,Le),F=Math.max(F,ce),D=Math.max(D,Le);return}le.forEach(X)}};return X(f.coordinates),!Number.isFinite(k)||!Number.isFinite(v)?null:[[k,v],[F,D]]}function Zr(f){if(!P||!f)return;const k=Xr(f);if(!k)return;const[[v,F],[D,X]]=k;if(v===D&&F===X){P.easeTo({center:[v,F],zoom:Math.max(B.value,14)});return}P.fitBounds(k,{padding:30,duration:250,maxZoom:18})}function Eo(){if(!Y){d.value=0;return}const f=Y.getAll();d.value=f?.features?.length??0}function un(){if(!Y)return null;const k=Y.getAll?.()?.features??[],v=X=>!!X&&k.some(le=>String(le?.id??"")===String(X??"")),F=Y.getSelectedIds?.();if(Array.isArray(F)&&F.length>0){const X=F[0];return X!=null?String(X):null}if(v(R))return String(R);if(!k.length)return null;const D=a.value?k[k.length-1]:k[0];return D?.id!==void 0&&D?.id!==null?String(D.id):null}function Tt(){if(!Y)return;const f=Y.getAll();if(d.value=f?.features?.length??0,!f?.features?.length){we=[],g.value=[],Ve=null,R=null,p.value=null,ae||(Ce="__null__",r("update:modelValue",null));return}const k=(f.features??[]).map(cn).filter(Boolean);if(we=k,vo(k),R=un(),Co(R),!ae){const v=j(k);Ce=te(v),r("update:modelValue",v)}}function jn(){if(!Y)return;(Y.getAll()?.features||[]).forEach(k=>Y.delete(k.id)),g.value=[],Eo()}function Un(f){if(!Y)return;const k=Dt(f),v=a.value?k:k.slice(0,1);ae=!0,jn(),v.forEach(X=>{try{Y.add(X)}catch{}}),ae=!1,we=(Y.getAll?.()?.features??v).map(cn).filter(Boolean),vo(we),R=null;const D=it(we[we.length-1]?.geometry??null);Ve=it(D),Eo(),_o(D),D&&(Zr(D),s.value||Bt())}function k0(){Y&&(ae=!0,jn(),we.forEach(f=>{try{Y.add(f)}catch{}}),ae=!1,vo(we),Eo(),Co(R))}function Kt(){if(Y){try{Y.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""}}function Hn(f){if(s.value||!Y)return;h.isRulerActive.value&&h.closeRuler(),z=!0,Kt(),u.value=f;const k=f==="marker"?"draw_point":f==="polyline"?"draw_line_string":f==="rectangle"?"draw_rectangle":"draw_polygon";a.value||(ae=!0,jn(),ae=!1);try{Y.changeMode(k)}catch{u.value=""}finally{requestAnimationFrame(()=>{z=!1})}}function Bt(f){if(s.value||!Y||!Y.getAll()?.features?.length)return;const v=f||un();if(v)try{Y.changeMode("direct_select",{featureId:v}),R=v,Co(R),u.value="edit"}catch{u.value=""}}function x0(f){s.value||!Y||!f||Bt(f)}function w0(){if(!(s.value||!Y)){if(a.value){const f=un();if(f)try{_=!0,Y.delete(f),_=!1,Tt();const k=un();k?Bt(k):Kt();return}catch{_=!1}}Kt(),jn(),we=[],g.value=[],R=null,Ce="__null__",p.value=null,r("update:modelValue",null)}}function _0(){s.value||!Ve||Zr(Ve)}function C0(f){if(!P||!J)return;const k=[f[1],f[0]];re||(re=new J.Marker({color:"#2563eb"})),re.setLngLat(k).addTo(P),P.easeTo({center:k,zoom:13,duration:250})}function v0(){s.value||I.value?.click()}function E0(){s.value||(Z.value=!Z.value)}function Jr(f){if(!Z.value)return;const k=G.value;k&&!k.contains(f.target)&&(Z.value=!1)}function B0(){Z.value=!1,v0()}function V0(){s.value||(be.value=[],Z.value=!1,oe.value=!0)}function S0(){oe.value=!1,be.value=[]}function $0(){if(s.value||!Y)return;const f=wc(pe.value.coordinates??"",pe.value.format||"decimal",pe.value.order||"lat-lon");if(!f.ok){be.value=f.errors,N0(f.errors);return}be.value=[],Un({type:"Polygon",coordinates:[f.ring]}),Tt(),oe.value=!1,f.wasClosedAutomatically&&ue.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function N0(f){if(!f.length)return;const k=5;f.slice(0,k).forEach(v=>{const F=v.line>0?`Рядок ${v.line}`:"Загальна помилка";ue.notify({type:"warning",title:"Імпорт координат",message:`${F} — ${v.message}`})}),f.length>k&&ue.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${f.length-k}`})}function A0(f){if(s.value||!Y)return;Z.value=!1;const k=f.target,v=k.files?.[0];if(!v)return;const F=new FileReader;F.onload=()=>{try{const D=JSON.parse(String(F.result));if(!Dt(D).length){ue.notify({type:"warning",title:"Імпорт файлу",message:"Файл не містить коректний GeoJSON-обʼєкт."});return}Un(D),Tt()}catch{ue.notify({type:"error",title:"Імпорт файлу",message:"Не вдалося прочитати файл. Перевірте формат GeoJSON/JSON."})}finally{k.value=""}},F.onerror=()=>{ue.notify({type:"error",title:"Імпорт файлу",message:"Помилка читання файлу."}),k.value=""},F.readAsText(v)}function M0(){if(s.value||!Y)return;const f=Y.getAll(),k=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),v=URL.createObjectURL(k),F=document.createElement("a");F.href=v,F.download="data.geojson",F.click(),URL.revokeObjectURL(v)}return e.onMounted(async()=>{if(window.addEventListener("click",Jr,!0),!c.value)return;const f=await tt();J=f.maplibregl,ne=f.MapboxDraw;const k=Se();k&&(P=new J.Map({container:c.value,style:U(k),center:[O.value[0],O.value[1]],zoom:B.value,attributionControl:!1}),b.value=P,P.addControl(new J.NavigationControl({showCompass:!0}),"bottom-right"),P.on("load",()=>{if(!(!ne||!P)){if(Y=new ne({displayControlsDefault:!1,modes:{...ne.modes,draw_rectangle:ke()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:Me}),P.addControl(Y),P.on("click",v=>{if(h.isRulerActive.value){const D=v?.lngLat;if(!D)return;m.value?.addPoint?.({lat:D.lat,lng:D.lng});return}if(!Y||s.value||u.value!=="edit")return;const F=ft(v?.point);!F||F===R||requestAnimationFrame(()=>{!Y||s.value||Bt(F)})}),P.on("draw.create",()=>{if(Y&&!h.isRulerActive.value){if(!a.value){const v=Y.getAll();if(v.features.length>1){const F=v.features[v.features.length-1];ae=!0,v.features.slice(0,-1).forEach(D=>Y.delete(D.id)),ae=!1,F&&(ae=!0,Y.add(F),ae=!1)}}Tt(),Bt()}}),P.on("draw.update",v=>{if(A||h.isRulerActive.value)return;const F=Array.isArray(v?.features)?v.features:[],D=v?.action==="move"&&F.length>0&&F.every(X=>X?.geometry?.type==="Point");if(v?.action==="move"){if(D){Tt();return}if(A=!0,k0(),A=!1,u.value==="edit"){const X=un(),le=X?ot(X):Y?.getAll?.()?.features?.[0];if(le?.id)try{Y.changeMode("direct_select",{featureId:le.id}),R=String(le.id)}catch{u.value=""}}return}Tt()}),P.on("draw.delete",()=>{me||_||h.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle"||(Tt(),Y?.getAll?.()?.features?.length||(R=null),u.value="",Kt())}),P.on("draw.selectionchange",v=>{if(!Y||A||h.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle")return;const F=v?.features?.[0]?.id!==void 0&&v?.features?.[0]?.id!==null?String(v.features[0].id):null;if(!s.value&&F){if(u.value==="edit"&&R===F)return;requestAnimationFrame(()=>{!Y||s.value||Bt(F)});return}const D=Y.getSelectedIds?.(),X=Array.isArray(D)&&D.length>0?String(D[0]):null;if(!s.value&&X){if(u.value==="edit"&&R===X)return;requestAnimationFrame(()=>{!Y||s.value||Bt(X)});return}try{Y.changeMode("simple_select",{featureIds:[]})}catch{}}),K.value!==void 0){const v=K.value;K.value=void 0,requestAnimationFrame(()=>{Y&&Un(v)})}Pt(),ie.value.forEach(v=>{const F=Q[v];F&&bt(F)}),Et()}}),P.on("contextmenu",ct),P.on("zoomend",()=>{P&&(B.value=P.getZoom())}))}),e.onUnmounted(()=>{h.isRulerActive.value&&h.closeRuler(),window.removeEventListener("click",Jr,!0),Object.values(Q).forEach(f=>{P&&Ft(f)}),Ge(),re?.remove&&re.remove(),re=null,P?.remove&&P.remove(),P=null,Y=null,b.value=null}),e.watch(()=>n.modelValue,f=>{if(!Y){K.value=f;return}const k=j((a.value?Dt(f):Dt(f).slice(0,1))||[]),v=te(k);if(Ce&&v===Ce){Ce=null;return}Ce=null,Un(f)},{deep:!0}),e.watch(()=>V.value,f=>{const k=Array.isArray(f)?f:[],v=[],F=new Set;k.forEach((D,X)=>{if(!D)return;const le=We(D,X);v.push(le),F.add(le);const ce={...D,id:le},Le=Q[le],rt=Le?.visible??!!ce.visible;Le&&P&&Ft(Le),Q[le]={id:le,config:ce,visible:rt,sourceId:`vs-ov-src-${le}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(Q).forEach(D=>{if(F.has(D))return;const X=Q[D];X&&P&&Ft(X),delete Q[D]}),ie.value=v,P&&(ie.value.forEach(D=>{const X=Q[D];X&&bt(X)}),Et())},{immediate:!0,deep:!0}),e.watch(()=>M.value,()=>{P&&(Pt(),ie.value.forEach(f=>{const k=Q[f];k&&bt(k)}),Et())},{deep:!0}),e.watch(()=>N.value,async f=>{if(L.value=[],!f){P&&(Pt(),ie.value.forEach(k=>{const v=Q[k];v&&bt(v)}),Et());return}try{const k=await fetch(`https://data.gki.com.ua/api-user/atu/${f}`);if(!k?.ok)return;const F=(await k.json())?.geometry?.coordinates;Array.isArray(F)&&F.length&&(L.value=F)}catch(k){console.error("Failed to fetch KATOTTG bounds",k)}finally{if(!P)return;Pt(),ie.value.forEach(k=>{const v=Q[k];v&&bt(v)}),Et()}},{immediate:!0}),e.watch(()=>E.value,f=>{if(!Array.isArray(f)||f.length!==2)return;const k=[Number(f[0]),Number(f[1])];if(Yr(O.value,k)||(O.value=[...k],!P))return;const v=P.getCenter?.();v&&Yr([v.lng,v.lat],O.value)||P.easeTo({center:[O.value[0],O.value[1]]})},{deep:!0}),e.watch(()=>$.value,f=>{typeof f=="number"&&(B.value=f,P&&P.setZoom(f))}),e.watch(s,f=>{f&&Kt()}),e.watch(d,f=>{if(f>0){s.value||Bt();return}z||Kt()}),e.watch(i,()=>{setTimeout(()=>{P?.resize&&P.resize()},50)}),(f,k)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!i.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:i.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:c,class:"w-full h-[calc(100%-28px)]"},null,512),_e.value.search||_e.value.import||_e.value.export?(e.openBlock(),e.createElementBlock("div",Id,[_e.value.search?(e.openBlock(),e.createBlock(zc,{key:0,onGoToCoordinates:C0})):e.createCommentVNode("",!0),_e.value.import||_e.value.export?(e.openBlock(),e.createElementBlock("div",Rd,[e.createElementVNode("div",Od,[_e.value.import?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:G,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:E0,disabled:s.value},[k[8]||(k[8]=e.createTextVNode(" Імпорт ",-1)),e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":Z.value}])},null,8,["class"])],8,Pd),Z.value?(e.openBlock(),e.createElementBlock("div",zd,[_e.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:B0}," З файлу ")):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:V0}," З координат ")])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),_e.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:M0,disabled:s.value||d.value===0}," Експорт ",8,jd)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:I,type:"file",onChange:A0,accept:".json,.geojson",class:"hidden",disabled:s.value},null,40,Ud)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(ue.VsModal),{visible:oe.value,"onUpdate:visible":k[1]||(k[1]=v=>oe.value=v),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(at,{schema:ee,values:pe.value,"onUpdate:values":k[0]||(k[0]=v=>pe.value=v)},null,8,["values"]),e.createElementVNode("div",Hd,[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:S0}," Скасувати "),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:$0,disabled:s.value}," Побудувати ",8,qd)])]),_:1},8,["visible"]),e.createElementVNode("div",Kd,[e.createElementVNode("div",Wd,[_e.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="marker"}]),title:"Point",onClick:k[2]||(k[2]=v=>Hn("marker")),disabled:s.value},[e.createVNode(e.unref(q.MapPin),{class:"h-4 w-4"})],10,Gd)):e.createCommentVNode("",!0),_e.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polyline"}]),title:"Line",onClick:k[3]||(k[3]=v=>Hn("polyline")),disabled:s.value},[e.createVNode(ac)],10,Yd)):e.createCommentVNode("",!0),_e.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polygon"}]),title:"Polygon",onClick:k[4]||(k[4]=v=>Hn("polygon")),disabled:s.value},[e.createVNode(dc)],10,Xd)):e.createCommentVNode("",!0),_e.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="rectangle"}]),title:"Rectangle",onClick:k[5]||(k[5]=v=>Hn("rectangle")),disabled:s.value},[e.createVNode(mc)],10,Zd)):e.createCommentVNode("",!0),_e.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(h).isRulerActive.value}]),title:"Ruler",onClick:y},[e.createVNode(e.unref(q.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:k[6]||(k[6]=v=>i.value=!i.value),title:"Full Screen"},[e.createVNode(e.unref(q.Maximize),{class:"h-4 w-4"})])])]),_e.value.ruler&&e.unref(h).isRulerActive.value?(e.openBlock(),e.createBlock(Dd,{key:1,ref_key:"rulerPanelRefEl",ref:m,onClose:k[7]||(k[7]=v=>e.unref(h).closeRuler()),onTabChange:e.unref(h).onRulerTabChange,onPointsChange:e.unref(h).onRulerPointsChange,onShapeClosedChange:e.unref(h).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),_e.value.ruler&&e.unref(h).isRulerActive.value&&e.unref(h).hasRulerPoints.value?(e.openBlock(),e.createBlock(Td,{key:2,map:b.value,points:e.unref(h).rulerPoints.value,"is-shape-closed":e.unref(h).rulerShapeClosed.value,"label-mode":e.unref(h).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),$e.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(Pe.value)},[e.createElementVNode("div",Jd,[e.createElementVNode("dl",Qd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList($e.value,v=>(e.openBlock(),e.createElementBlock("div",{key:`${v.key}-${v.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",eu,e.toDisplayString(v.key),1),e.createElementVNode("dd",tu,e.toDisplayString(v.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",nu,[e.createElementVNode("div",ou,[e.createVNode(kc,{basemaps:e.unref(Ae),onOnLayerChange:wo},null,8,["basemaps"]),fe.value.length?(e.openBlock(),e.createElementBlock("div",ru,[k[9]||(k[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",lu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(fe.value,v=>(e.openBlock(),e.createElementBlock("label",{key:v.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:v.visible,disabled:s.value,onChange:F=>xo(v.id)},null,40,au),e.createElementVNode("span",su,e.toDisplayString(v.config.title||v.config.name||v.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",iu,[g.value.length||p.value?(e.openBlock(),e.createElementBlock("div",cu,[e.createElementVNode("div",du,[e.createElementVNode("div",uu,[k[10]||(k[10]=e.createTextVNode(" Тип: ",-1)),g.value.length<=1?(e.openBlock(),e.createElementBlock("span",pu,e.toDisplayString(p.value?Gr(p.value.type):g.value[0]?.label||"—"),1)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(g.value,(v,F)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:v.id},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["font-bold underline-offset-2",v.id===e.unref(R)?"text-blue-700 underline":"text-gray-700 hover:text-blue-700 hover:underline"]),onClick:D=>x0(v.id),disabled:s.value},e.toDisplayString(v.label),11,fu),F<g.value.length-1?(e.openBlock(),e.createElementBlock("span",mu,", ")):e.createCommentVNode("",!0)],64))),128))])]),e.createElementVNode("div",hu,[e.createElementVNode("div",gu,[k[11]||(k[11]=e.createTextVNode(" Центр: ",-1)),p.value?(e.openBlock(),e.createElementBlock("b",yu,e.toDisplayString(p.value.center.lng.toFixed(5))+", "+e.toDisplayString(p.value.center.lat.toFixed(5)),1)):(e.openBlock(),e.createElementBlock("b",bu,"—"))]),p.value&&p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",ku,[k[12]||(k[12]=e.createTextVNode(" Площа: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",xu,k[13]||(k[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:_0,disabled:s.value},[e.createVNode(e.unref(q.ZoomIn),{class:"h-3 w-3"})],8,wu),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:w0,disabled:s.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,_u)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-33669cd5"]]),Cu=["data-focus"],vu={class:"flex items-center"},Eu={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},Bu=["onClick","aria-label"],Vu={key:0,class:"absolute text-gray-500 truncate pl-2"},Su={class:"flex-1 min-w-[2px]"},$u=["placeholder"],Nu={class:"flex items-center shrink-0"},Au=["disabled"],Yo=e.defineComponent({__name:"vs-input-tag",props:e.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t;je(n.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),i=e.ref(!1),c=e.ref(""),d=e.useModel(o,"modelValue"),u=e.computed(()=>n.placeholder||"Add tag…"),p=e.computed(()=>d.value?.length===0&&c.value===""),g=e.computed(()=>!n.disabled&&d.value?.length>0),b=e.computed(()=>n.disabled),m=async()=>{b.value||await e.nextTick(()=>s.value?.focus())},h=W=>{const T=W.trim();T!==""&&(!d.value||!Array.isArray(d.value)?d.value=[T]:n.unique?d.value.includes(T)||(d.value=[...d.value,T]):d.value=[...d.value,T],c.value="")},y=()=>{const W=c.value;W.trim()!==""&&h(W),c.value=""},w=W=>{const T=d.value.slice();T.splice(W,1),r("update:modelValue",T)},x=()=>{r("update:modelValue",[])},C=()=>{b.value||(i.value=!0)},S=()=>{i.value=!1,!b.value&&y()},H=W=>{const{key:T}=W;T==="Enter"?(W.preventDefault(),y()):T==="Backspace"&&c.value===""&&d.value.length>0&&w(d.value.length-1)};return(W,T)=>(e.openBlock(),e.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:l,onClick:T[1]||(T[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass]),role:"group","aria-label":"Tag input"},[e.createElementVNode("div",{class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",i.value?"border-blue-500 ring-1 ring-blue-500":"",b.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":i.value?"true":"false",onClick:m},[e.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:a},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(E,$)=>(e.openBlock(),e.createElementBlock("div",{key:$,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",vu,[e.createElementVNode("div",Eu,e.toDisplayString(E),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(N=>w($),["stop"]),"aria-label":`Remove ${E}`},[e.createVNode(e.unref(q.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Bu)]))),128)),p.value?(e.openBlock(),e.createElementBlock("div",Vu,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Su,[b.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":T[0]||(T[0]=E=>c.value=E),onFocus:C,onBlur:S,onKeydown:H,placeholder:d.value&&d.value.length?"":void 0},null,40,$u)),[[e.vModelText,c.value]])])],512),e.createElementVNode("div",Nu,[g.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:b.value,onClick:e.withModifiers(x,["stop"])},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,Au)):e.createCommentVNode("",!0)])],10,Cu)],2)],512))}}),Mu={class:"relative flex gap-1 bg-white w-full"},Fu=["disabled","placeholder"],Xo=ye(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.inject("values"),n=o,r=e.useModel(o,"modelValue");function l(s){const i={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return s.toLowerCase().split("").map(c=>i[c]||c).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[n.parent||""]?.toString(),i=l(s);r.value=i.toString()};return(s,i)=>(e.openBlock(),e.createElementBlock("div",Mu,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:s.disabled,placeholder:s.placeholder,"onUpdate:modelValue":i[0]||(i[0]=c=>r.value=c),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Fu),[[e.vModelText,r.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:a}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),Du={class:"relative flex gap-1 bg-white w-full"},Tu=["disabled","placeholder"],Lu=["disabled"],Iu={key:0},Ru={key:1},Zo=ye(e.defineComponent({__name:"vs-input-codegen",props:e.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(!1),l=e.computed(()=>t.init!==!1),a=e.computed(()=>!!t.table&&!!t.code),s=()=>{if(!a.value)return"";const d=encodeURIComponent(String(t.table)),u=encodeURIComponent(String(t.code));return`/api/code-gen/${d}/${u}`},i=async()=>{if(!a.value||r.value)return;const d=s();if(d){r.value=!0;try{const p=await(await fetch(d)).text();n.value=p}finally{r.value=!1}}},c=()=>{l.value&&(n.value||i())};return e.onMounted(()=>{c()}),e.watch(()=>[t.table,t.code,t.init],()=>{c()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",Du,[e.withDirectives(e.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":u[0]||(u[0]=p=>n.value=p),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Tu),[[e.vModelText,n.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:r.value||d.disabled||!a.value,onClick:i},[r.value?(e.openBlock(),e.createElementBlock("span",Ru,"...")):(e.openBlock(),e.createElementBlock("span",Iu,"Gen"))],8,Lu)]))}}),[["__scopeId","data-v-6ee5237d"]]),Ou={class:"w-full"},Pu={ref:"sortableContainer",class:"flex flex-col gap-1"},zu=["onDragstart","onDrop"],ju={class:"cursor-move",type:"button"},Uu={class:"w-1/3"},Hu={class:"w-2/3"},qu=["onClick"],Ku={key:0,class:"text-[14px] text-gray-700"},Wu={class:"mt-2 w-full flex items-center"},Gu=["disabled"],Jo=ye(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=y=>`${y}-${Math.random().toString(36).substring(2,15)}`,r=e.inject("values"),l=o,a=t,s=l.addButtonText??"Додати",i=l.ignore??[],c=e.ref([]),d=e.ref(null);(()=>{const y=l.parent&&r?.value?.[l.parent]||l.modelValue||{};c.value=Object.entries(y).filter(([w])=>!i.includes(w)).map(([w,x])=>({id:n("key-value-"),key:w,value:x}))})();function p(y){d.value=y}function g(y){if(d.value===null||d.value===y)return;const w=c.value.splice(d.value,1)[0];c.value.splice(y,0,w),d.value=null}const b=e.computed(()=>c.value.some(y=>y.key&&!y.value||!y.key&&y.value)),m=()=>{c.value.push({id:n("key-value-"),key:"",value:""})},h=y=>{c.value=c.value.filter(w=>w.id!==y)};return e.watch(c,y=>{const w={};y.forEach(C=>{C.key&&C.value!==void 0&&(w[C.key]=C.value)});const x={};i.length&&i.forEach(C=>{x[C]=l.parent?r?.value?.[l.parent]?.[C]:void 0}),r?.value&&l.parent&&(r.value[l.parent]={...x,...w}),a("update:modelValue",w)},{deep:!0}),(y,w)=>(e.openBlock(),e.createElementBlock("div",Ou,[e.createElementVNode("div",Pu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.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:w[0]||(w[0]=e.withModifiers(()=>{},["prevent"])),onDrop:S=>g(C)},[e.createElementVNode("button",ju,[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",Uu,[e.createVNode(zt,{modelValue:x.key,"onUpdate:modelValue":S=>x.key=S,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",Hu,[e.createVNode(zt,{modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:S=>h(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,qu)],42,zu))),128))],512),c.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Ku," Дані для відображення відсутні ")),e.createElementVNode("div",Wu,[e.createElementVNode("button",{type:"button",onClick:m,disabled:b.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,Gu)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),Yu={class:"w-full"},Xu={ref:"sortableContainer",class:"flex flex-col gap-1"},Zu=["onDragstart","onDrop"],Ju=["disabled"],Qu={class:"flex-1"},ep=["onClick","disabled"],tp={key:0,class:"text-[14px] text-gray-700"},np={class:"mt-2 w-full flex items-center"},op=["disabled"],Qo=ye(e.defineComponent({__name:"vs-input-text-array",props:e.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),i=e.computed(()=>t.addButtonText??"Додати");let c=!1;const d=y=>`${y}-${Math.random().toString(36).substring(2,15)}`,u=y=>{const w=y??n.value??[];r.value=w.map((x,C)=>({id:r.value[C]?.id??d("text-array"),value:x??""}))};u(),e.watch(()=>n.value,y=>{if(c){c=!1;return}u(y||[])},{deep:!0}),e.watch(r,y=>{c=!0,n.value=y.map(w=>w.value).filter(w=>w!=null&&w!=="")},{deep:!0});const p=e.computed(()=>a.value||r.value.some(y=>!y.value));function g(){p.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function b(y){a.value||(r.value=r.value.filter(w=>w.id!==y))}function m(y){a.value||(l.value=y)}function h(y){if(a.value||l.value===null||l.value===y)return;const w=[...r.value],[x]=w.splice(l.value,1);w.splice(y,0,x),r.value=w,l.value=null}return(y,w)=>(e.openBlock(),e.createElementBlock("div",Yu,[e.createElementVNode("div",Xu,[(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=>m(C),onDragover:w[0]||(w[0]=e.withModifiers(()=>{},["prevent"])),onDrop:S=>h(C)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})],8,Ju),e.createElementVNode("div",Qu,[y.inputType==="text"?(e.openBlock(),e.createBlock(zt,{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),y.inputType==="tel"?(e.openBlock(),e.createBlock(Yn,{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),y.inputType==="email"?(e.openBlock(),e.createBlock(Gn,{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),y.inputType==="mask"?(e.openBlock(),e.createBlock(mn,{key:3,modelValue:x.value,"onUpdate:modelValue":S=>x.value=S,mask:y.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=>b(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,ep)],42,Zu))),128))],512),r.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",tp," Дані для відображення відсутні ")),e.createElementVNode("div",np,[e.createElementVNode("button",{type:"button",onClick:g,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(i.value),1)],8,op)])]))}}),[["__scopeId","data-v-2c229b1f"]]),rp={class:"flex items-center gap-2 w-full"},lp=["disabled"],ap=["disabled"],er=e.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=je(n.style),l=t,a=e.computed({get:()=>n.modelValue||"#000000",set:i=>l("update:modelValue",i)}),s=e.computed(()=>!!n.disabled);return(i,c)=>(e.openBlock(),e.createElementBlock("div",rp,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":c[0]||(c[0]=d=>a.value=d),disabled:s.value,ref:"color",class:e.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[i.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,lp),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":c[1]||(c[1]=d=>a.value=d),disabled:s.value},null,8,ap),[[e.vModelText,a.value]])]))}}),sp={class:"flex items-center gap-2 w-full"},ip=["min","max","step","disabled"],cp=["value","min","max","step","disabled"],tr=e.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=je(n.style),l=t,a=u=>{const p=Number(u),g=Number(n.min),b=Number(n.max);return Number.isNaN(p)?g:Math.min(b,Math.max(g,p))},s=e.computed({get:()=>a(n.modelValue??n.min),set:u=>l("update:modelValue",a(u))}),i=u=>{const p=u.target,g=a(p.value);p.value=String(g),l("update:modelValue",g)},c=u=>{Number(n.min)>=0&&u.key==="-"&&u.preventDefault()},d=e.computed(()=>!!n.disabled);return(u,p)=>(e.openBlock(),e.createElementBlock("div",sp,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":p[0]||(p[0]=g=>s.value=g),min:u.min,max:u.max,step:u.step,disabled:d.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[u.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")])},null,10,ip),[[e.vModelText,s.value]]),e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number",value:s.value,min:u.min,max:u.max,step:u.step,onInput:i,onKeydown:c,disabled:d.value},null,40,cp)]))}}),dp=["placeholder","disabled","name"],up=["type","value","onInput","placeholder","disabled"],pp=["onClick"],nr=e.defineComponent({__name:"vs-input-array",props:e.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.ref(t.count),r=e.computed(()=>t.limit),{inputClass:l}=je(t.style),a=e.useModel(o,"modelValue"),s=e.computed(()=>!!t.disabled),i=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const h=a.value?.length??0;h<n.value&&(a.value=[...a.value??[],...Array(n.value-h)])});const c=e.ref({}),d=e.ref({});function u(h,y){h&&(c.value[y]=h)}async function p(h,y){if(!h||t.inputType!=="mask")return;const{default:w}=await Promise.resolve().then(()=>Pn);d.value[y]&&d.value[y].destroy(),d.value[y]=w(h,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[y].on("accept",()=>{const x=[...a.value||[]];x[y]=t.unmask?d.value[y].unmaskedValue:d.value[y].value,a.value=x}),d.value[y].on("complete",()=>{const x=[...a.value||[]];x[y]=t.unmask?d.value[y].unmaskedValue:d.value[y].value,a.value=x}),a.value?.[y]&&(d.value[y].value=a.value[y])}function g(h,y){if(s.value)return;const w=h.target.value??null,x=[...a.value];x[y]=t.inputType==="text"?w:Number(w),a.value=x}function b(){n.value+=1;const h=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,h],t.inputType==="mask"&&setTimeout(()=>{const y=n.value-1;c.value[y]&&p(c.value[y],y)},0)}function m(h){if(n.value>1){d.value[h]&&(d.value[h].destroy(),delete d.value[h]),n.value-=1,a.value=a.value.filter((w,x)=>x!==h);const y={};Object.keys(d.value).forEach(w=>{const x=parseInt(w,10);x>h?y[x-1]=d.value[x]:x<h&&(y[x]=d.value[x])}),d.value=y}}return e.onMounted(()=>{if(t.inputType==="mask")for(let h=0;h<n.value;h+=1)c.value[h]&&p(c.value[h],h)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(h=>{h&&h.destroy()})}),e.watch(()=>t.mask,h=>{t.inputType==="mask"&&Object.values(d.value).forEach(y=>{y&&y.updateOptions({mask:h,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,h=>{t.inputType==="mask"&&h&&h.forEach((y,w)=>{d.value[w]&&d.value[w].value!==y&&(d.value[w].value=y||"")})},{deep:!0}),(h,y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["grid gap-2",`grid-cols-${r.value}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,w=>(e.openBlock(),e.createElementBlock("div",{key:w,class:"flex items-center gap-2 w-full"},[h.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:x=>u(x,w-1),placeholder:h.placeholder,disabled:h.disabled,name:`${h.name}[${w-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,dp)):(e.openBlock(),e.createElementBlock("input",{key:1,type:h.inputType,value:a.value?.[w-1],onInput:x=>g(x,w-1),placeholder:i.value,disabled:s.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,up)),!h.disabled&&w===n.value&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(b,["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),!h.disabled&&n.value>1&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(x=>m(w-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,pp)):e.createCommentVNode("",!0)]))),128))],2))}}),fp={class:"flex gap-1 w-full"},mp=["aria-expanded","data-focus"],hp=["placeholder","disabled","readonly"],gp={class:"max-h-full"},yp=["onClick","disabled"],bp={key:0,class:"px-3 py-2 text-sm text-stone-500"},kp=["disabled"],xp={class:"flex flex-col gap-1"},wp=["onDragstart","onDrop"],_p=["disabled"],Cp=["title"],vp=["disabled","onClick","aria-label"],Ep={key:0,class:"text-xs text-stone-500"},Bn=ye(e.defineComponent({__name:"vs-input-array-select",props:e.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},add:{},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t,l=e.useModel(o,"modelValue"),a=e.ref([]),s=e.ref(n.options??[]),i=e.ref({}),c=e.ref({}),d=e.ref({keyword:"",parent:null}),u=e.ref(""),p=e.ref(!1),g=e.ref(null),b=e.ref(null),m=e.ref(null),h=e.ref(null),y=e.ref(null),w=e.ref({});let x=!1,C=!1;const S=e.inject("values"),H=e.computed(()=>!!n.disabled),W=e.computed(()=>n.placeholder??"Оберіть значення"),T=e.computed(()=>n.search!==!1),E=e.computed(()=>{const _=n.parent??n.parentValue;return _?String(_):""}),$=e.computed(()=>E.value?S?.value?.[E.value]??null:null),N=_=>_==null?"__null__":String(_),V=_=>{if(!_)return"";const A=_.label??_.text??_.name??_.ua??_.en;return A?String(A):_.id!==void 0&&_.id!==null?String(_.id):""},M=_=>{const A=N(_);return c.value[A]||(c.value[A]=`array-select-${A}-${Math.random().toString(36).slice(2,8)}`),c.value[A]},O=e.computed(()=>new Set(a.value.map(_=>N(_.id)))),B=e.computed(()=>{const _=O.value;let A=[...s.value];if(!n.data&&u.value.trim()){const z=u.value.toLowerCase();A=A.filter(re=>V(re).toLowerCase().includes(z))}return A.filter(z=>!_.has(N(z.id)))}),K=()=>{if(!n.data)return"";const _=n.prefix??"api",A=n.api??`/${_}/suggest/${n.data}`;return`${n.host??""}${A}`},I=()=>{a.value.length&&(x=!0,a.value=a.value.map(_=>({..._,text:i.value[N(_.id)]??_.text})))},G=_=>{const A=N(_.id),z=V(_);z&&(i.value[A]=z)},L=_=>{s.value=_?[..._]:[],_?.forEach(G),I()},Z=_=>{if(!_.length)return;const A=new Map(s.value.map(z=>[N(z.id),z]));_.forEach(z=>{const re=N(z.id);A.set(re,z),G(z)}),s.value=Array.from(A.values()),I()},oe=async(_="")=>{if(!n.data)return[];const A=K();if(!A)return[];const z=new URLSearchParams;z.set("json","1"),_&&z.set("key",_),n.start===1&&z.set("start","1"),$.value!==null&&$.value!==void 0&&$.value!==""&&z.set("parent",String($.value));try{return(await(await fetch(`${A}?${z.toString()}`)).json())?.data??[]}catch{return[]}},be=async _=>{if(!n.data||!_.length)return[];const A=K();if(!A)return[];const z=Array.from(new Set(_.map(ke=>N(ke)))),re=new URLSearchParams;re.set("json","1"),re.set("val",z.join(",")),n.start===1&&re.set("start","1"),$.value!==null&&$.value!==void 0&&$.value!==""&&re.set("parent",String($.value));try{const Se=(await(await fetch(`${A}?${re.toString()}`)).json())?.data??[];return Z(Se),Se}catch{return[]}},pe=async _=>{if(_==null||_==="")return null;const A=N(_),z=s.value.find(ke=>N(ke.id)===A);if(z)return z;const[re]=await be([_]);return re??null},ee=async(_="",{force:A=!1}={})=>{if(!n.data)return;const z=$.value??null;if(!A&&d.value.keyword===_&&d.value.parent===z&&s.value.length>0)return;d.value={keyword:_,parent:z};const ke=await oe(_);L(ke)},me=((_,A=200)=>{let z;return(...re)=>{z&&clearTimeout(z),z=setTimeout(()=>_(...re),A)}})(async _=>{n.data&&await ee(_,{force:!0})},250),Q=e.ref(null),ie=()=>{if(!m.value)return;const _=m.value.getBoundingClientRect(),A=window.innerHeight??document.documentElement.clientHeight,z=window.innerWidth??document.documentElement.clientWidth,re=8,ke=8,Me=n.maxHeight??280,Se=A-_.bottom-ke-re,We=_.top-ke-re,st=Se>=We,Ge=Math.max(z-re*2,0);let{width:ze}=_;Ge>0&&ze>Ge&&(ze=Ge);let{left:nt}=_;nt+ze+re>z&&(nt=z-ze-re),nt=Math.max(nt,re);const Ht=Math.min(Me,Math.max(st?Se:We,50));w.value={position:"fixed",left:`${nt}px`,width:`${ze}px`,maxHeight:`${Ht}px`,transform:st?"none":"translateY(-100%)",top:st?`${_.bottom+ke}px`:`${_.top-ke}px`}},fe=async(_="click")=>{H.value||p.value||(Q.value=_,await ee(u.value.trim()),p.value=!0,await e.nextTick(),ie(),y.value?.focus())},Ee=()=>{p.value=!1,Q.value=null,e.nextTick(()=>{y.value?.blur()})},$e=async _=>{if(_.stopPropagation(),!H.value){if(p.value){if(Q.value==="focus"){Q.value=null;return}Ee();return}await fe("click")}},Pe=_=>{_.key==="Escape"&&Ee()},Fe=_=>{if(!p.value)return;const A=_.target;h.value?.contains(A)||Ee()},_e=_=>{const A=_.target;b.value?.contains(A)||h.value?.contains(A)||Ee()},Ne=_=>{if(_.key==="Escape"){_.preventDefault(),Ee();return}if(_.key==="Enter"){_.preventDefault();const A=B.value[0];A&&Be(A)}},Be=_=>{if(!_)return;const A=N(_.id);if(O.value.has(A))return;G(_);const z={id:_.id,text:V(_)||String(_.id??""),key:M(_.id)};a.value=[...a.value,z],Ae(_),u.value="",e.nextTick(()=>{y.value?.focus()})},Ae=_=>{const A=a.value.map(z=>z.id);r("value-selected",{name:n.name,value:A,option:_})},Re=_=>{if(H.value)return;const A=a.value.filter(z=>N(z.id)!==N(_));a.value=A},{isOpenAdd:Oe,addData:tt,addSchema:U,addForm:J,addTitle:ne,addOption:P,onAddValue:Y}=Io({props:n,fetchOptionByValue:pe,optionsList:s,selectedOption:e.ref(null),modelValue:l,onCreated:async(_,A)=>{const z=_??await pe(A),re=z?.id??A;O.value.has(N(re))||(z&&G(z),a.value=[...a.value,{id:re,text:z?V(z):String(re),key:M(re)}],Ae(z??null))}}),we=_=>{H.value||(g.value=_)},Ve=_=>{if(H.value||g.value===null||g.value===_)return;const A=[...a.value],[z]=A.splice(g.value,1);A.splice(_,0,z),g.value=null,a.value=A},Ce=async()=>{const A=(Array.isArray(l.value)?[...l.value]:[]).filter(re=>re!=null);if(n.data&&A.length){const re=A.filter(ke=>!i.value[N(ke)]);re.length&&await be(re)}const z=A.map(re=>({id:re,text:i.value[N(re)]??String(re),key:M(re)}));x=!0,a.value=z};e.watch(a,_=>{if(x){x=!1;return}const A=_.map(z=>z.id);C=!0,l.value=A,r("change",A)},{deep:!0}),e.watch(l,()=>{if(C){C=!1;return}Ce()},{deep:!0}),e.watch(u,_=>{!n.data||!p.value||me(_.trim())}),e.watch(H,_=>{_&&Ee()}),e.watch(()=>n.options,async _=>{n.data||(L(_??[]),await Ce())},{immediate:!0,deep:!0}),e.watch(()=>n.data,async _=>{_&&(await ee(u.value.trim()),await Ce())},{immediate:!0});const R=e.ref(!1);return e.watch($,async()=>{if(n.data){if(!R.value){R.value=!0;return}a.value=[],await ee(u.value.trim()),await Ce()}}),e.onMounted(async()=>{document.addEventListener("click",_e,!0),window.addEventListener("keydown",Pe),window.addEventListener("scroll",Fe,!0),await Ce()}),e.onUnmounted(()=>{document.removeEventListener("click",_e,!0),window.removeEventListener("keydown",Pe),window.removeEventListener("scroll",Fe,!0)}),(_,A)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(ue.VsModal),{visible:e.unref(Oe),"onUpdate:visible":A[1]||(A[1]=z=>e.isRef(Oe)?Oe.value=z:null),class:"z-[1000]",title:e.unref(ne),buttonText:"Додати",onDone:e.unref(P)},{default:e.withCtx(()=>[e.createVNode(at,{schema:e.unref(U),modelValue:e.unref(tt),"onUpdate:modelValue":A[0]||(A[0]=z=>e.isRef(tt)?tt.value=z:null),ref_key:"addForm",ref:J},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),e.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:b},[e.createElementVNode("div",fp,[e.createElementVNode("div",{class:"relative flex-1",onClick:A[4]||(A[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",p.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",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:$e},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:y,"onUpdate:modelValue":A[2]||(A[2]=z=>u.value=z),placeholder:W.value,disabled:H.value,readonly:!T.value,onFocus:A[3]||(A[3]=()=>fe("focus")),onKeydown:Ne,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,hp),[[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,mp),(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:h,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(w.value)},[e.createElementVNode("div",gp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(B.value,z=>(e.openBlock(),e.createElementBlock("button",{key:N(z.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(re=>Be(z),["stop"]),disabled:H.value},e.toDisplayString(V(z)),9,yp))),128)),B.value.length===0?(e.openBlock(),e.createElementBlock("p",bp," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:A[5]||(A[5]=(...z)=>e.unref(Y)&&e.unref(Y)(...z)),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"}),A[8]||(A[8]=e.createElementVNode("span",null,"Додати",-1))],8,kp)):e.createCommentVNode("",!0)]),e.createElementVNode("div",xp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(z,re)=>(e.openBlock(),e.createElementBlock("div",{key:z.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":g.value===re}]),draggable:"true",onDragstart:ke=>we(re),onDragover:A[6]||(A[6]=e.withModifiers(()=>{},["prevent"])),onDrop:ke=>Ve(re),onDragend:A[7]||(A[7]=ke=>g.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,_p),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:z.text},e.toDisplayString(z.text),9,Cp),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(ke=>Re(z.id),["stop"]),"aria-label":`Видалити ${z.text}`},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,vp)],42,wp))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",Ep,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-da4b4da7"]]),Bp={class:"flex items-center gap-2 w-full"},Vp={class:"relative flex-1"},Sp=["placeholder","disabled","onKeydown"],$p=["disabled"],Np={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},Ap={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},Mp={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},Fp=["onClick"],Dp={key:0,class:"p-4 text-sm text-gray-500"},or=e.defineComponent({__name:"vs-input-address",props:e.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(o,{emit:t}){const n=/{{\s*([^}]+?)\s*}}/g,r=o,l=t,{inputClass:a}=je(r.style),s=e.useModel(o,"modelValue"),i=e.computed({get:()=>s.value,set:T=>{s.value=T}}),c=e.ref(!1),d=e.ref([]),u=e.ref(!1),p=e.ref(null);e.watch(u,T=>{typeof document>"u"||(T?(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 g=e.computed(()=>r.placeholder??""),b=e.computed(()=>!!r.disabled),m=T=>{if(!T)return null;if(Array.isArray(T))return T;if(typeof T=="string"){const E=T.split(",").map($=>$.trim()).filter(Boolean);return E.length!==4?null:E.map(Number)}return null},h=e.computed(()=>{const T=m(r.bbox);if(!T||T.length!==4)return null;const E=T.map(Number);return E.some($=>Number.isNaN($))?null:E}),y=e.computed(()=>{const T=h.value;if(!T)return"";const[E,$,N,V]=T;return`${E},${Math.max($,V)},${N},${Math.min($,V)}`});e.computed(()=>y.value?"1":"0");const w=e.inject("values");function x(){!b.value&&i.value.trim()&&C()}async function C(){const T=(i.value||"").trim();if(!T)return;let E=T;if(r.includes?.length&&w?.value){const N=r.includes.map(V=>w.value?.[V]).filter(Boolean);N.length&&(E=`${N.join(", ")}, ${T}`)}const $=W(E);if($){c.value=!0;try{const V=await(await fetch($)).json();d.value=Array.isArray(V)?V:[],u.value=!0}catch(N){console.error("Address search error:",N)}finally{c.value=!1}}}function S(){u.value=!u.value}function H(T){if(!T)return;u.value=!1;const E=parseFloat(T.lat),N={type:"Point",coordinates:[parseFloat(T.lon),E]};r.geom&&w?.value&&(w.value[r.geom]=N),l("update:geom",N)}function W(T){if(!r.api)return"";const E={value:encodeURIComponent(T),bbox:h.value?h.value.join(","):""};return r.api.replace(n,($,N)=>E[N.trim()]??"")}return(T,E)=>(e.openBlock(),e.createElementBlock("div",Bp,[e.createElementVNode("div",Vp,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":E[0]||(E[0]=$=>i.value=$),placeholder:g.value,disabled:b.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,Sp),[[e.vModelText,i.value]]),d.value.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick: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:c.value||!i.value?.trim()},[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,$p),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[u.value?(e.openBlock(),e.createElementBlock("div",Np,[e.createElementVNode("div",Ap,[e.createElementVNode("div",Mp,[E[2]||(E[2]=e.createElementVNode("span",null,"Результати пошуку",-1)),e.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:E[1]||(E[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,($,N)=>(e.openBlock(),e.createElementBlock("li",{key:N,onClick:V=>H($),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString($.display_name),9,Fp))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Dp," Не знайдено результатів "))])])):e.createCommentVNode("",!0)]))]))}}),Tp={class:"vs-datalist space-y-3"},Lp={class:"space-y-3"},Ip=["onClick","disabled"],Rp={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Op=["disabled"],Pp=ye(e.defineComponent({__name:"vs-input-datalist",props:e.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>Array.isArray(n.value)?n.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(h=>({...h,disabled:t.disabled||h.disabled}))??[]),s=e.computed(()=>a.value.map(h=>m(h))),i=e.computed(()=>t.disabled?!1:t.maxItems?r.value.length<t.maxItems:!0),c=e.computed(()=>t.disabled||r.value.length<=(t.minItems||0));e.watch(()=>r.value.length,()=>{d(),u()},{immediate:!0}),e.watch(()=>t.schema,u,{immediate:!0,deep:!0});function d(){const h=r.value.length;l.value.length<h?l.value=[...l.value,...Array.from({length:h-l.value.length},()=>eo())]:l.value.length>h&&l.value.splice(h)}function u(){if(!t.minItems||r.value.length>=t.minItems)return;const h=t.minItems-r.value.length,y=Array.from({length:h},p);n.value=[...r.value,...y]}function p(){const h={};return a.value.forEach(y=>{h[y.name]=y?.default??null}),h}function g(){i.value&&(n.value=[...r.value,p()],d())}function b(h){c.value||(n.value=r.value.filter((y,w)=>w!==h),d(),u())}function m(h){return{...h}}return(h,y)=>(e.openBlock(),e.createElementBlock("div",Tp,[e.createElementVNode("div",Lp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(w,x)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[x],class:"flex items-center gap-3"},[e.createVNode(at,{schema:s.value,layout:"inline",navigation:!1,values:r.value[x],"onUpdate:values":C=>r.value[x]=C,"form-id":l.value[x]},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:C=>b(x),disabled:c.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Ip)]))),128)),r.value.length===0?(e.openBlock(),e.createElementBlock("div",Rp,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:g,disabled:!i.value},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Op)]))}}),[["__scopeId","data-v-260e3e66"]]),zp={class:"vs-dataform space-y-4"},jp=["draggable","onDragstart","onDragover","onDragenter","onDrop"],Up={class:"flex items-center gap-2"},Hp=["onClick"],qp={class:"text-sm font-medium text-gray-700"},Kp={class:"flex items-center gap-2"},Wp=["title","onClick","disabled"],Gp=["title","onClick","disabled"],Yp={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Xp=["disabled"],Zp=ye(e.defineComponent({__name:"vs-input-dataform",props:e.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),i=e.ref(null),c=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),u=e.computed(()=>t.emptyLabel??"Ще немає груп"),p=e.computed(()=>t.schema?.map(ee=>({...ee,disabled:t.disabled||ee.disabled}))??[]),g=e.computed(()=>p.value.map(ee=>$(ee))),b=e.computed(()=>t.view==="accordion"),m=e.computed(()=>!!(t.collapsible||b.value)),h=e.computed(()=>t.draggable!==!1),y=e.computed(()=>t.disabled?!1:t.maxGroups?n.value.length<t.maxGroups:!0),w=e.computed(()=>t.disabled||n.value.length<=(t.minGroups||0));e.watch(()=>n.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 ee=n.value.length;r.value.length<ee?r.value=[...r.value,...Array.from({length:ee-r.value.length},()=>eo())]:r.value.length>ee&&r.value.splice(ee)}function C(){const ee=n.value.length;b.value?ee===0?a.value=-1:a.value>=ee?a.value=ee-1:a.value<0&&(a.value=0):l.value.length<ee?l.value=[...l.value,...Array.from({length:ee-l.value.length},()=>!1)]:l.value.length>ee&&l.value.splice(ee)}function S(){if(!t.minGroups||n.value.length>=t.minGroups)return;const ee=t.minGroups-n.value.length,ae=Array.from({length:ee},H);n.value=[...n.value,...ae],C()}function H(){const ee={};return p.value.forEach(ae=>{ee[ae.name]=ae?.default??null}),ee}function W(){y.value&&(n.value=[...n.value,H()],x(),C())}function T(ee){w.value||(n.value=n.value.filter((ae,me)=>me!==ee),x(),b.value?a.value>=n.value.length&&(a.value=n.value.length-1):l.value.splice(ee,1),S())}function E(ee){if(t.disabled)return;const ae=JSON.parse(JSON.stringify(n.value[ee]??{}));n.value=[...n.value.slice(0,ee+1),ae,...n.value.slice(ee+1)],x(),b.value?a.value>ee&&(a.value+=1):l.value.splice(ee+1,0,l.value[ee]??!1)}function $(ee){return{...ee}}function N(ee){return b.value?a.value===-1&&ee===0?!1:a.value!==ee:!!l.value[ee]}function V(ee){if(m.value){if(b.value){a.value=ee;return}l.value[ee]=!l.value[ee]}}function M(ee,ae){if(!h.value||t.disabled){ae.preventDefault();return}s.value=ee,i.value=ee,c.value={groups:JSON.parse(JSON.stringify(n.value)),keys:[...r.value],states:[...l.value]},ae.dataTransfer?.setData("text/plain",String(ee)),ae.dataTransfer?.setDragImage?.(ae.currentTarget,0,0)}function O(ee,ae){!h.value||t.disabled||s.value!==null&&Z(ee,ae)}function B(ee,ae){Z(ee,ae)}function K(ee){!h.value||t.disabled||pe()}function I(){c.value&&L(),s.value=null,i.value=null,c.value=null}function G(ee,ae){const me=[...n.value],[Q]=me.splice(ee,1);me.splice(ae,0,Q),n.value=me;const ie=[...r.value],[fe]=ie.splice(ee,1);if(ie.splice(ae,0,fe),r.value=ie,b.value)a.value===ee&&(a.value=ae);else{const Ee=[...l.value],[$e]=Ee.splice(ee,1);Ee.splice(ae,0,$e),l.value=Ee}}function L(){c.value&&(n.value=c.value.groups,r.value=c.value.keys,l.value=c.value.states,c.value=null,i.value=null)}function Z(ee,ae){if(s.value===null)return;const me=oe(ee,ae);i.value=me,be(me)}function oe(ee,ae){if(!ae?.currentTarget)return ee;const me=ae.currentTarget.getBoundingClientRect(),ie=ae.clientY-me.top>me.height/2?ee+1:ee;return Math.max(0,Math.min(ie,n.value.length))}function be(ee){const ae=s.value;if(ae===null)return;let me=ee;if(me>n.value.length&&(me=n.value.length),me===ae||me===ae+1)return;const Q=me>ae?me-1:me;G(ae,Q),s.value=Q,i.value=me>ae?Q+1:Q}function pe(){c.value=null,s.value=null,i.value=null}return(ee,ae)=>(e.openBlock(),e.createElementBlock("div",zp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(me,Q)=>(e.openBlock(),e.createElementBlock("div",{key:r.value[Q],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":N(Q)?"pt-6 px-6":"p-6"]]),draggable:h.value&&!t.disabled,onDragstart:ie=>M(Q,ie),onDragend:I,onDragover:e.withModifiers(ie=>O(Q,ie),["prevent"]),onDragenter:e.withModifiers(ie=>B(Q,ie),["prevent"]),onDrop:e.withModifiers(ie=>K(),["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"&&!N(Q)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",Up,[h.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),m.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:ie=>V(Q)},[e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",N(Q)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,Hp)):e.createCommentVNode("",!0),e.createElementVNode("div",qp,e.toDisplayString(`${d.value} (${Q+1})`),1)]),e.createElementVNode("div",Kp,[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:ie=>E(Q),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(q.Copy),{class:"h-4 w-4"})],8,Wp),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:ie=>T(Q),disabled:w.value,draggable:"false"},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Gp)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(at,{class:"vs-dataform__form",schema:g.value,layout:"inline",navigation:!1,values:n.value[Q],"onUpdate:values":ie=>n.value[Q]=ie,"form-id":r.value[Q],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!N(Q)]])],42,jp))),128)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",Yp,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:W,disabled:!y.value},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Xp)]))}}),[["__scopeId","data-v-cfbcfed8"]]),Vn="__vs_form_monaco_loader__",Rt="__vs_form_monaco_script_loader__",Sn="__vs_form_monaco_editor_loader__",to=e.defineComponent({__name:"vs-input-monaco",props:e.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:t}){const n=o,r=e.useModel(o,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof n.height=="number"?`${n.height}px`:n.height||"280px");let s=null,i=null,c=!1;const d=()=>{if(i)return Promise.resolve(i);if(typeof window>"u")return Promise.resolve(null);const m=window;if(m.monaco?.editor?.create)return i=m.monaco,Promise.resolve(i);if(m[Vn])return m[Vn];const y=(async()=>{const w=S=>{if(Array.from(document.styleSheets||[]).some(T=>T?.href?.includes(S)))return;const W=document.createElement("link");W.rel="stylesheet",W.href=S,document.head.appendChild(W)},x=S=>{if(m[Rt]?.[S])return m[Rt][S];m[Rt]||={};const H=Array.from(document.scripts).find(W=>W.src===S);return H?(m[Rt][S]=new Promise((W,T)=>{const E=H.readyState;if(H.dataset.loaded==="true"||E==="loaded"||E==="complete"){W();return}H.addEventListener("load",()=>{H.dataset.loaded="true",W()},{once:!0}),H.addEventListener("error",$=>T($),{once:!0})}),m[Rt][S]):(m[Rt][S]=new Promise((W,T)=>{const E=document.createElement("script");E.src=S,E.async=!0,E.onload=()=>{E.dataset.loaded="true",W()},E.onerror=$=>T($),document.body.appendChild(E)}),m[Rt][S])},C="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return w(`${C}/editor/editor.main.min.css`),await x(`${C}/loader.min.js`),m[Sn]||(m[Sn]=new Promise((S,H)=>{window.require.config({paths:{vs:C}}),window.require(["vs/editor/editor.main"],()=>{i=window.monaco,m.monaco=i,S(i)},W=>H(W))}).catch(S=>{throw delete m[Sn],S})),m[Sn]})().catch(w=>{throw delete m[Vn],w});return m[Vn]=y,y},u=()=>{!l.value||!i||(s&&(s.dispose(),s=null),s=i.editor.create(l.value,{value:r.value||"",language:n.syntax,theme:n.theme,automaticLayout:!0,minimap:{enabled:!!n.minimap},readOnly:!!n.disabled}),s.onDidChangeModelContent(()=>{c||(r.value=s.getValue())}))},p=()=>{s?.focus()},g=()=>s,b=()=>i;return e.watch(()=>r.value,m=>{if(!s)return;const h=s.getValue();m!==h&&(c=!0,s.setValue(m||""),c=!1)}),e.watch(()=>n.syntax,m=>{!s||!i||i.editor.setModelLanguage(s.getModel(),m||"xml")}),e.watch(()=>n.theme,m=>{i&&i.editor.setTheme(m||"vs-light")}),e.watch(()=>n.disabled,m=>{s&&s.updateOptions({readOnly:!!m})}),e.watch(()=>n.minimap,m=>{s&&s.updateOptions({minimap:{enabled:!!m}})}),e.onMounted(async()=>{try{const m=await d();if(!m||!m.editor)return;i=m,u()}catch(m){console.error("Failed to load Monaco editor",m)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:p,getEditor:g,getMonaco:b}),(m,h)=>(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))}}),rr={VsInputText:zt,VsInputRadio:Xn,VsInputInlineSelect:kn,"vs-input-text":zt,"vs-input-password":xl,"vs-input-textarea":Oo,"vs-input-richtext":Po,"vs-input-mask":mn,"vs-input-number":Vo,"vs-input-radio":Xn,"vs-input-select":Qn,"vs-input-inline-select":kn,"inline-select":kn,"vs-input-switcher":Kn,"vs-input-static":Wn,"vs-input-container":Lo,"vs-input-date":ga,"vs-input-checkbox":No,"vs-input-file":Fo,"vs-input-file2":Jn,file2:Jn,File2:Jn,"vs-input-html":Wn,"vs-input-email":Gn,"vs-input-tel":Yn,"vs-input-datatable":zo,"vs-input-map":Go,"vs-input-file-list":Do,"vs-input-tags":Yo,"vs-input-slug":Xo,"vs-input-codegen":Zo,"vs-input-key-value":Jo,"vs-input-text[]":Qo,"vs-input-range":tr,"vs-input-color":er,"vs-input-native-select":Qn,VsInputArraySelect:Bn,"vs-input-array":nr,"vs-input-array-select":Bn,"array-select":Bn,"vs-input-address":or,"vs-input-datalist":Pp,"vs-input-dataform":Zp,"vs-input-monaco":to},Jp=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(o){const t=o,n=e.inject("values");async function r(){try{if(!t.api)return;const l=t.api.replace("{{value}}",t.value),a=await fetch(l);if(!a.ok){ue.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!n)return;for(const[i,c]of Object.entries(t.set))n.value[i]=s.result[c]}catch(l){console.error(t.error,l)}}return(l,a)=>(e.openBlock(),e.createElementBlock("button",{onClick:r,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},e.toDisplayString(l.button),1))}}),Qp={class:"flex flex-col gap-1 w-full"},ef={class:"w-full"},tf=["disabled"],nf=["innerHTML"],of=2e3,rf=10,lr=e.defineComponent({__name:"vs-compact-form-layout",props:e.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:e.mergeModels(["value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),l=t,a=e.computed(()=>bl[`${n.layout}`]),s=["label","placeholder","info","description","text","html"],i=e.ref($()),c=e.computed(()=>W(n.item,i.value)),d=e.computed(()=>rr?.[`vs-input-${n.item.type}`]),u=e.inject("field-props"),p=e.computed(()=>{const V=e.unref(d);if(!V)return new Set;const M=V.props??V.__vccOpts?.props;if(!M)return new Set;const O=Array.isArray(M)?M:Object.keys(M);return new Set(O)}),b=[...["min","max","step"],"api","set","mask"],m=e.computed(()=>{const V={...c.value??{}},M=n.item?.name;M&&u?.value?.[M]&&Object.assign(V,u.value[M]);const O=p.value;let B;return O.size?B=Object.fromEntries(Object.entries(V).filter(([K])=>O.has(K))):B=V,b.forEach(K=>{const I=V[K];I!=null&&(B[K]=I)}),B}),h=V=>{const M=typeof V=="object"&&V!==null?V:{value:V};l("value-selected",{...M,name:M.name??n.item?.name})},y=/{{\s*([^}]+?)\s*}}/g,w=e.inject("values"),x=e.ref(!1),C=e.computed(()=>{const V=n.item?.api,M=n.item?.type?.toLowerCase();return typeof V=="string"&&V.trim().length>0&&(M==="text"||M==="mask")});function S(V,M){if(!(V==null||!M))return M.split(".").reduce((O,B)=>O?.[B.trim()],V)}async function H(){const V=String(r.value??"").trim();if(!V)return;const M=(n.item?.api??"").trim();if(!M)return;const O=M.replace(y,(B,K)=>K.trim()==="value"?encodeURIComponent(V):"");x.value=!0;try{let B=await fetch(O),K=0;for(;B.status===202&&K<rf;)K+=1,await new Promise(oe=>{setTimeout(oe,of)}),B=await fetch(O);if(B.status===202){ue.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!B.ok){ue.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const I=await B.json(),G=I?.result!==void 0?I.result:I,L=n.item?.set;if(!L||!w?.value)return;const Z=n.item?.name;Object.entries(L).forEach(([oe,be])=>{if(!oe)return;let pe=be;Z&&pe.startsWith(`${Z}.`)&&(pe=pe.slice(Z.length+1));const ee=S(G,pe);w.value[oe]=ee??null})}catch(B){console.error("API lookup error:",B),ue.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{x.value=!1}}e.onMounted(()=>{i.value=$(),window.addEventListener("storage",N)}),e.onUnmounted(()=>{window.removeEventListener("storage",N)});function W(V,M){if(!V)return{};const O={...V};return s.forEach(B=>{const K=E(V,B,M);K!=null&&(O[B]=K)}),Array.isArray(V.options)&&(O.options=V.options.map(B=>T(B,M))),O}function T(V,M){if(!V)return V;const O={...V},B=E(V,"label",M),K=E(V,"text",M);return B!=null&&(O.label=B),K!=null?O.text=K:B!=null&&(O.text=B),O}function E(V,M,O){const B=`${M}:${O}`;if(V?.[B]!=null)return V[B];if(M==="label"&&V?.[O]!=null)return V[O];if(V?.[M]!=null)return V[M];if(M==="label"){if(V?.ua!=null)return V.ua;if(V?.en!=null)return V.en}if(M==="text"||M==="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 N(){i.value=$()}return(V,M)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:c.value.ua,error:n.error||"",item:c.value,columns:n.columns,label:c.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${n.item.type}-component`])},[e.createElementVNode("div",Qp,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":C.value}])},[e.createElementVNode("div",ef,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),e.mergeProps(m.value,{modelValue:r.value,"onUpdate:modelValue":M[0]||(M[0]=O=>r.value=O),onValueSelected:h}),null,16,["modelValue"]))]),C.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:x.value||!r.value?.toString().trim(),onClick:H},[x.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,tf)):e.createCommentVNode("",!0)],2),c.value.description&&n.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:c.value.description},null,8,nf)):e.createCommentVNode("",!0)]),c.value.behavior?.api&&c.value.behavior?.button?(e.openBlock(),e.createBlock(Jp,e.mergeProps({key:0},c.value.behavior,{value:r.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),lf={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},af={class:"vs-compact-form-navigation__rail mt-[6px]"},sf=["onClick"],cf=ye(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(o,{expose:t}){const n=o,r=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!n.enabled),i=e.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),c=e.computed(()=>{const V=n.width;if(V==null)return{};const M=typeof V=="number"?`${V}px`:`${V}`;return{width:M,minWidth:M}});let d=null,u=0,p=0,g=null,b=null,m=null;const h=()=>$(),y=()=>x();e.watch(()=>n.target,async V=>{if(W(),!V){g=null,r.value=[],l.value="";return}g=V,s.value&&(await e.nextTick(),H(V),x())},{immediate:!0}),e.watch(()=>n.scrollContainer,V=>{if(!s.value){b=V??null;return}w(V??null),e.nextTick(()=>x())},{immediate:!0}),e.onMounted(()=>{n.scrollContainer||w(null),x()}),e.onBeforeUnmount(()=>{W(),w(null,!0),g=null,typeof window<"u"&&(u&&window.cancelAnimationFrame(u),p&&window.cancelAnimationFrame(p))});function w(V,M=!1){if(m&&(m(),m=null),M){b=null;return}if(b=V??null,typeof window>"u")return;const O=V??window,B=window;O.addEventListener("scroll",h,{passive:!0}),B.addEventListener("resize",y),m=()=>{O.removeEventListener("scroll",h),B.removeEventListener("resize",y)}}function x(){if(!s.value||!g)return;u&&typeof window<"u"&&window.cancelAnimationFrame(u);const V=()=>{C(),u=0};typeof window>"u"?V():u=window.requestAnimationFrame(V)}function C(){if(!s.value||!g)return;const V=Array.from(g.querySelectorAll("h1, h2")),M=new Set,O=[];V.forEach((B,K)=>{const I=B.textContent?.trim()??"";if(!I)return;let G=(B.getAttribute("id")??"").trim();G||(G=S(I)||`heading-${K+1}`);let L=G,Z=1;for(;M.has(L);)L=`${G}-${Z+=1}`;B.id!==L&&Object.assign(B,{id:L}),M.add(L),O.push({id:L,text:I,level:B.tagName.toLowerCase()==="h1"?1:2})}),r.value=O,O.length||(l.value=""),E()}function S(V){return V.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function H(V){!V||!s.value||typeof MutationObserver>"u"||(W(),d=new MutationObserver(()=>x()),d.observe(V,{childList:!0,subtree:!0}))}function W(){d&&(d.disconnect(),d=null)}function T(V){const M=b;if(!M)return typeof window>"u"?V.offsetTop:V.getBoundingClientRect().top+window.scrollY;const O=V.getBoundingClientRect(),B=M.getBoundingClientRect();return O.top-B.top+M.scrollTop}function E(){if(!s.value||!r.value.length)return;const V=b,M=(V?V.scrollTop:null)||(typeof window<"u"?window.scrollY:0),O=(V?V.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),B=M+O;let K=null;for(let G=0;G<r.value.length;G+=1){const L=r.value[G],Z=document.getElementById(L.id);if(Z){const oe=T(Z);oe+Z.offsetHeight>M&&oe<B&&(K=L.id)}}!K&&a.value&&(K=a.value),K&&(a.value=K);const I=V?V.scrollHeight-V.clientHeight:document.documentElement.scrollHeight-window.innerHeight;M+5>=I&&(K=r.value[r.value.length-1].id),K&&(l.value=K)}function $(){s.value&&(p&&window.cancelAnimationFrame(p),p=window.requestAnimationFrame(()=>{E(),p=0}))}function N(V){if(!s.value)return;const M=document.getElementById(V);if(!M)return;const O=b,B=Math.max(0,T(M));O?O.scrollTo({top:B,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:B,behavior:"smooth"})}return t({refresh:x}),(V,M)=>s.value&&r.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(i.value),style:e.normalizeStyle(c.value)},[e.createElementVNode("h2",lf,e.toDisplayString(V.title),1),e.createElementVNode("div",af,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,O=>(e.openBlock(),e.createElementBlock("div",{key:O.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",O.level===2?"vs-compact-form-navigation__item--nested":"",O.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:B=>N(O.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",O.level===2?"pl-[15px]":"pl-[18px]",O.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(O.text),1)],10,sf)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),dt={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:o=>`Мінімальна довжина — ${o} символів`,maxlength:o=>`Максимальна довжина — ${o} символів`,min:o=>`Значення має бути не менше ${o}`,max:o=>`Значення має бути не більше ${o}`},df=o=>typeof o=="string"?o.trim()?!1:dt.required:Array.isArray(o)?o.map(n=>typeof n=="string"?n.trim():n).filter(n=>n!=null&&n!=="").length?!1:dt.required:typeof o=="number"?Number?.isNaN(o)?dt?.required:!1:o?!1:dt.required,uf=o=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return o?t.test(o)?!1:dt.email:!1},pf=(o,t)=>{if(!o)return!1;const n=String(o).trim();if(!/^\+[1-9]\d{1,14}$/.test(n))return dt.tel;const a=(typeof t?.digits=="number"&&Number.isFinite(t.digits)&&t.digits>0?t.digits:St(wt))||St(wt);return n.length-1!==a?dt.tel:!1},ar=o=>o==null?0:typeof o=="string"?o.trim().length:Array.isArray(o)?o.length:typeof o=="number"?o.toString().length:String(o).length,ff=(o,t)=>{if(o==null)return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&ar(o)<n?t?.message||dt.minlength(n):!1},mf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&ar(o)>n?t?.message||dt.maxlength(n):!1},sr=o=>{if(typeof o=="number")return o;if(typeof o=="string"){const t=o.trim().replace(",",".");return t?Number(t):Number.NaN}return Number(o)},hf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=sr(o);return Number.isFinite(r)&&r<n?t?.message||dt.min(n):!1},gf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=sr(o);return Number.isFinite(r)&&r>n?t?.message||dt.max(n):!1},yf=(o,t)=>{const n=t.pattern??t.regexp,r=typeof n=="string"?new RegExp(n):n;if(Array.isArray(o)){const l=o.filter(Boolean);return l.length===0||l.every(a=>r.test(a))?!1:t.message}return!r.test(o)&&o?t.message:!1},bf=(o,t)=>!1,kf=(o,t)=>{switch(typeof t=="string"?t:t.type){case"required":return df(o);case"email":return uf(o);case"tel":return pf(o,typeof t=="object"?t:void 0);case"regexp":return yf(o,t);case"minlength":return ff(o,t);case"maxlength":return mf(o,t);case"min":return hf(o,t);case"max":return gf(o,t);case"custom":return bf();default:return!1}},xf={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file",inlineselect:"inline-select"};function ir(o){const t=o?.toLowerCase();return xf[t]||t}function no(o,t=!1){if(Array.isArray(o)){const r=[];return o.forEach(l=>{const a={...l};if(a.name=(l.name||l.id||l.key||"").toString(),a.type=ir(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,i=St(s)||St(wt);a.rules=[{type:"tel",digits:i}]}l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=no(a.schema,a.disabled)),r.push(a)}),r}const n=[];return Object.entries(o).forEach(r=>{const l={name:r[0],...r[1],type:ir(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=no(l.schema,l.disabled)),n.push(l)}),n}function wf(o,t,n=!1){const r=e.computed(()=>no((Array.isArray(t),t),typeof n=="boolean"?n:n.value)),l=e.ref({});function a(d){return To(o?.value,d?.conditions)}const s=(d=r.value,u=!0)=>(d.forEach(p=>{const g=[],b=Number(p?.minlength),m=Number(p?.maxlength),h=Number(p?.min),y=Number(p?.max);!Number.isNaN(b)&&Number.isFinite(b)&&g.push({type:"minlength",value:b}),!Number.isNaN(m)&&Number.isFinite(m)&&g.push({type:"maxlength",value:m}),!Number.isNaN(h)&&Number.isFinite(h)&&g.push({type:"min",value:h}),!Number.isNaN(y)&&Number.isFinite(y)&&g.push({type:"max",value:y});const w=[...g,...p.rules||[]];if(w.length){if(!a(p)){delete l.value[p.name];return}let x=!1,C=null;w.forEach(S=>{const H=kf(o.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),i=e.computed(()=>r.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{o.value={},l.value={}},visibleSchema:i}}const _f={class:"flex w-full h-full min-h-0 gap-6"},Cf={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},at=e.defineComponent({__name:"vs-compact-form",props:e.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:e.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(o,{expose:t,emit:n}){const r=n,l=o,a=e.useModel(o,"form"),s=e.useModel(o,"modelValue"),i=e.useModel(o,"values"),c=e.computed({get:()=>i.value??s.value,set:B=>{s.value=B,i.value=B}}),{errors:d,validate:u,reset:p,visibleSchema:g}=wf(c,l.schema,e.toRef(l,"disabled")),b=e.ref(null),m=e.ref(null),h=e.ref({}),y=e.computed(()=>l.navigation),w=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),W=e.computed(()=>H.value?"horizontal":l.layout),T=B=>B?.columns?"horizontal":W.value,E=B=>B?.columns??S.value,$=()=>{!l.formId&&c.value&&delete c.value.id,r("update:modelValue",c.value),u(),r("handle-submit",c.value)},N=B=>{r("value-selected",B)};t({validate:u,reset:p,errors:d}),e.onMounted(()=>{a.value={value:c.value,errors:d.value,reset:p,validate:u,formId:l.formId}});function V(B,K){if(B===K)return!0;if(typeof B!="object"||typeof K!="object"||!B||!K)return!1;const I=Object.keys(B),G=Object.keys(K);return I.length!==G.length?!1:I.every(L=>B[L]===K[L])}function M(B){return Array.isArray(B)?[...B]:B&&typeof B=="object"?{...B}:B}function O(B){Array.isArray(B)&&B.forEach(K=>{if(!K)return;const I=K.name,G=K.default!==void 0;I&&G&&c.value[I]===void 0&&(c.value[I]=M(K.default)),Array.isArray(K.schema)&&O(K.schema)})}return e.watch(g,B=>{O(B)},{immediate:!0,deep:!0}),e.provide("form",a),e.provide("values",c),e.provide("field-props",h),(B,K)=>(e.openBlock(),e.createElementBlock("div",_f,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:m},[e.createElementVNode("form",{ref_key:"formRef",ref:b,onSubmit:e.withModifiers($,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",W.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(g),(I,G)=>(e.openBlock(),e.createElementBlock("div",{key:I.name,class:e.normalizeClass(T(I)==="horizontal"?"col-span-12":`col-span-${I.col||12}`)},[e.createVNode(lr,{style:e.normalizeStyle(B.style),item:I,layout:T(I),columns:E(I),"model-value":c.value[I.name],"onUpdate:modelValue":L=>{if(I.name==="id"&&!B.formId)return;const Z=c.value[I.name];V(Z,L)||(c.value[I.name]=L)},error:e.unref(d)[I.name],onValueSelected:N},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),T(I)==="settings"&&G+1!==e.unref(g).length?(e.openBlock(),e.createElementBlock("div",Cf)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode(cf,{target:b.value,"scroll-container":m.value,enabled:y.value,width:w.value},null,8,["target","scroll-container","enabled","width"])]))}}),vf={class:"relative"},Ef={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},Bf={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"},Vf={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Sf={class:"font-medium text-gray-800 dark:text-[#ffffff]"},$f={class:"p-4 mim-h-0 h-full overflow-auto"},cr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(o,{emit:t}){const n=o,r=t,l=e.ref(n.schema),a=e.ref(n.defaultValue?JSON.parse(JSON.stringify(n.defaultValue)):{}),s=e.ref({}),i=e.ref(n.token||""),c=e.ref(n.token||""),d=e.ref(n.mode),u=()=>{const y=n.method?.trim().toUpperCase();return y==="GET"||y==="POST"||y==="PUT"?y:d.value==="add"?"POST":"PUT"},p=()=>{ue.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},g=y=>{const w={};y.id!==void 0&&y.id!==null&&(w.id=y.id,c.value=y.id.toString()),y.obj&&typeof y.obj=="object"&&Object.assign(w,y.obj),Object.keys(w).length&&(a.value={...a.value,...w})},b=async y=>{if(console.log(y),y.ok){await y.json().catch(()=>({})),p(),r("save",a.value);return}const w=await y.json().catch(()=>({})),x=w.message||w.error;if(y.status===400){ue.notify({type:"warning",title:"Помилка валідації",message:x||"Некоректні дані (400)"});return}if(y.status===500){ue.notify({type:"error",title:"Серверна помилка",message:x||"Виникла помилка на сервері (500)"});return}ue.notify({type:"error",title:"Помилка",message:`Статус: ${y.status}`})};async function m(){const y=s.value.validate();if(y){ue.notify({type:"warning",title:"Помилка валідації",message:Object.entries(y).map(([x,C])=>`${x}: ${C}`).join(`
5
- `)});return}d.value==="add"&&a.value&&delete a.value.id;const w=n.api?.trim();if(w){const x=u();try{const C=await fetch(w,{method:x,headers:x==="GET"?void 0:{"Content-Type":"application/json"},body:x==="GET"?void 0:JSON.stringify(a.value)});await b(C)}catch(C){ue.notify({type:"error",title:"Помилка з’єднання",message:C.message||"Не вдалося виконати запит"})}return}if(i.value)try{const x=await fetch(`/api/table/${i.value}`,{method:d.value==="add"?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.value)});await b(x)}catch(x){ue.notify({type:"error",title:"Помилка з’єднання",message:x.message||"Не вдалося виконати запит"})}else r("edit",a.value),h()}function h(){r("close")}return e.onMounted(async()=>{try{if(n.form&&!n.schema){const y=await fetch(`/api/template/form/${n.form}`);if(!y.ok){ue.notify({type:y.status>=400&&y.status<500?"warning":"error",title:"Error",message:`Error code: ${y.status}`});return}const w=await y.json();l.value=w.schema,w.id&&(c.value=w.id),w.token&&(i.value=w.token,c.value||(c.value=w.token))}else if(n.token&&!n.defaultValue){i.value=n.token;const y=await fetch(`/api/form/${i.value}`);if(!y.ok){ue.notify({type:y.status>=400&&y.status<500?"warning":"error",title:"Error",message:`Error code: ${y.status}`});return}const w=await y.json();l.value=w.schema,w.data?a.value=w.data:d.value="add",g({id:w.id,obj:w.obj})}}catch(y){ue.notify({type:"error",title:"Error",message:y.message||"Unexpected error"}),console.error(y)}}),(y,w)=>(e.openBlock(),e.createElementBlock("div",vf,[e.createElementVNode("div",Ef,[e.createElementVNode("div",Bf,[e.createElementVNode("div",Vf,[e.createElementVNode("h3",Sf,e.toDisplayString(d.value==="add"?"Додати":"Змінити"),1),e.createElementVNode("button",{onClick:h,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"},[w[2]||(w[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",$f,[l.value?(e.openBlock(),e.createBlock(at,{key:0,schema:l.value,values:a.value,"onUpdate:values":w[0]||(w[0]=x=>a.value=x),form:s.value,"onUpdate:form":w[1]||(w[1]=x=>s.value=x),formId:c.value},null,8,["schema","values","form","formId"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"vs-form__head mr-5 mb-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},[e.createElementVNode("button",{type:"button",onClick:h,class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:m,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])])])]))}}),Nf=1440*60*1e3,Af=["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"],Mf=["січ","лют","бер","квіт","трав","черв","лип","серп","вер","жовт","лист","груд"],Ff=["нд","пн","вт","ср","чт","пт","сб"];function Ue(o){return o instanceof Date&&!Number.isNaN(o.getTime())}const jt=o=>new Date(o.getTime());function Ot(o){const t=jt(o);return t.setHours(0,0,0,0),t}function Yt(o){const t=jt(o);return t.setHours(23,59,59,999),t}function oo(o){return Ot(new Date(o.getFullYear(),o.getMonth(),1))}function ro(o){return Yt(new Date(o.getFullYear(),o.getMonth()+1,0))}function lo(o,t){const n=new Date(o),r=n.getDate();n.setDate(1),n.setMonth(n.getMonth()+t);const l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return n.setDate(Math.min(r,l)),n}function Df(o,t){return lo(o,-1)}function $n(o,t){const n=new Date(o);return n.setFullYear(n.getFullYear()+t),n}function dr(o,t){return $n(o,-t)}function ur(o){return Ot(new Date(o.getFullYear(),0,1))}function pr(o){return Yt(new Date(o.getFullYear(),11,31))}function Tf(o){const t=Math.floor(o.getFullYear()/10)*10;return Ot(new Date(t,0,1))}function Lf(o){const t=Math.floor(o.getFullYear()/10)*10+9;return Yt(new Date(t,11,31))}const ut=o=>o.getFullYear(),Nn=o=>Math.floor(o.getFullYear()/10)*10;function If(o){const t=[];let n=Ot(o.start);const r=Ot(o.end);for(;n<=r;)t.push(jt(n)),n=new Date(n.getTime()+Nf);return t}function Rf(o){const t=[];let n=oo(o.start);const r=ro(o.end);for(;n<=r;)t.push(jt(n)),n=lo(n,1);return t}function Of(o){const t=[];let n=ur(o.start);const r=pr(o.end);for(;n<=r;)t.push(jt(n)),n=$n(n,1);return t}function ao(o,t=1){const n=Ot(o),r=(n.getDay()-t+7)%7;return n.setDate(n.getDate()-r),n}function Pf(o,t=1){const n=ao(o,t);return n.setDate(n.getDate()+6),Yt(n)}function zf(o,t,n=0){const r=ao(o,n),l=(t-n+7)%7;return r.setDate(r.getDate()+l),r}const An=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth()&&o.getDate()===t.getDate(),so=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth(),fr=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear(),mr=(o,t)=>!!o&&!!t&&An(o,t)&&o.getHours()===t.getHours(),jf=(o,t)=>!!o&&!!t&&mr(o,t)&&o.getMinutes()===t.getMinutes();function Uf(o,t){const n=o.getTime();return n>=t.start.getTime()&&n<=t.end.getTime()}const Xt=(o,t)=>!!o&&!!t&&o.getTime()<t.getTime(),Zt=(o,t)=>!!o&&!!t&&o.getTime()>t.getTime();function Hf(o){const t=o.filter(n=>Ue(n));if(t.length)return t.reduce((n,r)=>n.getTime()>=r.getTime()?n:r)}function qf(o){const t=o.filter(n=>Ue(n));if(t.length)return t.reduce((n,r)=>n.getTime()<=r.getTime()?n:r)}function hr(o,t){const n=jt(o);return typeof t.year=="number"&&n.setFullYear(t.year),typeof t.month=="number"&&n.setMonth(t.month),typeof t.date=="number"&&n.setDate(t.date),typeof t.hours=="number"&&n.setHours(t.hours),typeof t.minutes=="number"&&n.setMinutes(t.minutes),typeof t.seconds=="number"&&n.setSeconds(t.seconds),typeof t.milliseconds=="number"&&n.setMilliseconds(t.milliseconds),n}const Mn=(o,t=2)=>String(o).padStart(t,"0");function gr(o,t){return t==="wide"?Af[o]:Mf[o]}function Kf(o){return Ff[o]}const Wf=[{token:"LLLL",format:o=>gr(o.getMonth(),"wide")},{token:"LLL",format:o=>gr(o.getMonth(),"abbreviated")},{token:"EE",format:o=>Kf(o.getDay())},{token:"yyyy",format:o=>String(o.getFullYear())},{token:"MM",format:o=>Mn(o.getMonth()+1)},{token:"dd",format:o=>Mn(o.getDate())},{token:"HH",format:o=>Mn(o.getHours())},{token:"mm",format:o=>Mn(o.getMinutes())}];function Fn(o,t){if(!Ue(o))return"";let n="",r=0;for(;r<t.length;){const l=Wf.find(a=>t.startsWith(a.token,r));l?(n+=l.format(o),r+=l.token.length):(n+=t[r],r+=1)}return n}const Gf={"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 yr(o,t){const n=Gf[t];if(!n){const l=new Date(o);return Ue(l)?l:null}const r=o.match(n);if(!r)return null;switch(t){case"yyyy-MM-dd":{const[,l,a,s]=r,i=new Date(Number(l),Number(a)-1,Number(s));return Ue(i)?i:null}case"dd.MM.yyyy":{const[,l,a,s]=r,i=new Date(Number(s),Number(a)-1,Number(l));return Ue(i)?i:null}case"dd.MM.yyyy HH:mm":{const[,l,a,s,i,c]=r,d=new Date(Number(s),Number(a)-1,Number(l),Number(i),Number(c));return 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 Yf=["year","month","day","time","custom"],Xf=e.defineComponent({components:{ChevronLeft:q.ChevronLeft,ChevronRight:q.ChevronRight},emits:{elementClick:o=>Ue(o),left:()=>!0,right:()=>!0,heading:()=>!0},props:{headingClickable:{type:Boolean,default:!1},leftDisabled:{type:Boolean,default:!1},rightDisabled:{type:Boolean,default:!1},columnCount:{type:Number,default:7},items:{type:Array,default:()=>[]},viewMode:{type:String,required:!0,validate:o=>typeof o=="string"&&Yf.includes(o)}}}),Zf={class:"v3dp__heading"},Jf=["disabled"],Qf=["disabled"],em={class:"v3dp__body"},tm={class:"v3dp__subheading"},nm={class:"v3dp__elements"},om=["disabled","onClick"];function rm(o,t,n,r,l,a){const s=e.resolveComponent("ChevronLeft"),i=e.resolveComponent("ChevronRight");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["v3dp__popout",`v3dp__popout-${o.viewMode}`]),style:e.normalizeStyle({"--popout-column-definition":`repeat(${o.columnCount}, 1fr)`}),onMousedown:t[3]||(t[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Zf,[e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__left",disabled:o.leftDisabled,onClick:t[0]||(t[0]=e.withModifiers(c=>o.$emit("left"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-left",{},()=>[e.createVNode(s,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,Jf),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.headingClickable?"button":"span"),{class:"v3dp__heading__center",onClick:t[1]||(t[1]=e.withModifiers(c=>o.$emit("heading"),["stop","prevent"]))},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"heading",{},void 0,!0)]),_:3})),e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__right",disabled:o.rightDisabled,onClick:t[2]||(t[2]=e.withModifiers(c=>o.$emit("right"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-right",{},()=>[e.createVNode(i,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,Qf)]),e.createElementVNode("div",em,["subheading"in o.$slots?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",tm,[e.renderSlot(o.$slots,"subheading",{},void 0,!0)]),t[4]||(t[4]=e.createElementVNode("hr",{class:"v3dp__divider"},null,-1))],64)):e.createCommentVNode("",!0),e.createElementVNode("div",nm,[e.renderSlot(o.$slots,"body",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,c=>(e.openBlock(),e.createElementBlock("button",{key:c.key,disabled:c.disabled,class:e.normalizeClass([{selected:c.selected,current:c.current},`v3dp__element__button__${o.viewMode}`]),onClick:e.withModifiers(d=>o.$emit("elementClick",c.value),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(c.display),1)],10,om))),128))],!0)])])],38)}const Dn=ye(Xf,[["render",rm],["__scopeId","data-v-111981fe"]]),lm=e.defineComponent({components:{PickerPopup:Dn},emits:{"update:pageDate":o=>Ue(o),select:o=>Ue(o)},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>Tf(o.pageDate)),r=e.computed(()=>Lf(o.pageDate)),l=(p,g,b)=>!g&&!b?!0:!(g&&ut(p)<ut(g)||b&&ut(p)>ut(b)),a=e.computed(()=>Of({start:n.value,end:r.value}).map(p=>({value:p,key:String(ut(p)),display:ut(p),selected:!!o.selected&&ut(p)===ut(o.selected),disabled:!l(p,o.lowerLimit,o.upperLimit)}))),s=e.computed(()=>{const p=ut(n.value),g=ut(r.value);return`${p} - ${g}`}),i=e.computed(()=>o.lowerLimit&&(Nn(o.lowerLimit)===Nn(o.pageDate)||Xt(o.pageDate,o.lowerLimit))),c=e.computed(()=>o.upperLimit&&(Nn(o.upperLimit)===Nn(o.pageDate)||Zt(o.pageDate,o.upperLimit)));return{years:a,heading:s,leftDisabled:i,rightDisabled:c,previousPage:()=>t("update:pageDate",dr(o.pageDate,10)),nextPage:()=>t("update:pageDate",$n(o.pageDate,10))}}});function am(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{columnCount:3,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.years,viewMode:"year",onLeft:o.previousPage,onRight:o.nextPage,onElementClick:t[0]||(t[0]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const sm=ye(lm,[["render",am]]),im=e.defineComponent({components:{PickerPopup:Dn},emits:{"update:pageDate":o=>Ue(o),select:o=>Ue(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"LLL"},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>ur(o.pageDate)),r=e.computed(()=>pr(o.pageDate)),l=e.computed(()=>g=>Fn(g,o.format)),a=(g,b,m)=>!b&&!m?!0:!(b&&Xt(g,oo(b))||m&&Zt(g,ro(m))),s=e.computed(()=>Rf({start:n.value,end:r.value}).map(g=>({value:g,display:l.value(g),key:l.value(g),selected:!!o.selected&&so(o.selected,g),disabled:!a(g,o.lowerLimit,o.upperLimit)}))),i=e.computed(()=>ut(n.value)),c=e.computed(()=>o.lowerLimit&&(fr(o.lowerLimit,o.pageDate)||Xt(o.pageDate,o.lowerLimit))),d=e.computed(()=>o.upperLimit&&(fr(o.upperLimit,o.pageDate)||Zt(o.pageDate,o.upperLimit)));return{months:s,heading:i,leftDisabled:c,rightDisabled:d,previousPage:()=>t("update:pageDate",dr(o.pageDate,1)),nextPage:()=>t("update:pageDate",$n(o.pageDate,1))}}});function cm(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:3,items:o.months,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,viewMode:"month",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=i=>o.$emit("back")),onElementClick:t[1]||(t[1]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["items","leftDisabled","rightDisabled","onLeft","onRight"])}const dm=ye(im,[["render",cm]]),um=e.defineComponent({components:{PickerPopup:Dn},emits:{"update:pageDate":o=>Ue(o),select:o=>Ue(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"dd"},headingFormat:{type:String,required:!1,default:"LLLL yyyy"},weekdayFormat:{type:String,required:!1,default:"EE"},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>typeof o=="number"&&Number.isInteger(o)&&o>=0&&o<=6},customWeekdays:{type:Array,required:!1},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1}},setup(o,{emit:t}){const n=e.computed(()=>y=>w=>Fn(w,y)),r=e.computed(()=>oo(o.pageDate)),l=e.computed(()=>ro(o.pageDate)),a=e.computed(()=>({start:r.value,end:l.value})),s=e.computed(()=>({start:ao(r.value,o.weekStartsOn),end:Pf(l.value,o.weekStartsOn)})),i=e.computed(()=>o.customWeekdays?.length===7?o.customWeekdays:null),c=e.computed(()=>{const y=o.weekStartsOn,w=i.value;if(w)return Array.from({length:7}).map((C,S)=>w[(y+S)%7]);const x=n.value(o.weekdayFormat);return Array.from(Array(7)).map((C,S)=>(y+S)%7).map(C=>zf(new Date,C,o.weekStartsOn)).map(x)}),d=(y,w,x,C)=>C?.dates?.some(S=>An(y,S))||C?.predicate?.(y)?!1:!w&&!x?!0:!(w&&Xt(y,Ot(w))||x&&Zt(y,Yt(x))),u=e.computed(()=>{const y=new Date,w=n.value(o.format);return If(s.value).map(x=>({value:x,display:w(x),selected:!!o.selected&&An(o.selected,x),current:An(y,x),disabled:!o.allowOutsideInterval&&!Uf(x,a.value)||!d(x,o.lowerLimit,o.upperLimit,o.disabledDates),key:n.value("yyyy-MM-dd")(x)}))}),p=e.computed(()=>n.value(o.headingFormat)(o.pageDate)),g=e.computed(()=>o.lowerLimit&&(so(o.lowerLimit,o.pageDate)||Xt(o.pageDate,o.lowerLimit))),b=e.computed(()=>o.upperLimit&&(so(o.upperLimit,o.pageDate)||Zt(o.pageDate,o.upperLimit)));return{weekDays:c,days:u,heading:p,leftDisabled:g,rightDisabled:b,previousPage:()=>t("update:pageDate",Df(o.pageDate)),nextPage:()=>t("update:pageDate",lo(o.pageDate,1))}}});function pm(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.days,viewMode:"day",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=i=>o.$emit("back")),onElementClick:t[1]||(t[1]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),subheading:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.weekDays,(i,c)=>(e.openBlock(),e.createElementBlock("span",{key:i,class:e.normalizeClass(`v3dp__subheading__weekday__${c}`)},e.toDisplayString(i),3))),128))]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const fm=ye(um,[["render",pm]]);function br(o,t){const n=o.getBoundingClientRect(),r={height:o.clientHeight,width:o.clientWidth},l=t.getBoundingClientRect();if(!(l.top>=n.top&&l.bottom<=n.top+r.height)){const s=l.top-n.top,i=l.bottom-n.bottom;Math.abs(s)<Math.abs(i)?o.scrollTop+=s:o.scrollTop+=i}}const mm=e.defineComponent({components:{PickerPopup:Dn},emits:{select:o=>Ue(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},visible:{type:Boolean,required:!0},disabledTime:{type:Object,required:!1}},setup(o,{emit:t}){const n=e.ref(null),r=e.ref(null),l=e.computed(()=>o.pageDate??o.selected),a=e.ref(l.value.getHours()),s=e.ref(l.value.getMinutes());e.watch(()=>o.selected,b=>{let m=0,h=0;b&&(m=b.getHours(),h=b.getMinutes()),a.value=m,s.value=h});const i=e.computed(()=>[...Array(24).keys()].map(b=>({value:b,date:hr(new Date(l.value.getTime()),{hours:b,minutes:s.value,seconds:0}),selected:a.value===b,ref:e.ref(null)}))),c=e.computed(()=>[...Array(60).keys()].map(b=>({value:b,date:hr(new Date(l.value.getTime()),{hours:a.value,minutes:b,seconds:0}),selected:s.value===b,ref:e.ref(null)}))),d=b=>{s.value=b.value,t("select",b.date)},u=()=>{const b=i.value.find(h=>h.ref.value?.classList?.contains("selected")??!1),m=c.value.find(h=>h.ref.value?.classList?.contains("selected")??!1);b&&m&&(br(n.value,b.ref.value),br(r.value,m.ref.value))};return e.watch(()=>o.visible,b=>{b&&e.nextTick(u)}),{hoursListRef:n,minutesListRef:r,hours:a,minutes:s,hoursList:i,minutesList:c,padStartZero:b=>`0${b}`.substr(-2),selectMinutes:d,isEnabled:b=>!(o.disabledTime?.dates?.some(m=>mr(b,m)&&jf(b,m))||o.disabledTime?.predicate?.(b)),scroll:u}}}),hm={ref:"hoursListRef",class:"v3dp__column"},gm=["disabled","onClick"],ym={ref:"minutesListRef",class:"v3dp__column"},bm=["disabled","onClick"];function km(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:2,leftDisabled:!0,rightDisabled:!0,viewMode:"time",onHeading:t[0]||(t[0]=i=>o.$emit("back"))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.padStartZero(o.hours))+":"+e.toDisplayString(o.padStartZero(o.minutes)),1)]),body:e.withCtx(()=>[e.createElementVNode("div",hm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.hoursList,i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,ref_for:!0,ref:i.ref,class:e.normalizeClass([{selected:i.selected},"v3dp__element_button__hour"]),disabled:!o.isEnabled(i.date),onClick:e.withModifiers(c=>o.hours=i.value,["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(o.padStartZero(i.value)),1)],10,gm))),128))],512),e.createElementVNode("div",ym,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.minutesList,i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,ref_for:!0,ref:i.ref,class:e.normalizeClass([{selected:i.selected},"v3dp__element_button__minute"]),disabled:!o.isEnabled(i.date),onClick:e.withModifiers(c=>o.selectMinutes(i),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(o.padStartZero(i.value)),1)],10,bm))),128))],512)]),_:1})}const xm=ye(mm,[["render",km],["__scopeId","data-v-610b89e1"]]),Tn=["time","day","month","year"],wm=(o,t,n=void 0)=>{let r=n||new Date;const l=Hf([o,r]);l&&(r=l);const a=qf([t,r]);return a&&(r=a),r},_m=e.defineComponent({components:{YearPicker:sm,MonthPicker:dm,DayPicker:fm,TimePicker:xm},inheritAttrs:!1,props:{placeholder:{type:String,default:""},modelValue:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1},disabledTime:{type:Object,required:!1},upperLimit:{type:Date,required:!1},lowerLimit:{type:Date,required:!1},startingView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Tn.includes(o)},startingViewDate:{type:Date,required:!1,default:()=>new Date},dayPickerHeadingFormat:{type:String,required:!1,default:"LLLL yyyy"},monthListFormat:{type:String,required:!1,default:"LLL"},weekdayFormat:{type:String,required:!1,default:"EE"},dayFormat:{type:String,required:!1,default:"dd"},inputFormat:{type:String,required:!1,default:"yyyy-MM-dd"},weekDayNames:{type:Array,required:!1},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>[0,1,2,3,4,5,6].includes(o)},disabled:{type:Boolean,required:!1,default:!1},clearable:{type:Boolean,required:!1,default:!1},typeable:{type:Boolean,required:!1,default:!1},minimumView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Tn.includes(o)}},emits:{"update:modelValue":o=>o==null||Ue(o),decadePageChanged:o=>!0,yearPageChanged:o=>!0,monthPageChanged:o=>!0,opened:()=>!0,closed:()=>!0},setup(o,{emit:t,attrs:n}){const r=e.ref("none"),l=e.ref(o.startingViewDate),a=e.ref(null),s=e.ref(!1),i=e.ref({}),c=e.ref(""),d=L=>{const Z=L.replace(/[a-zA-Z]/g,"0");return/0/.test(Z)?Z:""},u=e.computed(()=>d(o.inputFormat));let p=null,g=null;const b=()=>{p?.destroy(),p=null},m=async()=>{if(!g){const{default:L}=await Promise.resolve().then(()=>Pn);g=L}return g},h=()=>{p&&p.value!==c.value&&(p.value=c.value??"")},y=async()=>{if(b(),!a.value||!u.value)return;p=(await m())(a.value,{mask:u.value,lazy:!0,overwrite:!0}),h()};e.watchEffect(()=>{if(!c.value)return;const L=yr(c.value,o.inputFormat);L&&(l.value=L)}),e.watchEffect(()=>{c.value=o.modelValue&&Ue(o.modelValue)?Fn(o.modelValue,o.inputFormat):""}),e.onMounted(()=>{u.value&&e.nextTick(()=>{y()})}),e.onBeforeUnmount(()=>{b()}),e.watch(u,L=>{L?e.nextTick(()=>{y()}):b()}),e.watch(c,()=>{h()});const w=(L="none")=>{o.disabled||(L!=="none"&&r.value==="none"&&(l.value=o.modelValue||wm(o.lowerLimit,o.upperLimit,l.value)),r.value=L,L!=="none"?(e.nextTick(()=>I()),t("opened")):t("closed"))};e.watchEffect(()=>{o.disabled&&(r.value="none")});const x=(L,Z)=>{l.value=Z,L==="year"?t("decadePageChanged",Z):L==="month"?t("yearPageChanged",Z):L==="day"&&t("monthPageChanged",Z)},C=L=>{l.value=L,o.minimumView==="year"?(w("none"),t("update:modelValue",L)):r.value="month"},S=L=>{l.value=L,o.minimumView==="month"?(w("none"),t("update:modelValue",L)):r.value="day"},H=L=>{l.value=L,o.minimumView==="day"?(w("none"),t("update:modelValue",L)):r.value="time"},W=L=>{w("none"),t("update:modelValue",L)},T=()=>{o.clearable&&(w("none"),t("update:modelValue",null),l.value=o.startingViewDate)},E=()=>s.value=!0,$=()=>w(M.value),N=()=>{s.value=!1,w()},V=L=>{const Z=L.keyCode?L.keyCode:L.which;if([27,13].includes(Z)&&a.value.blur(),o.typeable){const be=yr(a.value.value,o.inputFormat);be&&c.value===Fn(be,o.inputFormat)&&(c.value=a.value.value,t("update:modelValue",be))}},M=e.computed(()=>{const L=Tn.indexOf(o.startingView),Z=Tn.indexOf(o.minimumView);return L<Z?o.minimumView:o.startingView}),O=L=>Object.fromEntries(Object.entries(L??{}).filter(([Z,oe])=>Z.startsWith("--"))),B=e.computed(()=>o.weekDayNames?.length===7?o.weekDayNames:void 0),K=()=>o.startingView==="time"&&o.minimumView==="time"?null:r.value="day",I=()=>{if(!a.value)return;const L=a.value.getBoundingClientRect();i.value={position:"fixed",top:`${Math.round(L.bottom+4)}px`,left:`${Math.round(L.left)}px`,zIndex:"100100"}},G=()=>{r.value!=="none"&&I()};return e.onMounted(()=>{window.addEventListener("resize",G),window.addEventListener("scroll",G,!0)}),e.onBeforeUnmount(()=>{window.removeEventListener("resize",G),window.removeEventListener("scroll",G,!0)}),{blur:N,focus:$,click:E,input:c,inputRef:a,pageDate:l,renderView:w,updatePageDate:x,selectYear:C,selectMonth:S,selectDay:H,selectTime:W,keyUp:V,normalizedWeekdayNames:B,viewShown:r,goBackFromTimepicker:K,clearModelValue:T,initialView:M,log:L=>console.log(L),variables:O,popupAnchorStyle:i}}}),Cm={class:"v3dp__input_wrapper"},vm=["readonly","placeholder","disabled","tabindex"],Em={class:"v3dp__clearable"};function Bm(o,t,n,r,l,a){const s=e.resolveComponent("year-picker"),i=e.resolveComponent("month-picker"),c=e.resolveComponent("day-picker"),d=e.resolveComponent("time-picker");return e.openBlock(),e.createElementBlock("div",{class:"v3dp__datepicker v3dp__theme_vars",style:e.normalizeStyle(o.variables(o.$attrs.style))},[e.createElementVNode("div",Cm,[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"text",ref:"inputRef",readonly:!o.typeable,"onUpdate:modelValue":t[0]||(t[0]=u=>o.input=u)},o.$attrs,{placeholder:o.placeholder,disabled:o.disabled,tabindex:o.disabled?-1:0,onKeyup:t[1]||(t[1]=(...u)=>o.keyUp&&o.keyUp(...u)),onBlur:t[2]||(t[2]=(...u)=>o.blur&&o.blur(...u)),onFocus:t[3]||(t[3]=(...u)=>o.focus&&o.focus(...u)),onClick:t[4]||(t[4]=(...u)=>o.click&&o.click(...u))}),null,16,vm),[[e.vModelText,o.input]]),e.withDirectives(e.createElementVNode("div",Em,[e.renderSlot(o.$slots,"clear",{onClear:o.clearModelValue},()=>[e.createElementVNode("i",{onClick:t[5]||(t[5]=u=>o.clearModelValue())},"x")])],512),[[e.vShow,o.clearable&&o.modelValue]])]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.withDirectives(e.createElementVNode("div",{style:e.normalizeStyle({...o.variables(o.$attrs.style),...o.popupAnchorStyle}),class:"v3dp__popup_anchor v3dp__theme_vars"},[e.withDirectives(e.createVNode(s,{pageDate:o.pageDate,"onUpdate:pageDate":t[6]||(t[6]=u=>o.updatePageDate("year",u)),selected:o.modelValue,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,onSelect:o.selectYear},null,8,["pageDate","selected","lowerLimit","upperLimit","onSelect"]),[[e.vShow,o.viewShown==="year"]]),e.withDirectives(e.createVNode(i,{pageDate:o.pageDate,"onUpdate:pageDate":t[7]||(t[7]=u=>o.updatePageDate("month",u)),selected:o.modelValue,onSelect:o.selectMonth,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,format:o.monthListFormat,onBack:t[8]||(t[8]=u=>o.viewShown="year")},null,8,["pageDate","selected","onSelect","lowerLimit","upperLimit","format"]),[[e.vShow,o.viewShown==="month"]]),e.withDirectives(e.createVNode(c,{pageDate:o.pageDate,"onUpdate:pageDate":t[9]||(t[9]=u=>o.updatePageDate("day",u)),selected:o.modelValue,weekStartsOn:o.weekStartsOn,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,headingFormat:o.dayPickerHeadingFormat,disabledDates:o.disabledDates,weekdayFormat:o.weekdayFormat,"allow-outside-interval":o.allowOutsideInterval,format:o.dayFormat,"custom-weekdays":o.normalizedWeekdayNames,onSelect:o.selectDay,onBack:t[10]||(t[10]=u=>o.viewShown="month")},null,8,["pageDate","selected","weekStartsOn","lowerLimit","upperLimit","headingFormat","disabledDates","weekdayFormat","allow-outside-interval","format","custom-weekdays","onSelect"]),[[e.vShow,o.viewShown==="day"]]),e.withDirectives(e.createVNode(d,{pageDate:o.pageDate,visible:o.viewShown==="time",selected:o.modelValue,disabledTime:o.disabledTime,onSelect:o.selectTime,onBack:o.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"]),[[e.vShow,o.viewShown==="time"]])],4),[[e.vShow,o.viewShown!=="none"]])]))],4)}const Vm=ye(_m,[["render",Bm]]),Sm=ye(e.defineComponent({__name:"vs-input-date2",props:{clearable:{type:Boolean,default:!0},now:{type:Boolean},editable:{type:Boolean,default:!0},time:{type:Boolean},isInfinity:{type:Boolean},mode:{default:"date"},weekStart:{},dayNames:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,{inputClass:l}=je(n.style),a=e.computed(()=>n.mode?n.mode:n.time?"datetime":"date"),s={date:"дд.мм.рррр",datetime:"дд.мм.рррр гг:хх",month:"мм.рррр",week:"рррр-тиждень",time:"гг:хх",year:"рррр"},i=e.computed(()=>n.placeholder||s[a.value]||""),c=e.computed(()=>["py-1.5 px-3 block w-full placeholder:text-[#767f8f] bg-white",l.value,n.customClass,{"!border-red-600":n.error}]),d=e.computed(()=>!n.modelValue&&n.now?new Date:null),u=e.computed({get:()=>C(n.modelValue??d.value,a.value)||void 0,set:I=>r("update:modelValue",S(I,a.value))}),p=["Пн","Вт","Ср","Чт","Пт","Сб","Нд"],g=e.computed(()=>{if(n.dayNames?.length)return n.dayNames.length===7?n.dayNames:p}),b=e.computed(()=>{const I=n.weekStart,G=typeof I=="string"?Number(I):I;return G===void 0||Number.isNaN(G)?1:Math.min(6,Math.max(0,G))}),m=e.computed(()=>{switch(a.value){case"time":return{startingView:"time",minimumView:"time"};case"month":return{startingView:"month",minimumView:"month"};case"year":return{startingView:"year",minimumView:"year"};case"datetime":return{startingView:"day",minimumView:"time"};default:return{startingView:"day",minimumView:"day"}}}),h={date:"dd.MM.yyyy",datetime:"dd.MM.yyyy HH:mm",month:"MM.yyyy",time:"HH:mm",week:"dd.MM.yyyy",year:"yyyy"},y=e.computed(()=>h[a.value]||"dd.MM.yyyy"),w=e.computed(()=>({"--vdp-selected-bg-color":n.style?.primaryColor||"#2563eb","--vdp-hover-bg-color":n.style?.primaryColor||"#2563eb","--vdp-selected-color":"#ffffff","--vdp-hover-color":"#ffffff","--vdp-border-radius":n.style?.size==="sm"?"6px":"8px","--vdp-elem-font-size":n.style?.size==="sm"?"0.75em":"0.85em"})),x=e.ref(!1);e.watch(()=>n.modelValue,I=>{I?x.value=!0:n.now||(x.value=!1)},{immediate:!0}),e.watchEffect(()=>{n.now&&!n.modelValue&&!x.value&&(r("update:modelValue",S(new Date,a.value)),x.value=!0)});function C(I,G){if(!I)return null;if(I instanceof Date&&!Number.isNaN(I.getTime()))return I;if(typeof I!="string")return null;switch(G){case"datetime":return E(I);case"time":return V(I);case"month":return $(I);case"year":return N(I);case"week":return M(I);case"date":default:return T(I)}}function S(I,G){if(!I)return null;const L=I instanceof Date?I:C(I,G);if(!L)return null;switch(G){case"datetime":return`${H(L)}T${W(L)}`;case"time":return W(L);case"month":return`${L.getFullYear()}-${K(L.getMonth()+1)}`;case"year":return`${L.getFullYear()}`;case"week":{const{year:Z,week:oe}=O(L);return`${Z}-W${K(oe)}`}case"date":default:return H(L)}}function H(I){return`${I.getFullYear()}-${K(I.getMonth()+1)}-${K(I.getDate())}`}function W(I){return`${K(I.getHours())}:${K(I.getMinutes())}`}function T(I){const G=I.split("-");if(G.length<3)return null;const[L,Z,oe]=G.map(Number);return!L||!Z||!oe?null:new Date(L,Z-1,oe)}function E(I){const G=I.includes("T")?I:I.replace(" ","T"),L=new Date(G);return Number.isNaN(L.getTime())?null:L}function $(I){const[G,L]=I.split("-").map(Number);return!G||Number.isNaN(L)?null:new Date(G,(L||1)-1,1)}function N(I){const G=Number(I);return G?new Date(G,0,1):null}function V(I){const G=I.match(/^(\d{1,2}):(\d{2})$/);if(!G)return null;const[,L,Z]=G,oe=new Date;return oe.setHours(Number(L),Number(Z),0,0),oe}function M(I){const G=I.match(/^(\d{4})-W(\d{2})$/);if(!G)return null;const[,L,Z]=G,oe=Number(Z);return B(Number(L),oe)}function O(I){const G=new Date(Date.UTC(I.getFullYear(),I.getMonth(),I.getDate())),L=G.getUTCDay()||7;G.setUTCDate(G.getUTCDate()+4-L);const Z=new Date(Date.UTC(G.getUTCFullYear(),0,1)),oe=Math.ceil(((G.getTime()-Z.getTime())/864e5+1)/7);return{year:G.getUTCFullYear(),week:oe}}function B(I,G){if(!I||!G)return null;const L=new Date(I,0,1+(G-1)*7),Z=L.getDay(),oe=L;return Z<=4?oe.setDate(L.getDate()-L.getDay()+1):oe.setDate(L.getDate()+8-L.getDay()),oe}function K(I){return String(I).padStart(2,"0")}return(I,G)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-date-picker",n.customClass]),style:e.normalizeStyle(w.value)},[e.createVNode(Vm,{modelValue:u.value,"onUpdate:modelValue":G[0]||(G[0]=L=>u.value=L),style:e.normalizeStyle(w.value),placeholder:i.value,disabled:n.disabled,clearable:n.clearable,typeable:n.editable,"week-day-names":g.value,"week-starts-on":b.value,"starting-view":m.value.startingView,"minimum-view":m.value.minimumView,"input-format":y.value,name:n.name,class:e.normalizeClass(c.value)},null,8,["modelValue","style","placeholder","disabled","clearable","typeable","week-day-names","week-starts-on","starting-view","minimum-view","input-format","name","class"])],6))}}),[["__scopeId","data-v-f292c667"]]),$m={form:{richtext:{paragraph:"Paragraph",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",createTable:"Create Table",addColumn:"Add Column",addRow:"Add Row",deleteColumn:"Delete Column",deleteRow:"Delete Row",deleteTable:"Delete Table",mergeCells:"Merge Cells",splitCells:"Split Cells",linkTitle:"Enter Link",link:"Link",linkUrl:"Enter URL",editLink:"Edit Link",openLink:"Open Link",removeLink:"Remove Link",openInNewTab:"Open in New Tab",editor:"Editor",html:"HTML",markdown:"Markdown",create:"Create",update:"Update",cancel:"Cancel"}}},Nm={form:{richtext:{paragraph:"Звичайний текст",heading1:"Заголовок 1",heading2:"Заголовок 2",heading3:"Заголовок 3",heading4:"Заголовок 4",heading5:"Заголовок 5",heading6:"Заголовок 6",createTable:"Створити таблицю",addColumn:"Додати колонку",addRow:"Додати рядок",deleteColumn:"Видалити колонку",deleteRow:"Видалити рядок",deleteTable:"Видалити таблицю",mergeCells:"Об'єднати комірки",splitCells:"Розділити комірки",linkTitle:"Додати посилання",link:"Посилання",linkUrl:"Введіть URL",editLink:"Редагувати посилання",openLink:"Відкрити посилання",removeLink:"Видалити посилання",openInNewTab:"Відкривати в новій вкладці",editor:"Редактор",html:"HTML",markdown:"Markdown",create:"Створити",update:"Оновити",cancel:"Скасувати"}}},kr=$m.form.richtext,xr=Nm.form.richtext,io={en:{form:{richtext:kr}},uk:{form:{richtext:xr}}},wr=(o={mode:"edit",schema:null})=>new Promise(t=>{const{close:n}=ue.modal({title:o.mode==="add"?"Додати":"Редагувати",template:"",visible:!0,size:"medium",closeClickBack:!0,content:cr,contentProps:{...o,onClose:()=>{t(null),n()},onSave:r=>{t(r),n()}}})});at.install=function(t){t.component("VForm",at),Object.assign(t.config.globalProperties,{$form:wr}),t.provide("form",wr),window.v3plugin||(window.v3plugin={})};function $t(o){return typeof o=="string"||o instanceof String}function _r(o){var t;return typeof o=="object"&&o!=null&&(o==null||(t=o.constructor)==null?void 0:t.name)==="Object"}function Cr(o,t){return Array.isArray(t)?Cr(o,(n,r)=>t.includes(r)):Object.entries(o).reduce((n,r)=>{let[l,a]=r;return t(a,l)&&(n[l]=a),n},{})}const de={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function vr(o){switch(o){case de.LEFT:return de.FORCE_LEFT;case de.RIGHT:return de.FORCE_RIGHT;default:return o}}function co(o){return o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function Ln(o,t){if(t===o)return!0;const n=Array.isArray(t),r=Array.isArray(o);let l;if(n&&r){if(t.length!=o.length)return!1;for(l=0;l<t.length;l++)if(!Ln(t[l],o[l]))return!1;return!0}if(n!=r)return!1;if(t&&o&&typeof t=="object"&&typeof o=="object"){const a=t instanceof Date,s=o instanceof Date;if(a&&s)return t.getTime()==o.getTime();if(a!=s)return!1;const i=t instanceof RegExp,c=o instanceof RegExp;if(i&&c)return t.toString()==o.toString();if(i!=c)return!1;const d=Object.keys(t);for(l=0;l<d.length;l++)if(!Object.prototype.hasOwnProperty.call(o,d[l]))return!1;for(l=0;l<d.length;l++)if(!Ln(o[d[l]],t[d[l]]))return!1;return!0}else if(t&&o&&typeof t=="function"&&typeof o=="function")return t.toString()===o.toString();return!1}class Am{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?de.NONE:(this.oldSelection.end===this.cursorPos||this.oldSelection.start===this.cursorPos)&&this.oldSelection.end===this.oldSelection.start?de.RIGHT:de.LEFT}}function ge(o,t){return new ge.InputMask(o,t)}function Er(o){if(o==null)throw new Error("mask property should be defined");return o instanceof RegExp?ge.MaskedRegExp:$t(o)?ge.MaskedPattern:o===Date?ge.MaskedDate:o===Number?ge.MaskedNumber:Array.isArray(o)||o===Array?ge.MaskedDynamic:ge.Masked&&o.prototype instanceof ge.Masked?o:ge.Masked&&o instanceof ge.Masked?o.constructor:o instanceof Function?ge.MaskedFunction:(console.warn("Mask not found for mask",o),ge.Masked)}function Ut(o){if(!o)throw new Error("Options in not defined");if(ge.Masked){if(o.prototype instanceof ge.Masked)return{mask:o};const{mask:t=void 0,...n}=o instanceof ge.Masked?{mask:o}:_r(o)&&o.mask instanceof ge.Masked?o:{};if(t){const r=t.mask;return{...Cr(t,(l,a)=>!a.startsWith("_")),mask:t.constructor,_mask:r,...n}}}return _r(o)?{...o}:{mask:o}}function ht(o){if(ge.Masked&&o instanceof ge.Masked)return o;const t=Ut(o),n=Er(t.mask);if(!n)throw new Error("Masked class is not found for provided mask "+t.mask+", appropriate module needs to be imported manually before creating mask.");return t.mask===n&&delete t.mask,t._mask&&(t.mask=t._mask,delete t._mask),new n(t)}ge.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,n){if(!(t==null||n==null||t===this.selectionStart&&n===this.selectionEnd))try{this._unsafeSelect(t,n)}catch{}}get isActive(){return!1}}ge.MaskElement=In;const Br=90,Mm=89;class Jt 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,n,r;return(t=(n=(r=this.input).getRootNode)==null?void 0:n.call(r))!=null?t:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(t){this.input.addEventListener("keydown",this._onKeydown),this.input.addEventListener("input",this._onInput),this.input.addEventListener("beforeinput",this._onBeforeinput),this.input.addEventListener("compositionend",this._onCompositionEnd),this.input.addEventListener("drop",t.drop),this.input.addEventListener("click",t.click),this.input.addEventListener("focus",t.focus),this.input.addEventListener("blur",t.commit),this._handlers=t}_onKeydown(t){if(this._handlers.redo&&(t.keyCode===Br&&t.shiftKey&&(t.metaKey||t.ctrlKey)||t.keyCode===Mm&&t.ctrlKey))return t.preventDefault(),this._handlers.redo(t);if(this._handlers.undo&&t.keyCode===Br&&(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={}}}ge.HTMLMaskElement=Jt;class Vr extends Jt{constructor(t){super(t),this.input=t}get _unsafeSelectionStart(){return this.input.selectionStart!=null?this.input.selectionStart:this.value.length}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,n){this.input.setSelectionRange(t,n)}get value(){return this.input.value}set value(t){this.input.value=t}}ge.HTMLMaskElement=Jt;class uo extends Jt{get _unsafeSelectionStart(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||r==null||r<l?r:l}get _unsafeSelectionEnd(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||r==null||r>l?r:l}_unsafeSelect(t,n){if(!this.rootElement.createRange)return;const r=this.rootElement.createRange();r.setStart(this.input.firstChild||this.input,t),r.setEnd(this.input.lastChild||this.input,n);const l=this.rootElement,a=l.getSelection&&l.getSelection();a&&(a.removeAllRanges(),a.addRange(r))}get value(){return this.input.textContent||""}set value(t){this.input.textContent=t}}ge.HTMLContenteditableMaskElement=uo;class Rn{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>Rn.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}}Rn.MAX_LENGTH=100;class Sr{constructor(t,n){this.el=t instanceof In?t:t.isContentEditable&&t.tagName!=="INPUT"&&t.tagName!=="TEXTAREA"?new uo(t):new Vr(t),this.masked=ht(n),this._listeners={},this._value="",this._unmaskedValue="",this._rawInputValue="",this.history=new Rn,this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this._onUndo=this._onUndo.bind(this),this._onRedo=this._onRedo.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}maskEquals(t){var n;return t==null||((n=this.masked)==null?void 0:n.maskEquals(t))}get mask(){return this.masked.mask}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof ge.Masked)&&this.masked.constructor===Er(t)){this.masked.updateOptions({mask:t});return}const n=t instanceof ge.Masked?t:ht({mask:t});n.unmaskedValue=this.masked.unmaskedValue,this.masked=n}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl("auto"))}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl("auto"))}get rawInputValue(){return this._rawInputValue}set rawInputValue(t){this.rawInputValue!==t&&(this.masked.rawInputValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl("auto"))}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange,undo:this._onUndo,redo:this._onRedo})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t,n){const r=this._listeners[t];r&&r.forEach(l=>l(n))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){!this.el||!this.el.isActive||(this.el.select(t,t),this._saveSelection())}_saveSelection(){this.displayValue!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value,this._unmaskedValue=this.masked.unmaskedValue,this._rawInputValue=this.masked.rawInputValue}updateControl(t){const n=this.masked.unmaskedValue,r=this.masked.value,l=this.masked.rawInputValue,a=this.displayValue,s=this.unmaskedValue!==n||this.value!==r||this._rawInputValue!==l;this._unmaskedValue=n,this._value=r,this._rawInputValue=l,this.el.value!==a&&(this.el.value=a),t==="auto"?this.alignCursor():t!=null&&(this.cursorPos=t),s&&this._fireChangeEvents(),!this._historyChanging&&(s||this.history.isEmpty)&&this.history.push({unmaskedValue:n,selection:{start:this.selectionStart,end:this.cursorPos}})}updateOptions(t){const{mask:n,...r}=t,l=!this.maskEquals(n),a=this.masked.optionsIsChanged(r);l&&(this.mask=n),a&&this.masked.updateOptions(r),(l||a)&&this.updateControl()}updateCursor(t){t!=null&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())},10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,de.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,n){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(n),this}off(t,n){if(!this._listeners[t])return this;if(!n)return delete this._listeners[t],this;const r=this._listeners[t].indexOf(n);return r>=0&&this._listeners[t].splice(r,1),this}_onInput(t){this._inputEvent=t,this._abortUpdateCursor();const n=new Am({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),r=this.masked.rawInputValue,l=this.masked.splice(n.startChangePos,n.removed.length,n.inserted,n.removeDirection,{input:!0,raw:!0}).offset,a=r===this.masked.rawInputValue?n.removeDirection:de.NONE;let s=this.masked.nearestInputPos(n.startChangePos+l,a);a!==de.NONE&&(s=this.masked.nearestInputPos(s,de.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}}ge.InputMask=Sr;class xe{static normalize(t){return Array.isArray(t)?t:[t,new xe]}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}}ge.ChangeDetails=xe;class gt{constructor(t,n,r){t===void 0&&(t=""),n===void 0&&(n=0),this.value=t,this.from=n,this.stop=r}toString(){return this.value}extend(t){this.value+=String(t)}appendTo(t){return t.append(this.toString(),{tail:!0}).aggregate(t._appendPlaceholder())}get state(){return{value:this.value,from:this.from,stop:this.stop}}set state(t){Object.assign(this,t)}unshift(t){if(!this.value.length||t!=null&&this.from>=t)return"";const n=this.value[0];return this.value=this.value.slice(1),n}shift(){if(!this.value.length)return"";const t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}class 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,n){n===void 0&&(n={input:!0}),this.reset(),this.append(t,n,""),this.doCommit()}get unmaskedValue(){return this.value}set unmaskedValue(t){this.resolve(t,{})}get typedValue(){return this.parse?this.parse(this.value,this):this.unmaskedValue}set typedValue(t){this.format?this.value=this.format(t,this):this.unmaskedValue=String(t)}get rawInputValue(){return this.extractInput(0,this.displayValue.length,{raw:!0})}set rawInputValue(t){this.resolve(t,{raw:!0})}get displayValue(){return this.value}get isComplete(){return!0}get isFilled(){return this.isComplete}nearestInputPos(t,n){return t}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),Math.min(this.displayValue.length,n-t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this.displayValue.slice(t,n)}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new gt(this.extractInput(t,n),t)}appendTail(t){return $t(t)&&(t=new gt(String(t))),t.appendTo(this)}_appendCharRaw(t,n){return t?(this._value+=t,new xe({inserted:t,rawInserted:t})):new xe}_appendChar(t,n,r){n===void 0&&(n={});const l=this.state;let a;if([t,a]=this.doPrepareChar(t,n),t&&(a=a.aggregate(this._appendCharRaw(t,n)),!a.rawInserted&&this.autofix==="pad")){const s=this.state;this.state=l;let i=this.pad(n);const c=this._appendCharRaw(t,n);i=i.aggregate(c),c.rawInserted||i.equals(a)?a=i:this.state=s}if(a.inserted){let s,i=this.doValidate(n)!==!1;if(i&&r!=null){const c=this.state;if(this.overwrite===!0){s=r.state;for(let u=0;u<a.rawInserted.length;++u)r.unshift(this.displayValue.length-a.tailShift)}let d=this.appendTail(r);if(i=d.rawInserted.length===r.toString().length,!(i&&d.inserted)&&this.overwrite==="shift"){this.state=c,s=r.state;for(let u=0;u<a.rawInserted.length;++u)r.shift();d=this.appendTail(r),i=d.rawInserted.length===r.toString().length}i&&d.inserted&&(this.state=c)}i||(a=new xe,this.state=l,r&&s&&(r.state=s))}return a}_appendPlaceholder(){return new xe}_appendEager(){return new xe}append(t,n,r){if(!$t(t))throw new Error("value should be string");const l=$t(r)?new gt(String(r)):r;n!=null&&n.tail&&(n._beforeTailState=this.state);let a;[t,a]=this.doPrepare(t,n);for(let s=0;s<t.length;++s){const i=this._appendChar(t[s],n,l);if(!i.rawInserted&&!this.doSkipInvalid(t[s],n,l))break;a.aggregate(i)}return(this.eager===!0||this.eager==="append")&&n!=null&&n.input&&t&&a.aggregate(this._appendEager()),l!=null&&(a.tailShift+=this.appendTail(l).tailShift),a}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this._value=this.displayValue.slice(0,t)+this.displayValue.slice(n),new xe}withValueRefresh(t){if(this._refreshing||!this._initialized)return t();this._refreshing=!0;const n=this.rawInputValue,r=this.value,l=t();return this.rawInputValue=n,this.value&&this.value!==r&&r.indexOf(this.value)===0&&(this.append(r.slice(this.displayValue.length),{},""),this.doCommit()),delete this._refreshing,l}runIsolated(t){if(this._isolated||!this._initialized)return t(this);this._isolated=!0;const n=this.state,r=t(this);return this.state=n,delete this._isolated,r}doSkipInvalid(t,n,r){return!!this.skipInvalid}doPrepare(t,n){return n===void 0&&(n={}),xe.normalize(this.prepare?this.prepare(t,this,n):t)}doPrepareChar(t,n){return n===void 0&&(n={}),xe.normalize(this.prepareChar?this.prepareChar(t,this,n):t)}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}splice(t,n,r,l,a){r===void 0&&(r=""),l===void 0&&(l=de.NONE),a===void 0&&(a={input:!0});const s=t+n,i=this.extractTail(s),c=this.eager===!0||this.eager==="remove";let d;c&&(l=vr(l),d=this.extractInput(0,s,{raw:!0}));let u=t;const p=new xe;if(l!==de.NONE&&(u=this.nearestInputPos(t,n>1&&t!==0&&!c?de.NONE:l),p.tailShift=u-t),p.aggregate(this.remove(u)),c&&l!==de.NONE&&d===this.rawInputValue)if(l===de.FORCE_LEFT){let g;for(;d===this.rawInputValue&&(g=this.displayValue.length);)p.aggregate(new xe({tailShift:-1})).aggregate(this.remove(g-1))}else l===de.FORCE_RIGHT&&i.unshift();return p.aggregate(this.append(r,a,i))}maskEquals(t){return this.mask===t}optionsIsChanged(t){return!Ln(this,t)}typedValueEquals(t){const n=this.typedValue;return t===n||He.EMPTY_VALUES.includes(t)&&He.EMPTY_VALUES.includes(n)||(this.format?this.format(t,this)===this.format(this.typedValue,this):!1)}pad(t){return new xe}}He.DEFAULTS={skipInvalid:!0},He.EMPTY_VALUES=[void 0,null,""],ge.Masked=He;class Nt{constructor(t,n){t===void 0&&(t=[]),n===void 0&&(n=0),this.chunks=t,this.from=n}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=$t(t)?new gt(String(t)):t;const n=this.chunks[this.chunks.length-1],r=n&&(n.stop===t.stop||t.stop==null)&&t.from===n.from+n.toString().length;if(t instanceof gt)r?n.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 ge.MaskedPattern))return new gt(this.toString()).appendTo(t);const n=new xe;for(let r=0;r<this.chunks.length;++r){const l=this.chunks[r],a=t._mapPosToBlock(t.displayValue.length),s=l.stop;let i;if(s!=null&&(!a||a.index<=s)&&((l instanceof Nt||t._stops.indexOf(s)>=0)&&n.aggregate(t._appendPlaceholder(s)),i=l instanceof Nt&&t._blocks[s]),i){const c=i.appendTail(l);n.aggregate(c);const d=l.toString().slice(c.rawInserted.length);d&&n.aggregate(t.append(d,{tail:!0}))}else n.aggregate(t.append(l.toString(),{tail:!0}))}return n}get state(){return{chunks:this.chunks.map(t=>t.state),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(t){const{chunks:n,...r}=t;Object.assign(this,r),this.chunks=n.map(l=>{const a="chunks"in l?new Nt:new gt;return a.state=l,a})}unshift(t){if(!this.chunks.length||t!=null&&this.from>=t)return"";const n=t!=null?t-this.from:t;let r=0;for(;r<this.chunks.length;){const l=this.chunks[r],a=l.unshift(n);if(l.toString()){if(!a)break;++r}else this.chunks.splice(r,1);if(a)return a}return""}shift(){if(!this.chunks.length)return"";let t=this.chunks.length-1;for(;0<=t;){const n=this.chunks[t],r=n.shift();if(n.toString()){if(!r)break;--t}else this.chunks.splice(t,1);if(r)return r}return""}}class Fm{constructor(t,n){this.masked=t,this._log=[];const{offset:r,index:l}=t._mapPosToBlock(n)||(n<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0});this.offset=r,this.index=l,this.ok=!1}get block(){return this.masked._blocks[this.index]}get pos(){return this.masked._blockStartPos(this.index)+this.offset}get state(){return{index:this.index,offset:this.offset,ok:this.ok}}set state(t){Object.assign(this,t)}pushState(){this._log.push(this.state)}popState(){const t=this._log.pop();return t&&(this.state=t),t}bindBlock(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.displayValue.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=((n=this.block)==null?void 0:n.displayValue.length)||0){var n;if(t())return this.ok=!0}return this.ok=!1}_pushRight(t){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(t())return this.ok=!0;return this.ok=!1}pushLeftBeforeFilled(){return this._pushLeft(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,de.FORCE_LEFT),this.offset!==0))return!0})}pushLeftBeforeInput(){return this._pushLeft(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,de.LEFT),!0})}pushLeftBeforeRequired(){return this._pushLeft(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,de.LEFT),!0})}pushRightBeforeFilled(){return this._pushRight(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,de.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,de.NONE),!0})}pushRightBeforeRequired(){return this._pushRight(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,de.NONE),!0})}}class po{constructor(t){Object.assign(this,t),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}get rawInputValue(){return this._isRawInput?this.value:""}get displayValue(){return this.value}reset(){this._isRawInput=!1,this._value=""}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(n),this._value||(this._isRawInput=!1),new xe}nearestInputPos(t,n){n===void 0&&(n=de.NONE);const r=0,l=this._value.length;switch(n){case de.LEFT:case de.FORCE_LEFT:return r;case de.NONE:case de.RIGHT:case de.FORCE_RIGHT:default:return l}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._isRawInput?n-t:0}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),r===void 0&&(r={}),r.raw&&this._isRawInput&&this._value.slice(t,n)||""}get isComplete(){return!0}get isFilled(){return!!this._value}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new xe;const r=this.eager===!0||this.eager==="append",a=this.char===t&&(this.isUnmasking||n.input||n.raw)&&(!n.raw||!r)&&!n.tail,s=new xe({inserted:this.char,rawInserted:a?this.char:""});return this._value=this.char,this._isRawInput=a&&(n.raw||n.input),s}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new xe;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,n,r){const l=this._appendChar(t[0],n);return r!=null&&(l.tailShift+=this.appendTail(r).tailShift),l}doCommit(){}get state(){return{_value:this._value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value,this._isRawInput=!!t._rawInputValue}pad(t){return this._appendPlaceholder()}}class Qt{constructor(t){const{parent:n,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:i,...c}=t;this.masked=ht(c),Object.assign(this,{parent:n,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:i})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),t===0&&n>=1?(this.isFilled=!1,this.masked.remove(t,n)):new xe}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get rawInputValue(){return this.masked.rawInputValue}get displayValue(){return this.masked.value&&this.displayChar||this.value}get isComplete(){return!!this.masked.value||this.isOptional}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new xe;const r=this.masked.state;let l=this.masked._appendChar(t,this.currentMaskFlags(n));return l.inserted&&this.doValidate(n)===!1&&(l=new xe,this.masked.state=r),!l.inserted&&!this.isOptional&&!this.lazy&&!n.input&&(l.inserted=this.placeholderChar),l.skip=!l.inserted&&!this.isOptional,this.isFilled=!!l.inserted,l}append(t,n,r){return this.masked.append(t,this.currentMaskFlags(n),r)}_appendPlaceholder(){return this.isFilled||this.isOptional?new xe:(this.isFilled=!0,new xe({inserted:this.placeholderChar}))}_appendEager(){return new xe}extractTail(t,n){return this.masked.extractTail(t,n)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.masked.extractInput(t,n,r)}nearestInputPos(t,n){n===void 0&&(n=de.NONE);const r=0,l=this.value.length,a=Math.min(Math.max(t,r),l);switch(n){case de.LEFT:case de.FORCE_LEFT:return this.isComplete?a:r;case de.RIGHT:case de.FORCE_RIGHT:return this.isComplete?a:l;case de.NONE:default:return a}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.value.slice(t,n).length}doValidate(t){return this.masked.doValidate(this.currentMaskFlags(t))&&(!this.parent||this.parent.doValidate(this.currentMaskFlags(t)))}doCommit(){this.masked.doCommit()}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue,masked:this.masked.state,isFilled:this.isFilled}}set state(t){this.masked.state=t.masked,this.isFilled=t.isFilled}currentMaskFlags(t){var n;return{...t,_beforeTailState:(t==null||(n=t._beforeTailState)==null?void 0:n.masked)||t?._beforeTailState}}pad(t){return new xe}}Qt.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 $r extends He{updateOptions(t){super.updateOptions(t)}_update(t){const n=t.mask;n&&(t.validate=r=>r.search(n)>=0),super._update(t)}}ge.MaskedRegExp=$r;class qe extends He{constructor(t){super({...qe.DEFAULTS,...t,definitions:Object.assign({},Qt.DEFAULT_DEFINITIONS,t?.definitions)})}updateOptions(t){super.updateOptions(t)}_update(t){t.definitions=Object.assign({},this.definitions,t.definitions),super._update(t),this._rebuildMask()}_rebuildMask(){const t=this.definitions;this._blocks=[],this.exposeBlock=void 0,this._stops=[],this._maskedBlocks={};const n=this.mask;if(!n||!t)return;let r=!1,l=!1;for(let a=0;a<n.length;++a){if(this.blocks){const d=n.slice(a),u=Object.keys(this.blocks).filter(g=>d.indexOf(g)===0);u.sort((g,b)=>b.length-g.length);const p=u[0];if(p){const{expose:g,repeat:b,...m}=Ut(this.blocks[p]),h={lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,autofix:this.autofix,...m,repeat:b,parent:this},y=b!=null?new ge.RepeatBlock(h):ht(h);y&&(this._blocks.push(y),g&&(this.exposeBlock=y),this._maskedBlocks[p]||(this._maskedBlocks[p]=[]),this._maskedBlocks[p].push(this._blocks.length-1)),a+=p.length-1;continue}}let s=n[a],i=s in t;if(s===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=n[a],!s)break;i=!1}const c=i?new Qt({isOptional:l,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...Ut(t[s]),parent:this}):new po({char:s,eager:this.eager,isUnmasking:r});this._blocks.push(c)}}get state(){return{...super.state,_blocks:this._blocks.map(t=>t.state)}}set state(t){if(!t){this.reset();return}const{_blocks:n,...r}=t;this._blocks.forEach((l,a)=>l.state=n[a]),super.state=r}reset(){super.reset(),this._blocks.forEach(t=>t.reset())}get isComplete(){return this.exposeBlock?this.exposeBlock.isComplete:this._blocks.every(t=>t.isComplete)}get isFilled(){return this._blocks.every(t=>t.isFilled)}get isFixed(){return this._blocks.every(t=>t.isFixed)}get isOptional(){return this._blocks.every(t=>t.isOptional)}doCommit(){this._blocks.forEach(t=>t.doCommit()),super.doCommit()}get unmaskedValue(){return this.exposeBlock?this.exposeBlock.unmaskedValue:this._blocks.reduce((t,n)=>t+=n.unmaskedValue,"")}set unmaskedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.unmaskedValue=t,this.appendTail(n),this.doCommit()}else super.unmaskedValue=t}get value(){return this.exposeBlock?this.exposeBlock.value:this._blocks.reduce((t,n)=>t+=n.value,"")}set value(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.value=t,this.appendTail(n),this.doCommit()}else super.value=t}get typedValue(){return this.exposeBlock?this.exposeBlock.typedValue:super.typedValue}set typedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.typedValue=t,this.appendTail(n),this.doCommit()}else super.typedValue=t}get displayValue(){return this._blocks.reduce((t,n)=>t+=n.displayValue,"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const n=new xe;let r=(t=this._mapPosToBlock(this.displayValue.length))==null?void 0:t.index;if(r==null)return n;this._blocks[r].isFilled&&++r;for(let l=r;l<this._blocks.length;++l){const a=this._blocks[l]._appendEager();if(!a.inserted)break;n.aggregate(a)}return n}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._mapPosToBlock(this.displayValue.length),l=new xe;if(!r)return l;for(let s=r.index,i;i=this._blocks[s];++s){var a;const c=i._appendChar(t,{...n,_beforeTailState:(a=n._beforeTailState)==null||(a=a._blocks)==null?void 0:a[s]});if(l.aggregate(c),c.consumed)break}return l}extractTail(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=new Nt;return t===n||this._forEachBlocksInRange(t,n,(l,a,s,i)=>{const c=l.extractTail(s,i);c.stop=this._findStopBefore(a),c.from=this._blockStartPos(a),c instanceof Nt&&(c.blockIndex=a),r.extend(c)}),r}extractInput(t,n,r){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),r===void 0&&(r={}),t===n)return"";let l="";return this._forEachBlocksInRange(t,n,(a,s,i,c)=>{l+=a.extractInput(i,c,r)}),l}_findStopBefore(t){let n;for(let r=0;r<this._stops.length;++r){const l=this._stops[r];if(l<=t)n=l;else break}return n}_appendPlaceholder(t){const n=new xe;if(this.lazy&&t==null)return n;const r=this._mapPosToBlock(this.displayValue.length);if(!r)return n;const l=r.index,a=t??this._blocks.length;return this._blocks.slice(l,a).forEach(s=>{if(!s.lazy||t!=null){var i;n.aggregate(s._appendPlaceholder((i=s._blocks)==null?void 0:i.length))}}),n}_mapPosToBlock(t){let n="";for(let r=0;r<this._blocks.length;++r){const l=this._blocks[r],a=n.length;if(n+=l.displayValue,t<=n.length)return{index:r,offset:t-a}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce((n,r)=>n+=r.displayValue.length,0)}_forEachBlocksInRange(t,n,r){n===void 0&&(n=this.displayValue.length);const l=this._mapPosToBlock(t);if(l){const a=this._mapPosToBlock(n),s=a&&l.index===a.index,i=l.offset,c=a&&s?a.offset:this._blocks[l.index].displayValue.length;if(r(this._blocks[l.index],l.index,i,c),a&&!s){for(let d=l.index+1;d<a.index;++d)r(this._blocks[d],d,0,this._blocks[d].displayValue.length);r(this._blocks[a.index],a.index,0,a.offset)}}}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._forEachBlocksInRange(t,n,(l,a,s,i)=>{r.aggregate(l.remove(s,i))}),r}nearestInputPos(t,n){if(n===void 0&&(n=de.NONE),!this._blocks.length)return 0;const r=new Fm(this,t);if(n===de.NONE)return r.pushRightBeforeInput()||(r.popState(),r.pushLeftBeforeInput())?r.pos:this.displayValue.length;if(n===de.LEFT||n===de.FORCE_LEFT){if(n===de.LEFT){if(r.pushRightBeforeFilled(),r.ok&&r.pos===t)return t;r.popState()}if(r.pushLeftBeforeInput(),r.pushLeftBeforeRequired(),r.pushLeftBeforeFilled(),n===de.LEFT){if(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.ok&&r.pos<=t||(r.popState(),r.ok&&r.pos<=t))return r.pos;r.popState()}return r.ok?r.pos:n===de.FORCE_LEFT?0:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:0)}return n===de.RIGHT||n===de.FORCE_RIGHT?(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.pushRightBeforeFilled()?r.pos:n===de.FORCE_RIGHT?this.displayValue.length:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:this.nearestInputPos(t,de.LEFT))):t}totalInputPositions(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);let r=0;return this._forEachBlocksInRange(t,n,(l,a,s,i)=>{r+=l.totalInputPositions(s,i)}),r}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const n=this._maskedBlocks[t];return n?n.map(r=>this._blocks[r]):[]}pad(t){const n=new xe;return this._forEachBlocksInRange(0,this.displayValue.length,r=>n.aggregate(r.pad(t))),n}}qe.DEFAULTS={...He.DEFAULTS,lazy:!0,placeholderChar:"_"},qe.STOP_CHAR="`",qe.ESCAPE_CHAR="\\",qe.InputDefinition=Qt,qe.FixedDefinition=po,ge.MaskedPattern=qe;class en extends qe{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:n=this.to||0,from:r=this.from||0,maxLength:l=this.maxLength||0,autofix:a=this.autofix,...s}=t;this.to=n,this.from=r,this.maxLength=Math.max(String(n).length,l),this.autofix=a;const i=String(this.from).padStart(this.maxLength,"0"),c=String(this.to).padStart(this.maxLength,"0");let d=0;for(;d<c.length&&c[d]===i[d];)++d;s.mask=c.slice(0,d).replace(/0/g,"\\0")+"0".repeat(this.maxLength-d),super._update(s)}get isComplete(){return super.isComplete&&!!this.value}boundaries(t){let n="",r="";const[,l,a]=t.match(/^(\D*)(\d*)(\D*)/)||[];return a&&(n="0".repeat(l.length)+a,r="9".repeat(l.length)+a),n=n.padEnd(this.maxLength,"0"),r=r.padEnd(this.maxLength,"9"),[n,r]}doPrepareChar(t,n){n===void 0&&(n={});let r;return[t,r]=super.doPrepareChar(t.replace(/\D/g,""),n),t||(r.skip=!this.isComplete),[t,r]}_appendCharRaw(t,n){if(n===void 0&&(n={}),!this.autofix||this.value.length+1>this.maxLength)return super._appendCharRaw(t,n);const r=String(this.from).padStart(this.maxLength,"0"),l=String(this.to).padStart(this.maxLength,"0"),[a,s]=this.boundaries(this.value+t);return Number(s)<this.from?super._appendCharRaw(r[this.value.length],n):Number(a)>this.to?!n.tail&&this.autofix==="pad"&&this.value.length+1<this.maxLength?super._appendCharRaw(r[this.value.length],n).aggregate(this._appendCharRaw(t,n)):super._appendCharRaw(l[this.value.length],n):super._appendCharRaw(t,n)}doValidate(t){const n=this.value;if(n.search(/[^0]/)===-1&&n.length<=this._matchFrom)return!0;const[l,a]=this.boundaries(n);return this.from<=Number(a)&&Number(l)<=this.to&&super.doValidate(t)}pad(t){const n=new xe;if(this.value.length===this.maxLength)return n;const r=this.value,l=this.maxLength-this.value.length;if(l){this.reset();for(let a=0;a<l;++a)n.aggregate(super._appendCharRaw("0",t));r.split("").forEach(a=>this._appendCharRaw(a))}return n}}ge.MaskedRange=en;const Dm="d{.}`m{.}`Y";class yt extends qe{static extractPatternOptions(t){const{mask:n,pattern:r,...l}=t;return{...l,mask:$t(n)?n:r}}constructor(t){super(yt.extractPatternOptions({...yt.DEFAULTS,...t}))}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:n,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(n)?n:r,blocks:s})}doValidate(t){const n=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&n!=null&&(this.min==null||this.min<=n)&&(this.max==null||n<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}optionsIsChanged(t){return super.optionsIsChanged(yt.extractPatternOptions(t))}}yt.GET_DEFAULT_BLOCKS=()=>({d:{mask:en,from:1,to:31,maxLength:2},m:{mask:en,from:1,to:12,maxLength:2},Y:{mask:en,from:1900,to:9999}}),yt.DEFAULTS={...qe.DEFAULTS,mask:Date,pattern:Dm,format:(o,t)=>{if(!o)return"";const n=String(o.getDate()).padStart(2,"0"),r=String(o.getMonth()+1).padStart(2,"0"),l=o.getFullYear();return[n,r,l].join(".")},parse:(o,t)=>{const[n,r,l]=o.split(".").map(Number);return new Date(l,r-1,n)}},ge.MaskedDate=yt;class tn extends He{constructor(t){super({...tn.DEFAULTS,...t}),this.currentMask=void 0}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),"mask"in t&&(this.exposeMask=void 0,this.compiledMasks=Array.isArray(t.mask)?t.mask.map(n=>{const{expose:r,...l}=Ut(n),a=ht({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...l});return r&&(this.exposeMask=a),a}):[])}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._applyDispatch(t,n);return this.currentMask&&r.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(n))),r}_applyDispatch(t,n,r){t===void 0&&(t=""),n===void 0&&(n={}),r===void 0&&(r="");const l=n.tail&&n._beforeTailState!=null?n._beforeTailState._value:this.value,a=this.rawInputValue,s=n.tail&&n._beforeTailState!=null?n._beforeTailState._rawInputValue:a,i=a.slice(s.length),c=this.currentMask,d=new xe,u=c?.state;return this.currentMask=this.doDispatch(t,{...n},r),this.currentMask&&(this.currentMask!==c?(this.currentMask.reset(),s&&(this.currentMask.append(s,{raw:!0}),d.tailShift=this.currentMask.value.length-l.length),i&&(d.tailShift+=this.currentMask.append(i,{raw:!0,tail:!0}).tailShift)):u&&(this.currentMask.state=u)),d}_appendPlaceholder(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}appendTail(t){const n=new xe;return t&&n.aggregate(this._applyDispatch("",{},t)),n.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var n,r;return{...t,_beforeTailState:((n=t._beforeTailState)==null?void 0:n.currentMaskRef)===this.currentMask&&((r=t._beforeTailState)==null?void 0:r.currentMask)||t._beforeTailState}}doDispatch(t,n,r){return n===void 0&&(n={}),r===void 0&&(r=""),this.dispatch(t,this,n,r)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,n){n===void 0&&(n={});let[r,l]=super.doPrepare(t,n);if(this.currentMask){let a;[r,a]=super.doPrepare(r,this.currentMaskFlags(n)),l=l.aggregate(a)}return[r,l]}doPrepareChar(t,n){n===void 0&&(n={});let[r,l]=super.doPrepareChar(t,n);if(this.currentMask){let a;[r,a]=super.doPrepareChar(r,this.currentMaskFlags(n)),l=l.aggregate(a)}return[r,l]}reset(){var t;(t=this.currentMask)==null||t.reset(),this.compiledMasks.forEach(n=>n.reset())}get value(){return this.exposeMask?this.exposeMask.value:this.currentMask?this.currentMask.value:""}set value(t){this.exposeMask?(this.exposeMask.value=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.value=t}get unmaskedValue(){return this.exposeMask?this.exposeMask.unmaskedValue:this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){this.exposeMask?(this.exposeMask.unmaskedValue=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.unmaskedValue=t}get typedValue(){return this.exposeMask?this.exposeMask.typedValue:this.currentMask?this.currentMask.typedValue:""}set typedValue(t){if(this.exposeMask){this.exposeMask.typedValue=t,this.currentMask=this.exposeMask,this._applyDispatch();return}let n=String(t);this.currentMask&&(this.currentMask.typedValue=t,n=this.currentMask.unmaskedValue),this.unmaskedValue=n}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var t;return!!((t=this.currentMask)!=null&&t.isComplete)}get isFilled(){var t;return!!((t=this.currentMask)!=null&&t.isFilled)}remove(t,n){const r=new xe;return this.currentMask&&r.aggregate(this.currentMask.remove(t,n)).aggregate(this._applyDispatch()),r}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map(n=>n.state),currentMaskRef:this.currentMask,currentMask:(t=this.currentMask)==null?void 0:t.state}}set state(t){const{compiledMasks:n,currentMaskRef:r,currentMask:l,...a}=t;n&&this.compiledMasks.forEach((s,i)=>s.state=n[i]),r!=null&&(this.currentMask=r,this.currentMask.state=l),super.state=a}extractInput(t,n,r){return this.currentMask?this.currentMask.extractInput(t,n,r):""}extractTail(t,n){return this.currentMask?this.currentMask.extractTail(t,n):super.extractTail(t,n)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,n){return this.currentMask?this.currentMask.nearestInputPos(t,n):super.nearestInputPos(t,n)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(t){this._overwrite=t}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(t){this._eager=t}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(t){this._skipInvalid=t}get autofix(){return this.currentMask?this.currentMask.autofix:this._autofix}set autofix(t){this._autofix=t}maskEquals(t){return Array.isArray(t)?this.compiledMasks.every((n,r)=>{if(!t[r])return;const{mask:l,...a}=t[r];return Ln(n,a)&&n.maskEquals(l)}):super.maskEquals(t)}typedValueEquals(t){var n;return!!((n=this.currentMask)!=null&&n.typedValueEquals(t))}}tn.DEFAULTS={...He.DEFAULTS,dispatch:(o,t,n,r)=>{if(!t.compiledMasks.length)return;const l=t.rawInputValue,a=t.compiledMasks.map((s,i)=>{const c=t.currentMask===s,d=c?s.displayValue.length:s.nearestInputPos(s.displayValue.length,de.FORCE_LEFT);return s.rawInputValue!==l?(s.reset(),s.append(l,{raw:!0})):c||s.remove(d),s.append(o,t.currentMaskFlags(n)),s.appendTail(r),{index:i,weight:s.rawInputValue.length,totalInputPositions:s.totalInputPositions(0,Math.max(d,s.nearestInputPos(s.displayValue.length,de.FORCE_LEFT)))}});return a.sort((s,i)=>i.weight-s.weight||i.totalInputPositions-s.totalInputPositions),t.compiledMasks[a[0].index]}},ge.MaskedDynamic=tn;class nn extends qe{constructor(t){super({...nn.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){const{enum:n,...r}=t;if(n){const l=n.map(i=>i.length),a=Math.min(...l),s=Math.max(...l)-a;r.mask="*".repeat(a),s&&(r.mask+="["+"*".repeat(s)+"]"),this.enum=n}super._update(r)}_appendCharRaw(t,n){n===void 0&&(n={});const r=Math.min(this.nearestInputPos(0,de.FORCE_RIGHT),this.value.length),l=this.enum.filter(a=>this.matchValue(a,this.unmaskedValue+t,r));if(l.length){l.length===1&&this._forEachBlocksInRange(0,this.value.length,(s,i)=>{const c=l[0][i];i>=this.value.length||c===s.value||(s.reset(),s._appendChar(c,n))});const a=super._appendCharRaw(l[0][this.value.length],n);return l.length===1&&l[0].slice(this.unmaskedValue.length).split("").forEach(s=>a.aggregate(super._appendCharRaw(s))),a}return new xe({skip:!this.isComplete})}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new gt("",t)}remove(t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),t===n)return new xe;const r=Math.min(super.nearestInputPos(0,de.FORCE_RIGHT),this.value.length);let l;for(l=t;l>=0&&!(this.enum.filter(i=>this.matchValue(i,this.value.slice(r,l),r)).length>1);--l);const a=super.remove(l,n);return a.tailShift+=l-t,a}get isComplete(){return this.enum.indexOf(this.value)>=0}}nn.DEFAULTS={...qe.DEFAULTS,matchValue:(o,t,n)=>o.indexOf(t,n)===n},ge.MaskedEnum=nn;class Nr extends He{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}ge.MaskedFunction=Nr;var Ar;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?"[+|\\-]?":""),n="\\d*",r=(this.scale?"("+co(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+n+r),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(co).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(co(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const n=t.split(this.radix);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),n.join(this.radix)}doPrepareChar(t,n){n===void 0&&(n={});const[r,l]=super.doPrepareChar(this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(n.input&&n.raw||!n.input&&!n.raw)?t.replace(this._mapToRadixRegExp,this.radix):t),n);return t&&!r&&(l.skip=!0),r&&!this.allowPositive&&!this.value&&r!=="-"&&l.aggregate(this._appendChar("-")),[r,l]}_separatorsCount(t,n){n===void 0&&(n=!1);let r=0;for(let l=0;l<t;++l)this._value.indexOf(this.thousandsSeparator,l)===l&&(++r,n&&(t+=this.thousandsSeparator.length));return r}_separatorsCountFromSlice(t){return t===void 0&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n),this._removeThousandsSeparators(super.extractInput(t,n,r))}_appendCharRaw(t,n){n===void 0&&(n={});const r=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,l=this._separatorsCountFromSlice(r);this._value=this._removeThousandsSeparators(this.value);const a=this._value;this._value+=t;const s=this.number;let i=!isNaN(s),c=!1;if(i){let g;this.min!=null&&this.min<0&&this.number<this.min&&(g=this.min),this.max!=null&&this.max>0&&this.number>this.max&&(g=this.max),g!=null&&(this.autofix?(this._value=this.format(g,this).replace(Ye.UNMASKED_RADIX,this.radix),c||(c=a===this._value&&!n.tail)):i=!1),i&&(i=!!this._value.match(this._numberRegExp))}let d;i?d=new xe({inserted:this._value.slice(a.length),rawInserted:c?"":t,skip:c}):(this._value=a,d=new xe),this._value=this._insertThousandsSeparators(this._value);const u=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,p=this._separatorsCountFromSlice(u);return d.tailShift+=(p-l)*this.thousandsSeparator.length,d}_findSeparatorAround(t){if(this.thousandsSeparator){const n=t-this.thousandsSeparator.length+1,r=this.value.indexOf(this.thousandsSeparator,n);if(r<=t)return r}return-1}_adjustRangeWithSeparators(t,n){const r=this._findSeparatorAround(t);r>=0&&(t=r);const l=this._findSeparatorAround(n);return l>=0&&(n=l+this.thousandsSeparator.length),[t,n]}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n);const r=this.value.slice(0,t),l=this.value.slice(n),a=this._separatorsCount(r.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(r+l));const s=this._separatorsCountFromSlice(r);return new xe({tailShift:(s-a)*this.thousandsSeparator.length})}nearestInputPos(t,n){if(!this.thousandsSeparator)return t;switch(n){case de.NONE:case de.LEFT:case de.FORCE_LEFT:{const r=this._findSeparatorAround(t-1);if(r>=0){const l=r+this.thousandsSeparator.length;if(t<l||this.value.length<=l||n===de.FORCE_LEFT)return r}break}case de.RIGHT:case de.FORCE_RIGHT:{const r=this._findSeparatorAround(t);if(r>=0)return r+this.thousandsSeparator.length}}return t}doCommit(){if(this.value){const t=this.number;let n=t;this.min!=null&&(n=Math.max(n,this.min)),this.max!=null&&(n=Math.min(n,this.max)),n!==t&&(this.unmaskedValue=this.format(n,this));let r=this.value;this.normalizeZeros&&(r=this._normalizeZeros(r)),this.padFractionalZeros&&this.scale>0&&(r=this._padFractionalZeros(r)),this._value=r}super.doCommit()}_normalizeZeros(t){const n=this._removeThousandsSeparators(t).split(this.radix);return n[0]=n[0].replace(/^(\D*)(0*)(\d*)/,(r,l,a,s)=>l+s),t.length&&!/\d$/.test(n[0])&&(n[0]=n[0]+"0"),n.length>1&&(n[1]=n[1].replace(/0*$/,""),n[1].length||(n.length=1)),this._insertThousandsSeparators(n.join(this.radix))}_padFractionalZeros(t){if(!t)return t;const n=t.split(this.radix);return n.length<2&&n.push(""),n[1]=n[1].padEnd(this.scale,"0"),n.join(this.radix)}doSkipInvalid(t,n,r){n===void 0&&(n={});const l=this.scale===0&&t!==this.thousandsSeparator&&(t===this.radix||t===Ye.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,n,r)&&!l}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,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==="")}}Ar=Ye,Ye.UNMASKED_RADIX=".",Ye.EMPTY_VALUES=[...He.EMPTY_VALUES,0],Ye.DEFAULTS={...He.DEFAULTS,mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[Ar.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:o=>o.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},ge.MaskedNumber=Ye;const On={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function fo(o,t,n){t===void 0&&(t=On.MASKED),n===void 0&&(n=On.MASKED);const r=ht(o);return l=>r.runIsolated(a=>(a[t]=l,a[n]))}function Mr(o,t,n,r){return fo(t,n,r)(o)}ge.PIPE_TYPE=On,ge.createPipe=fo,ge.pipe=Mr;class Fr 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 n,r,l;const{repeat:a,...s}=Ut(t);this._blockOpts=Object.assign({},this._blockOpts,s);const i=ht(this._blockOpts);this.repeat=(n=(r=a??i.repeat)!=null?r:this.repeat)!=null?n:1/0,super._update({mask:"m".repeat(Math.max(this.repeatTo===1/0&&((l=this._blocks)==null?void 0:l.length)||0,this.repeatFrom)),blocks:{m:i},eager:i.eager,overwrite:i.overwrite,skipInvalid:i.skipInvalid,lazy:i.lazy,placeholderChar:i.placeholderChar,displayChar:i.displayChar})}_allocateBlock(t){if(t<this._blocks.length)return this._blocks[t];if(this.repeatTo===1/0||this._blocks.length<this.repeatTo)return this._blocks.push(ht(this._blockOpts)),this.mask+="m",this._blocks[this._blocks.length-1]}_appendCharRaw(t,n){n===void 0&&(n={});const r=new xe;for(let c=(l=(a=this._mapPosToBlock(this.displayValue.length))==null?void 0:a.index)!=null?l:Math.max(this._blocks.length-1,0),d,u;d=(s=this._blocks[c])!=null?s:u=!u&&this._allocateBlock(c);++c){var l,a,s,i;const p=d._appendChar(t,{...n,_beforeTailState:(i=n._beforeTailState)==null||(i=i._blocks)==null?void 0:i[c]});if(p.skip&&u){this._blocks.pop(),this.mask=this.mask.slice(1);break}if(r.aggregate(p),p.consumed)break}return r}_trimEmptyTail(t,n){var r,l;t===void 0&&(t=0);const a=Math.max(((r=this._mapPosToBlock(t))==null?void 0:r.index)||0,this.repeatFrom,0);let s;n!=null&&(s=(l=this._mapPosToBlock(n))==null?void 0:l.index),s==null&&(s=this._blocks.length-1);let i=0;for(let c=s;a<=c&&!this._blocks[c].unmaskedValue;--c,++i);i&&(this._blocks.splice(s-i+1,i),this.mask=this.mask.slice(i))}reset(){super.reset(),this._trimEmptyTail()}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._trimEmptyTail(t,n),r}totalInputPositions(t,n){return t===void 0&&(t=0),n==null&&this.repeatTo===1/0?1/0:super.totalInputPositions(t,n)}get state(){return super.state}set state(t){this._blocks.length=t._blocks.length,this.mask=this.mask.slice(0,this._blocks.length),super.state=t}}ge.RepeatBlock=Fr;try{globalThis.IMask=ge}catch{}const Pn=Object.freeze(Object.defineProperty({__proto__:null,ChangeDetails:xe,ChunksTailDetails:Nt,DIRECTION:de,HTMLContenteditableMaskElement:uo,HTMLInputMaskElement:Vr,HTMLMaskElement:Jt,InputMask:Sr,MaskElement:In,Masked:He,MaskedDate:yt,MaskedDynamic:tn,MaskedEnum:nn,MaskedFunction:Nr,MaskedNumber:Ye,MaskedPattern:qe,MaskedRange:en,MaskedRegExp:$r,PIPE_TYPE:On,PatternFixedDefinition:po,PatternInputDefinition:Qt,RepeatBlock:Fr,createMask:ht,createPipe:fo,default:ge,forceDirection:vr,normalizeOpts:Ut,pipe:Mr},Symbol.toStringTag,{value:"Module"})),Tm=async o=>{try{const t=new FormData;return t.append("unique","true"),t.append("file",o),(await(await fetch("/file/upload/uploads?id=&form=&table=",{method:"POST",body:t})).json())?.result}catch(t){console.error(t)}},Lm=async(o,t,n)=>{const r=t.clipboardData?.items;if(r){const l=t.clipboardData?.getData("text/html"),a=t.clipboardData?.getData("text/plain");if(l){const{state:s,dispatch:i}=o,{tr:c}=s,d=n.fromSchema(o.state.schema),u=new DOMParser().parseFromString(l,"text/html").body,p=d.parse(u),g=c.replaceSelectionWith(p);return i(g),t.preventDefault(),!0}if(a){const{state:s,dispatch:i}=o,{tr:c}=s,d=c.insertText(a,s.selection.from,s.selection.to);return i(d),t.preventDefault(),!0}for(let s=0;s<r.length;s++){const i=r[s];if(i.type.startsWith("image/")){const c=i.getAsFile();if(c){const d=await Tm(c),{schema:u}=o.state,p=u.nodes.image.create({src:d?.file_path}),g=o.state.tr.replaceSelectionWith(p);return o.dispatch(g),t.preventDefault(),!0}}}}return!1},Im="https://esm.sh",Ze="3.7.2",Dr="3.7.2",Rm=`?deps=@tiptap/core@${Ze},@tiptap/pm@${Dr}`,Je=o=>`${Im}/${o}${Rm}`,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@${Dr}/model`)},on="__vs_form_tiptap_loader__",et=o=>import(o),Ie=(o,t)=>o?.[t]||o?.default?.[t]||o?.default?.default?.[t]||o?.default||o,Tr={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;"},Om=o=>o.extend({addOptions(){return{...this.parent?.(),levels:[1,2,3,4,5,6]}}}).extend({addAttributes(){return{...this.parent?.(),level:{default:1,renderHTML:t=>{const n=t.level||1;return{class:`heading-level-${n}`,style:Tr[n]||Tr[1]}}}}}}),Pm=o=>o.configure({HTMLAttributes:{style:"min-height: 1rem;"}}),zm=(o,t,n,r,l)=>{const a=t.extend({renderHTML({HTMLAttributes:s}){return["div",{style:"overflow-x: auto;"},["table",s,0]]},parseHTML(){return[{tag:"div.table-wrapper table",priority:100},{tag:"table"}]}});return o.extend({addExtensions(){return[a.configure({HTMLAttributes:{class:"editor-content"},resizable:!0}),n,r,l]}})},jm=o=>o.extend({addAttributes(){return{...this.parent?.(),fontFamily:{default:null,parseHTML:t=>t.style.fontFamily?.replace(/['"]/g,""),renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}},fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}},color:{default:null,parseHTML:t=>t.style.color?.replace(/['"]/g,""),renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}},backgroundColor:{default:null,parseHTML:t=>t.style.backgroundColor?.replace(/['"]/g,""),renderHTML:t=>!t.backgroundColor||t.backgroundColor==="transparent"?{}:{style:`background-color: ${t.backgroundColor}`}}}},addCommands(){return{setFontFamily:t=>({chain:n})=>n().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run(),setFontSize:t=>({chain:n})=>n().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run(),setColor:t=>({chain:n})=>n().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run(),setBackgroundColor:t=>({chain:n})=>n().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Um=o=>o.create({name:"iframe",group:"block",inline:!1,atom:!0,selectable:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"280"},frameborder:{default:"0"},allow:{default:null},allowfullscreen:{default:null},referrerpolicy:{default:null},loading:{default:null},class:{default:null},title:{default:null},style:{default:null}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",t]}});async function Hm(){if(typeof window>"u")return null;const o=window;return o[on]||(o[on]=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,n,r,l,a,s,i,c,d,u,p,g,b])=>{const m=Ie(t,"Editor"),h=Ie(t,"Node"),y=Ie(t,"Extension"),w=Ie(n,"StarterKit"),x=Ie(r,"TextStyle"),C=Ie(l,"TableKit"),S=Ie(l,"Table"),H=Ie(l,"TableRow"),W=Ie(l,"TableCell"),T=Ie(l,"TableHeader"),E=Ie(a,"Highlight"),$=Ie(s,"Subscript"),N=Ie(i,"Superscript"),V=Ie(c,"Link"),M=Ie(d,"Image"),O=Ie(u,"TextAlign"),B=Ie(p,"Heading"),K=Ie(g,"Paragraph"),I=Ie(b,"DOMParser");if(!m||!h||!w||!x||!C||!S||!H||!W||!T||!E||!$||!N||!V||!M||!O||!B||!K||!I)throw new Error("Failed to resolve one or more Tiptap modules");return{Editor:m,Extension:y,ProseMirrorDOMParser:I,StarterKit:w,ExtendedTextStyle:jm(x),Highlight:E,Subscript:$,Superscript:N,Link:V,Image:M,TextAlign:O,CustomHeading:Om(B),CustomParagraph:Pm(K),CustomTableKit:zm(C,S,H,W,T),Iframe:Um(h)}}).catch(t=>{throw delete o[on],t})),o[on]}function qm(o){let t=!1;const n=e.shallowRef(null),r=e.ref(!1),l=e.ref(""),a=async(d,u="")=>{if(!d)return null;r.value=!0,l.value="";try{const p=await Hm();if(!p)return null;const g=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:(b,m)=>Lm(b,m,p.ProseMirrorDOMParser),handleKeyDown:(b,m)=>{if(m.key==="Tab"){const h=b.state,{$anchor:y}=h.selection;let w=!1;for(let x=y.depth;x>0;x--){const C=y.node(x);if(C&&(C.type.name==="bulletList"||C.type.name==="orderedList")){w=!0;break}}return w?!1:(m.preventDefault(),!0)}return!1}}});return n.value=e.markRaw(g),g}catch(p){return l.value="Failed to load rich text editor dependencies.",console.error("Failed to initialize rich text editor",p),null}finally{r.value=!1}},s=e.computed(()=>n.value||null);return e.watch(n,d=>{d&&n.value.on("update",u=>{if(!t){t=!0;const p=u.editor.getHTML();o.modelValue,setTimeout(()=>{t=!1},10)}})}),{editor:n,editorInstance:s,focusEditor:()=>{n.value&&!n.value.isFocused&&n.value.commands.focus()},createEditor:a,destroyEditor:()=>{n.value&&(n.value.destroy(),n.value=null)},isLoading:r,loadError:l}}function Km(o,t,n,{toEditorContent:r,toSourceContent:l}={}){const a=e.ref(!1),s=e.ref(""),i=e.ref(null);return{isHtmlMode:a,htmlContent:s,htmlTextarea:i,toggleHtmlMode:async u=>{if(a.value=u,u)o.value&&(s.value=l?await l(o.value.getHTML(),t):o.value.getHTML()),e.nextTick(()=>{i.value&&i.value.focus?.()});else if(o.value){const p=r?await r(s.value,t):s.value;o.value.commands.setContent(p,!0),e.nextTick(()=>{o.value?.commands?.focus?.()})}},onHtmlInput:u=>{s.value=u,n&&n("update:modelValue",u)}}}function Wm(){const o=e.ref(!1);return{isFullscreen:o,toggleFullscreen:()=>{o.value=!o.value}}}const At=o=>o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),rn=o=>{let t=At(o||"");return t=t.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,r,l,a)=>{const s=a?` title="${At(a)}"`:"";return`<img src="${At(l)}" alt="${At(r)}"${s}>`}),t=t.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,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},ln=o=>/^\s*\d+\.\s+/.test(o),mo=o=>/^\s*[-*+]\s+/.test(o),Lr=o=>/^\s*[-*+]\s+\[[ xX]\]\s+/.test(o),ho=o=>/^\s*>\s?/.test(o),go=o=>/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(o),Ir=o=>o.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>rn(t.trim())),Gm=(o,t)=>{const n=o[t],r=o[t+1];if(!n||!r||!n.includes("|")||!go(r))return null;const l=Ir(n),a=[];let s=t+2;for(;s<o.length&&o[s].includes("|")&&o[s].trim()!=="";){const d=Ir(o[s]);a.push(`<tr>${d.map(u=>`<td>${u}</td>`).join("")}</tr>`),s+=1}const i=`<thead><tr>${l.map(d=>`<th>${d}</th>`).join("")}</tr></thead>`,c=a.length?`<tbody>${a.join("")}</tbody>`:"";return{html:`<table>${i}${c}</table>`,nextIndex:s}},Ym=(o,t)=>{const n=ln(o[t]),r=n?"ol":"ul",l=[];let a=t;for(;a<o.length;){const s=o[a];if(s.trim()===""||!(n?ln(s):(mo(s)||Lr(s))&&!ln(s)))break;const c=s.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);if(c){const d=c[1].toLowerCase()==="x";l.push(`<li><input type="checkbox" disabled${d?" checked":""}> ${rn(c[2])}</li>`)}else{const d=s.replace(/^\s*(?:[-*+]|\d+\.)\s+/,"");l.push(`<li>${rn(d)}</li>`)}a+=1}return{html:`<${r}>${l.join("")}</${r}>`,nextIndex:a}},Xm=(o,t)=>{const r=o[t].replace(/^```/,"").trim(),l=[];let a=t+1;for(;a<o.length&&!o[a].startsWith("```");)l.push(o[a]),a+=1;return{html:`<pre><code${r?` class="language-${At(r)}"`:""}>${At(l.join(`
6
- `))}</code></pre>`,nextIndex:a<o.length?a+1:a}},Zm=(o,t)=>{const n=[];let r=t;for(;r<o.length;){const l=o[r];if(l.trim()===""||l.startsWith("```")||/^#{1,6}\s+/.test(l)||/^---+$/.test(l.trim())||/^\*\*\*+$/.test(l.trim())||ho(l)||ln(l)||mo(l)||r+1<o.length&&l.includes("|")&&go(o[r+1]))break;n.push(l.trim()),r+=1}return{html:`<p>${rn(n.join(" "))}</p>`,nextIndex:r}},Rr=o=>{const n=(o||"").replace(/\r\n/g,`
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 de=!1,ne=!1;const ae=e.reactive({}),fe=e.ref([]),Se=e.computed(()=>fe.value.map(f=>ae[f]).filter(Boolean)),Ve=e.ref(null),Oe=e.computed(()=>Ve.value?.entries??[]),Te=e.computed(()=>{if(Ve.value)return{left:`${Ve.value.point.x+12}px`,top:`${Ve.value.point.y+12}px`}}),Ne=e.computed(()=>{if(Array.isArray(n.tools)&&n.tools.length)return n.tools;const f=l?.tools;return Array.isArray(f)?f.map(g=>String(g)):typeof f=="string"?f.split(",").map(g=>g.trim()).filter(Boolean):[]}),Ce=e.computed(()=>{const f={search:!1,import:!1,export:!1,point:!1,line:!1,polygon:!1,rectangle:!1,ruler:!1};if(!Ne.value.length)return{...f,import:!0,export:!0,point:!0,line:!0,polygon:!0,rectangle:!0};const g=new Set(Ne.value.map(C=>C.toLowerCase()));return{search:g.has("search"),import:g.has("import"),export:g.has("export"),point:g.has("point"),line:g.has("line"),polygon:g.has("polygon"),rectangle:g.has("rectangle"),ruler:g.has("ruler")}});function Ee(f){if(typeof f!="string"||!f.trim())return"";if(/^https?:\/\//i.test(f))return f;const g=window?.location?.origin??"",C=f.replace(/^\/+/,"");return C?g?`${g}/${C}`:`/${C}`:g}function Pe(){const f=Array.isArray(v.basemaps)&&v.basemaps.length?v.basemaps:x.basemaps;if(Array.isArray(f)&&f.length){const C=f.map((F,D)=>{const G=String(F?.key??F?.id??F?.name??`b${D}`),le=Ee(String(F?.url??""));if(!le)return null;const se=typeof F?.preview=="string"&&F.preview?Ee(F.preview):"";return[G,{...F,url:le,preview:se}]}).filter(F=>Array.isArray(F)&&F.length===2).reduce((F,[D,G])=>(F[D]=G,F),{});if(Object.keys(C).length)return C}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 Me=Pe(),ze=Object.keys(Me),Ye=e.ref(ze.length?ze[0]:"");async function H(){if(typeof window>"u")return null;const f=window;if(f[Cn])return f[Cn];const g=G=>{if(Array.from(document.styleSheets).some(Ie=>Ie?.href?.includes(G)))return;const se=document.createElement("link");se.rel="stylesheet",se.href=G,document.head.appendChild(se)},C=async()=>{const G=new Function("u","return import(u)"),le=await G("https://esm.sh/maplibre-gl@3.6.2"),se=le?.default??le;if(!se)throw new Error("maplibre esm fallback failed");window.maplibregl=se,window.mapboxgl=se;const Ie=await G("https://esm.sh/@mapbox/mapbox-gl-draw@1.5.0"),tt=Ie?.default??Ie;if(!tt)throw new Error("mapbox draw esm fallback failed");window.MapboxDraw=tt},D=(async()=>{g("https://unpkg.com/maplibre-gl@3.6.2/dist/maplibre-gl.css"),g("https://unpkg.com/@mapbox/mapbox-gl-draw@1.5.0/dist/mapbox-gl-draw.css"),(!window.maplibregl||!window.MapboxDraw)&&await C();const G=window.maplibregl,le=window.MapboxDraw;if(!G)throw new Error("maplibregl not available after load");if(!le)throw new Error("MapboxDraw not available after load");return{maplibregl:G,MapboxDraw:le}})().catch(G=>{throw delete f[Cn],G});return f[Cn]=D,D}function Z(f){return{version:8,sources:{rasterSource:{type:"raster",tiles:[f],tileSize:256}},layers:[{id:"rasterLayer",type:"raster",source:"rasterSource"}]}}let te=null,ce=null,z=null,oe=null,_e=[],ve=null,j=null,w=null,A=!1,R=!1,re=!1,ge=null;function Ae(){return{onSetup(){const f=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[[0,0],[0,0],[0,0],[0,0],[0,0]]]}});return this.addFeature(f),this.clearSelectedFeatures(),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:f,startPoint:null,hasCoordinates:!1}},onMouseMove(f,g){if(!f.startPoint)return;const[C,F]=f.startPoint,D=g.lngLat.lng,G=g.lngLat.lat;f.rectangle.setCoordinates([[[C,F],[D,F],[D,G],[C,G],[C,F]]])},onClick(f,g){if(!f.startPoint){f.startPoint=[g.lngLat.lng,g.lngLat.lat],f.hasCoordinates=!0,f.rectangle.setCoordinates([[[g.lngLat.lng,g.lngLat.lat],[g.lngLat.lng,g.lngLat.lat],[g.lngLat.lng,g.lngLat.lat],[g.lngLat.lng,g.lngLat.lat],[g.lngLat.lng,g.lngLat.lat]]]);return}const[C,F]=f.startPoint,D=g.lngLat.lng,G=g.lngLat.lat;return Math.abs(C-D)>0&&Math.abs(F-G)>0?(f.rectangle.setCoordinates([[[C,F],[D,F],[D,G],[C,G],[C,F]]]),this.map.fire("draw.create",{features:[f.rectangle.toGeoJSON()]}),this.changeMode("simple_select",{featureIds:[f.rectangle.id]})):(this.deleteFeature([f.rectangle.id],{silent:!0}),f.hasCoordinates=!1,this.changeMode("simple_select"))},onStop(){},onTrash(f){this.deleteFeature([f.rectangle.id],{silent:!0}),this.changeMode("simple_select")},toDisplayFeatures(f,g,C){const F=g.properties.id===f.rectangle.id;F&&!f.hasCoordinates||(g.properties.active=F?"true":"false",C(g))}}}const $e=[{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 We(){const f=Ye.value;return!f||!Me[f]?.url?"":Me[f].url}function rt(f,g){return f?.id?String(f.id):f?.url?`${f.url}-${g}`:`layer-${g}`}function pt(f){const g=String(f?.url??"").trim();if(!g)return"";if(/^https?:\/\//i.test(g))return g;const C=window.location?.origin??"",F=g.replace(/^\/+/,"");return`${C}/${F}`}function Fe(f){f&&Ve.value?.layerId!==f||(Ve.value=null)}function lt(f,g={}){return f.popup===!1?[]:Array.isArray(f.popup)?f.popup.length?f.popup.map(C=>{const F=C?.field||C?.name;if(!F)return null;const D=g[F];return D==null||D===""?null:{key:C.label||F,value:String(D)}}).filter(Boolean):[]:Object.entries(g).slice(0,5).map(([C,F])=>({key:C,value:F==null?"—":String(F)}))}function Ot(f){if(!Array.isArray(f))return[];const g=F=>Array.isArray(F)&&F.length>=2&&Number.isFinite(Number(F[0]))&&Number.isFinite(Number(F[1])),C=F=>{if(!F.length)return F;const D=F[0],G=F[F.length-1];return!G||D[0]!==G[0]||D[1]!==G[1]?[...F,D]:F};if(f.length&&g(f[0])){const F=f.map(D=>[Number(D[0]),Number(D[1])]).filter(g);return F.length?[C(F)]:[]}return f.length&&Array.isArray(f[0])&&g(f[0][0])?f.map(D=>Array.isArray(D)?D.map(G=>[Number(G[0]),Number(G[1])]):[]).filter(D=>D.length).map(C):f.length&&Array.isArray(f[0])&&Array.isArray(f[0][0])&&g(f[0][0][0])?f.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(C):[]}function an(f){const g=f.style??{},C=g.color??"#3b82f6";if(!g.colorAttr||!g.colorSet)return C;const F=Object.keys(g.colorSet);if(!F.length)return C;const D=["match",["to-string",["get",g.colorAttr]]];return F.forEach(G=>{D.push(String(G),g.colorSet?.[G]??C)}),D.push(C),D}function Ft(f){if(!z)return;f.handlers.forEach(C=>{try{z.off(C.type,C.layerId,C.handler)}catch{}}),f.handlers=[],[...f.layerIds,...f.boundsIds].forEach(C=>{z.getLayer(C)&&z.removeLayer(C)}),z.getSource(f.sourceId)&&z.removeSource(f.sourceId);const g=`vs-ov-bounds-src-${f.id}`;z.getSource(g)&&z.removeSource(g),Fe(f.id)}function sn(f,g){if(!z)return[];const C=`vs-ov-bounds-src-${g}`,F=`vs-ov-bounds-line-${g}`,D=f.bounds??O.value??X.value,G=Ot(D);if(!G.length)return[];const le={type:"FeatureCollection",features:G.map(se=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:se}}))};return z.getSource(C)&&z.removeSource(C),z.addSource(C,{type:"geojson",data:le}),z.addLayer({id:F,type:"line",source:C,paint:{"line-color":f.style?.stroke??f.style?.color??"#2563eb","line-width":f.style?.width??2,"line-opacity":f.style?.opacity??.8,"line-dasharray":[2,2]}}),[F]}function Mt(f){if(!z)return;Ft(f);const g=f.config,C=pt(g);if(!C)return;const F=[],D=[];if(/\.v(?:m)?t(?:\?|$)/i.test(C)||/\.pbf(?:\?|$)/i.test(C)){const se=g.sourceLayer||g.layer||g.service_layer||g.dataset?.layer||g.id;z.addSource(f.sourceId,{type:"vector",tiles:[C]});const Ie=String(g.style?.type??"polygon").toLowerCase(),tt=an(g),mt=g.style?.opacity??.5;if(Ie==="point"){const kt=`vs-ov-point-${f.id}`;z.addLayer({id:kt,type:"circle",source:f.sourceId,"source-layer":se,paint:{"circle-color":tt,"circle-radius":5,"circle-opacity":mt}}),F.push(kt)}else if(Ie==="polyline"||Ie==="line"){const kt=`vs-ov-line-${f.id}`;z.addLayer({id:kt,type:"line",source:f.sourceId,"source-layer":se,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":tt,"line-width":g.style?.width??2,"line-opacity":mt}}),F.push(kt)}else{const kt=`vs-ov-fill-${f.id}`,pn=`vs-ov-border-${f.id}`;z.addLayer({id:kt,type:"fill",source:f.sourceId,"source-layer":se,paint:{"fill-color":tt,"fill-opacity":mt}}),z.addLayer({id:pn,type:"line",source:f.sourceId,"source-layer":se,paint:{"line-color":g.style?.stroke??g.style?.color??"#2563eb","line-width":g.style?.width??1,"line-opacity":mt}}),F.push(kt,pn)}}else{z.addSource(f.sourceId,{type:"raster",tiles:[C],tileSize:256});const se=`vs-ov-raster-${f.id}`;z.addLayer({id:se,type:"raster",source:f.sourceId,paint:{"raster-opacity":g.style?.opacity??1}}),F.push(se)}F.forEach(se=>{const Ie=mt=>{if(!mt?.features?.length){Fe(f.id);return}const kt=mt.features[0]?.properties??{},pn=lt(f.config,kt);if(!pn.length){Fe(f.id);return}Ve.value={layerId:f.id,entries:pn,point:{x:mt.point.x,y:mt.point.y}}},tt=()=>Fe(f.id);z.on("mousemove",se,Ie),z.on("mouseleave",se,tt),D.push({layerId:se,type:"mousemove",handler:Ie},{layerId:se,type:"mouseleave",handler:tt})}),f.layerIds=F,f.boundsIds=sn(f.config,f.id),f.handlers=D;const le=f.visible?"visible":"none";[...f.layerIds,...f.boundsIds].forEach(se=>{z.getLayer(se)&&z.setLayoutProperty(se,"visibility",le)})}function Pt(){if(!z)return;const g={type:"FeatureCollection",features:Ot(O.value??X.value).map(C=>({type:"Feature",properties:{},geometry:{type:"LineString",coordinates:C}}))};z.getSource(vn)?z.getSource(vn).setData(g):z.addSource(vn,{type:"geojson",data:g}),z.getLayer(En)||z.addLayer({id:En,type:"line",source:vn,paint:{"line-color":"#2563eb","line-width":2,"line-opacity":.8,"line-dasharray":[2,2]}})}function wo(f){if(!z||s.value)return;const g=ae[f];if(!g)return;g.visible=!g.visible;const C=g.visible?"visible":"none";[...g.layerIds,...g.boundsIds].forEach(F=>{z.getLayer(F)&&z.setLayoutProperty(F,"visibility",C)}),vt(),g.visible||Fe(f)}function vt(){if(!z)return;const f=[],g=[],C=[],F=[];fe.value.forEach(le=>{const se=ae[le];if(!se)return;const Ie=String(se.config?.url??""),tt=/\.v(?:m)?t(?:\?|$)/i.test(Ie),mt=/\.png(?:\?|$)/i.test(Ie);tt?C.push(...se.layerIds):mt?f.push(...se.layerIds):g.push(...se.layerIds),F.push(...se.boundsIds)}),[...f,...g,...C,...F].forEach(le=>{z.getLayer(le)&&z.moveLayer(le)}),z.getLayer(En)&&z.moveLayer(En),(z.getStyle?.()?.layers??[]).map(le=>String(le?.id??"")).filter(le=>le.startsWith("gl-draw-")).forEach(le=>{z.getLayer(le)&&z.moveLayer(le)})}function jn(f){if(!Me[f]||(Ye.value=f,!z))return;const g=We();if(!g)return;const C=z.getCenter?.(),F=z.getZoom?.(),D=oe?.getAll?.();z.setStyle(Z(g)),z.once("style.load",()=>{if(z&&(C&&Number.isFinite(F)&&z.jumpTo({center:[C.lng,C.lat],zoom:F}),Pt(),fe.value.forEach(G=>{const le=ae[G];le&&Mt(le)}),vt(),D?.features?.length&&oe))try{D.features.forEach(G=>oe.add(G)),d.value=D.features.length}catch{d.value=0}})}function cn(f){return{type:"Feature",properties:{},geometry:f}}function at(f){if(!f)return null;try{return JSON.parse(JSON.stringify(f))}catch{return null}}function Ht(f){if(!f)return null;const g=at(f.geometry);return g?{...f.id!==void 0?{id:f.id}:{},type:"Feature",properties:{...f.properties??{}},geometry:g}:null}function P(f){if(!f)return[];const g=(D,G)=>{if(!D?.type)return[];const le={...G??{}};return D.type==="MultiPoint"&&Array.isArray(D.coordinates)?D.coordinates.map(se=>cn({type:"Point",coordinates:se})).map(se=>({...se,properties:le})):D.type==="MultiLineString"&&Array.isArray(D.coordinates)?D.coordinates.map(se=>cn({type:"LineString",coordinates:se})).map(se=>({...se,properties:le})):D.type==="MultiPolygon"&&Array.isArray(D.coordinates)?D.coordinates.map(se=>cn({type:"Polygon",coordinates:se})).map(se=>({...se,properties:le})):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?D.geometries.flatMap(se=>g(se,le)):[{type:"Feature",properties:le,geometry:at(D)}]},C=D=>{if(!D)return null;if(D.type==="Feature"){const G=Ht(D);return G?g(G.geometry,G.properties):null}return D.geom?.type&&Array.isArray(D.geom.coordinates)?g({type:D.geom.type,coordinates:D.geom.coordinates},D.properties??{}):D.type==="GeometryCollection"&&Array.isArray(D.geometries)?g(D,D.properties??{}):typeof D.type=="string"&&Array.isArray(D.coordinates)?g(at(D),D.properties??{}):null};if(f.type==="FeatureCollection")return(f.features??[]).flatMap(C).filter(Boolean);if(Array.isArray(f))return f.flatMap(D=>D?.type==="FeatureCollection"?P(D):[C(D)]).flat().filter(Boolean);const F=C(f);return F?Array.isArray(F)?F:[F]:[]}function ee(f){if(!f.length)return null;if(!a.value)return at(f[0]?.geometry??null);const g=f.map(G=>at(G?.geometry)).filter(Boolean);return g.every(G=>G?.type==="Point")?{type:"MultiPoint",coordinates:g.map(G=>G.coordinates)}:g.every(G=>G?.type==="LineString")?{type:"MultiLineString",coordinates:g.map(G=>G.coordinates)}:g.every(G=>G?.type==="Polygon")?{type:"MultiPolygon",coordinates:g.map(G=>G.coordinates)}:{type:"GeometryCollection",geometries:g}}function ie(f){if(!f)return"__null__";try{return JSON.stringify(f)}catch{return"__invalid__"}}function Be(f,g){if(!Array.isArray(f)||!Array.isArray(g)||f.length<2||g.length<2)return!1;const C=1e-12;return Math.abs(Number(f[0])-Number(g[0]))<C&&Math.abs(Number(f[1])-Number(g[1]))<C}function De(f,g){if(!Array.isArray(f)||f.length<4)return null;const F=Be(f[0],f[f.length-1])?f.slice(0,-1):f.slice();return!Number.isInteger(g)||g<0||g>=F.length||F.length<=3||(F.splice(g,1),F.length<3)?null:[...F,[...F[0]]]}function je(f,g){if(!Array.isArray(f)||f.length<2||!Number.isInteger(g)||g<0||g>=f.length||f.length<=2)return null;const C=f.slice();return C.splice(g,1),C.length<2?null:C}function Le(f,g){const C=at(f);if(!C||!Array.isArray(g))return null;if(C.type==="LineString"){const[F]=g,D=je(C.coordinates,F);return D?(C.coordinates=D,C):null}if(C.type==="MultiLineString"){const[F,D]=g,G=C.coordinates?.[F],le=je(G,D);return le?(C.coordinates[F]=le,C):null}if(C.type==="Polygon"){const[F,D]=g,G=C.coordinates?.[F],le=De(G,D);return le?(C.coordinates[F]=le,C):null}if(C.type==="MultiPolygon"){const[F,D,G]=g,le=C.coordinates?.[F]?.[D],se=De(le,G);return se?(C.coordinates[F][D]=se,C):null}return null}function st(f){return f?f.split(".").map(g=>Number(g)).filter(g=>Number.isInteger(g)&&g>=0):[]}function ft(f){return!oe||!f?null:typeof oe.get=="function"?oe.get(f)??null:oe.getAll?.()?.features?.find(C=>String(C?.id??"")===f)??null}function it(f){const g=f?.properties?.id??f?.id;return g==null||g===""?null:String(g)}function bt(f){if(!z||!f)return null;const g=[[f.x-8,f.y-8],[f.x+8,f.y+8]],F=z.queryRenderedFeatures(g).find(D=>{const G=String(D?.properties?.meta??"");return G&&G!=="feature"?!1:!!it(D)});return it(F)}function ct(f,g){if(!oe||!f||!g.length)return;const C=ft(f);if(!C?.geometry)return;const F=Le(C.geometry,g);if(!F)return;const D={...C,id:C.id??f,geometry:F};ne=!0,de=!0;try{oe.delete(f),oe.add(D)}finally{de=!1,ne=!1}Dt(),Et()}function dn(f){if(!z||!oe||s.value||h.isRulerActive.value||u.value!=="edit")return;const g=f?.point;if(!g)return;const C=[[g.x-8,g.y-8],[g.x+8,g.y+8]],D=z.queryRenderedFeatures(C).find(le=>le?.properties?.meta==="vertex"&&le?.properties?.parent&&le?.properties?.coord_path);if(!D)return;f?.originalEvent?.preventDefault?.(),f?.originalEvent?.stopPropagation?.();const G=st(String(D.properties.coord_path));G.length&&ct(String(D.properties.parent),G)}function b0(f){const g=Xr(f);if(!g)return null;const[[C,F],[D,G]]=g;return{lat:(F+G)/2,lng:(C+D)/2}}function Wr(f){if(!Array.isArray(f)||f.length<3)return 0;const g=(F,D)=>{const G=F*2003750834e-2/180,le=Math.log(Math.tan((90+D)*Math.PI/360))/(Math.PI/180);return[G,le*2003750834e-2/180]};let C=0;for(let F=0;F<f.length-1;F+=1){const[D,G]=g(Number(f[F][0]),Number(f[F][1])),[le,se]=g(Number(f[F+1][0]),Number(f[F+1][1]));C+=D*se-le*G}return Math.abs(C/2)/1e6}function k0(f){if(!f?.type||!f?.coordinates)return null;if(f.type==="Polygon"){const g=f.coordinates?.[0];return Array.isArray(g)?Wr(g):null}return f.type==="MultiPolygon"?f.coordinates.reduce((g,C)=>{const F=C?.[0];return Array.isArray(F)?g+Wr(F):g},0):null}function _o(f){if(!f){p.value=null;return}const g=b0(f);if(!g){p.value=null;return}p.value={type:String(f.type??"Feature"),center:g,areaKm2:k0(f)}}function Co(f){if(!f){const F=_e[_e.length-1],D=at(F?.geometry??null);ve=D,_o(D);return}const g=_e.find(F=>String(F?.id??"")===String(f))??null,C=at(g?.geometry??null);ve=C,_o(C)}function vo(f){y.value=(f??[]).map((g,C)=>{const F=String(g?.id??`feature-${C+1}`),D=Gr(String(g?.geometry?.type??"Feature"));return{id:F,label:`${D} ${C+1}`}})}function Gr(f){switch(String(f)){case"Point":return"Точка";case"MultiPoint":return"Мультиточка";case"LineString":return"Лінія";case"MultiLineString":return"Мультилінія";case"Polygon":return"Полігон";case"MultiPolygon":return"Мультиполігон";case"GeometryCollection":return"Колекція геометрій";default:return String(f||"Невідомо")}}function Yr(f,g){if(!Array.isArray(f)||!Array.isArray(g)||f.length!==2||g.length!==2)return!1;const C=1e-9;return Math.abs(Number(f[0])-Number(g[0]))<C&&Math.abs(Number(f[1])-Number(g[1]))<C}function Xr(f){if(!f)return null;let g=1/0,C=1/0,F=-1/0,D=-1/0;const G=le=>{if(Array.isArray(le)){if(le.length>=2&&Number.isFinite(le[0])&&Number.isFinite(le[1])){const se=Number(le[0]),Ie=Number(le[1]);g=Math.min(g,se),C=Math.min(C,Ie),F=Math.max(F,se),D=Math.max(D,Ie);return}le.forEach(G)}};return G(f.coordinates),!Number.isFinite(g)||!Number.isFinite(C)?null:[[g,C],[F,D]]}function Zr(f){if(!z||!f)return;const g=Xr(f);if(!g)return;const[[C,F],[D,G]]=g;if(C===D&&F===G){z.easeTo({center:[C,F],zoom:Math.max(K.value,14)});return}z.fitBounds(g,{padding:30,duration:250,maxZoom:18})}function Eo(){if(!oe){d.value=0;return}const f=oe.getAll();d.value=f?.features?.length??0}function un(){if(!oe)return null;const g=oe.getAll?.()?.features??[],C=G=>!!G&&g.some(le=>String(le?.id??"")===String(G??"")),F=oe.getSelectedIds?.();if(Array.isArray(F)&&F.length>0){const G=F[0];return G!=null?String(G):null}if(C(w))return String(w);if(!g.length)return null;const D=a.value?g[g.length-1]:g[0];return D?.id!==void 0&&D?.id!==null?String(D.id):null}function Dt(){if(!oe)return;const f=oe.getAll();if(d.value=f?.features?.length??0,!f?.features?.length){_e=[],y.value=[],ve=null,w=null,p.value=null,de||(j="__null__",r("update:modelValue",null));return}const g=(f.features??[]).map(Ht).filter(Boolean);if(_e=g,vo(g),w=un(),Co(w),!de){const C=ee(g);j=ie(C),r("update:modelValue",C)}}function Un(){if(!oe)return;(oe.getAll()?.features||[]).forEach(g=>oe.delete(g.id)),y.value=[],Eo()}function Hn(f){if(!oe)return;const g=P(f),C=a.value?g:g.slice(0,1);de=!0,Un(),C.forEach(G=>{try{oe.add(G)}catch{}}),de=!1,_e=(oe.getAll?.()?.features??C).map(Ht).filter(Boolean),vo(_e),w=null;const D=at(_e[_e.length-1]?.geometry??null);ve=at(D),Eo(),_o(D),D&&(Zr(D),s.value||Et())}function x0(){oe&&(de=!0,Un(),_e.forEach(f=>{try{oe.add(f)}catch{}}),de=!1,vo(_e),Eo(),Co(w))}function qt(){if(oe){try{oe.changeMode("simple_select",{featureIds:[]})}catch{}u.value=""}}function qn(f){if(s.value||!oe)return;h.isRulerActive.value&&h.closeRuler(),re=!0,qt(),u.value=f;const g=f==="marker"?"draw_point":f==="polyline"?"draw_line_string":f==="rectangle"?"draw_rectangle":"draw_polygon";a.value||(de=!0,Un(),de=!1);try{oe.changeMode(g)}catch{u.value=""}finally{requestAnimationFrame(()=>{re=!1})}}function Et(f){if(s.value||!oe||!oe.getAll()?.features?.length)return;const C=f||un();if(C)try{oe.changeMode("direct_select",{featureId:C}),w=C,Co(w),u.value="edit"}catch{u.value=""}}function w0(f){s.value||!oe||!f||Et(f)}function _0(){if(!(s.value||!oe)){if(a.value){const f=un();if(f)try{A=!0,oe.delete(f),A=!1,Dt();const g=un();g?Et(g):qt();return}catch{A=!1}}qt(),Un(),_e=[],y.value=[],w=null,j="__null__",p.value=null,r("update:modelValue",null)}}function C0(){s.value||!ve||Zr(ve)}function v0(f){if(!z||!te)return;const g=[f[1],f[0]];ge||(ge=new te.Marker({color:"#2563eb"})),ge.setLngLat(g).addTo(z),z.easeTo({center:g,zoom:13,duration:250})}function E0(){s.value||Y.value?.click()}function B0(){s.value||(Q.value=!Q.value)}function Jr(f){if(!Q.value)return;const g=I.value;g&&!g.contains(f.target)&&(Q.value=!1)}function V0(){Q.value=!1,E0()}function S0(){s.value||(he.value=[],Q.value=!1,ke.value=!0)}function $0(){ke.value=!1,he.value=[]}function N0(){if(s.value||!oe)return;const f=wc(J.value.coordinates??"",J.value.format||"decimal",J.value.order||"lat-lon");if(!f.ok){he.value=f.errors,A0(f.errors);return}he.value=[],Hn({type:"Polygon",coordinates:[f.ring]}),Dt(),ke.value=!1,f.wasClosedAutomatically&&pe.notify({type:"info",title:"Імпорт координат",message:"Полігон був автоматично замкнений (перша і остання точки різнилися)."})}function A0(f){if(!f.length)return;const g=5;f.slice(0,g).forEach(C=>{const F=C.line>0?`Рядок ${C.line}`:"Загальна помилка";pe.notify({type:"warning",title:"Імпорт координат",message:`${F} — ${C.message}`})}),f.length>g&&pe.notify({type:"warning",title:"Імпорт координат",message:`Ще помилок: ${f.length-g}`})}function F0(f){if(s.value||!oe)return;Q.value=!1;const g=f.target,C=g.files?.[0];if(!C)return;const F=new FileReader;F.onload=()=>{try{const D=JSON.parse(String(F.result));if(!P(D).length){pe.notify({type:"warning",title:"Імпорт файлу",message:"Файл не містить коректний GeoJSON-обʼєкт."});return}Hn(D),Dt()}catch{pe.notify({type:"error",title:"Імпорт файлу",message:"Не вдалося прочитати файл. Перевірте формат GeoJSON/JSON."})}finally{g.value=""}},F.onerror=()=>{pe.notify({type:"error",title:"Імпорт файлу",message:"Помилка читання файлу."}),g.value=""},F.readAsText(C)}function M0(){if(s.value||!oe)return;const f=oe.getAll(),g=new Blob([JSON.stringify(f,null,2)],{type:"application/json"}),C=URL.createObjectURL(g),F=document.createElement("a");F.href=C,F.download="data.geojson",F.click(),URL.revokeObjectURL(C)}return e.onMounted(async()=>{if(window.addEventListener("click",Jr,!0),!c.value)return;const f=await H();te=f.maplibregl,ce=f.MapboxDraw;const g=We();g&&(z=new te.Map({container:c.value,style:Z(g),center:[E.value[0],E.value[1]],zoom:K.value,attributionControl:!1}),k.value=z,z.addControl(new te.NavigationControl({showCompass:!0}),"bottom-right"),z.on("load",()=>{if(!(!ce||!z)){if(oe=new ce({displayControlsDefault:!1,modes:{...ce.modes,draw_rectangle:Ae()},controls:{point:!1,line_string:!1,polygon:!1,trash:!1},styles:$e}),z.addControl(oe),z.on("click",C=>{if(h.isRulerActive.value){const D=C?.lngLat;if(!D)return;m.value?.addPoint?.({lat:D.lat,lng:D.lng});return}if(!oe||s.value||u.value!=="edit")return;const F=bt(C?.point);!F||F===w||requestAnimationFrame(()=>{!oe||s.value||Et(F)})}),z.on("draw.create",()=>{if(oe&&!h.isRulerActive.value){if(!a.value){const C=oe.getAll();if(C.features.length>1){const F=C.features[C.features.length-1];de=!0,C.features.slice(0,-1).forEach(D=>oe.delete(D.id)),de=!1,F&&(de=!0,oe.add(F),de=!1)}}Dt(),Et()}}),z.on("draw.update",C=>{if(R||h.isRulerActive.value)return;const F=Array.isArray(C?.features)?C.features:[],D=C?.action==="move"&&F.length>0&&F.every(G=>G?.geometry?.type==="Point");if(C?.action==="move"){if(D){Dt();return}if(R=!0,x0(),R=!1,u.value==="edit"){const G=un(),le=G?ft(G):oe?.getAll?.()?.features?.[0];if(le?.id)try{oe.changeMode("direct_select",{featureId:le.id}),w=String(le.id)}catch{u.value=""}}return}Dt()}),z.on("draw.delete",()=>{ne||A||h.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle"||(Dt(),oe?.getAll?.()?.features?.length||(w=null),u.value="",qt())}),z.on("draw.selectionchange",C=>{if(!oe||R||h.isRulerActive.value||u.value==="marker"||u.value==="polyline"||u.value==="polygon"||u.value==="rectangle")return;const F=C?.features?.[0]?.id!==void 0&&C?.features?.[0]?.id!==null?String(C.features[0].id):null;if(!s.value&&F){if(u.value==="edit"&&w===F)return;requestAnimationFrame(()=>{!oe||s.value||Et(F)});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||Et(G)});return}try{oe.changeMode("simple_select",{featureIds:[]})}catch{}}),T.value!==void 0){const C=T.value;T.value=void 0,requestAnimationFrame(()=>{oe&&Hn(C)})}Pt(),fe.value.forEach(C=>{const F=ae[C];F&&Mt(F)}),vt()}}),z.on("contextmenu",dn),z.on("zoomend",()=>{z&&(K.value=z.getZoom())}))}),e.onUnmounted(()=>{h.isRulerActive.value&&h.closeRuler(),window.removeEventListener("click",Jr,!0),Object.values(ae).forEach(f=>{z&&Ft(f)}),Fe(),ge?.remove&&ge.remove(),ge=null,z?.remove&&z.remove(),z=null,oe=null,k.value=null}),e.watch(()=>n.modelValue,f=>{if(!oe){T.value=f;return}const g=ee((a.value?P(f):P(f).slice(0,1))||[]),C=ie(g);if(j&&C===j){j=null;return}j=null,Hn(f)},{deep:!0}),e.watch(()=>M.value,f=>{const g=Array.isArray(f)?f:[],C=[],F=new Set;g.forEach((D,G)=>{if(!D)return;const le=rt(D,G);C.push(le),F.add(le);const se={...D,id:le},Ie=ae[le],tt=Ie?.visible??!!se.visible;Ie&&z&&Ft(Ie),ae[le]={id:le,config:se,visible:tt,sourceId:`vs-ov-src-${le}`,layerIds:[],boundsIds:[],handlers:[]}}),Object.keys(ae).forEach(D=>{if(F.has(D))return;const G=ae[D];G&&z&&Ft(G),delete ae[D]}),fe.value=C,z&&(fe.value.forEach(D=>{const G=ae[D];G&&Mt(G)}),vt())},{immediate:!0,deep:!0}),e.watch(()=>O.value,()=>{z&&(Pt(),fe.value.forEach(f=>{const g=ae[f];g&&Mt(g)}),vt())},{deep:!0}),e.watch(()=>V.value,async f=>{if(X.value=[],!f){z&&(Pt(),fe.value.forEach(g=>{const C=ae[g];C&&Mt(C)}),vt());return}try{const g=await fetch(`https://data.gki.com.ua/api-user/atu/${f}`);if(!g?.ok)return;const F=(await g.json())?.geometry?.coordinates;Array.isArray(F)&&F.length&&(X.value=F)}catch(g){console.error("Failed to fetch KATOTTG bounds",g)}finally{if(!z)return;Pt(),fe.value.forEach(g=>{const C=ae[g];C&&Mt(C)}),vt()}},{immediate:!0}),e.watch(()=>S.value,f=>{if(!Array.isArray(f)||f.length!==2)return;const g=[Number(f[0]),Number(f[1])];if(Yr(E.value,g)||(E.value=[...g],!z))return;const C=z.getCenter?.();C&&Yr([C.lng,C.lat],E.value)||z.easeTo({center:[E.value[0],E.value[1]]})},{deep:!0}),e.watch(()=>$.value,f=>{typeof f=="number"&&(K.value=f,z&&z.setZoom(f))}),e.watch(s,f=>{f&&qt()}),e.watch(d,f=>{if(f>0){s.value||Et();return}re||qt()}),e.watch(i,()=>{setTimeout(()=>{z?.resize&&z.resize()},50)}),(f,g)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body",disabled:!i.value},[e.createElementVNode("div",{class:e.normalizeClass(["vs-map-wrapper relative w-full h-[400px]",{fullscreen:i.value}])},[e.createElementVNode("div",{ref_key:"mapContainer",ref:c,class:"w-full h-[calc(100%-28px)]"},null,512),Ce.value.search||Ce.value.import||Ce.value.export?(e.openBlock(),e.createElementBlock("div",Id,[Ce.value.search?(e.openBlock(),e.createBlock(zc,{key:0,onGoToCoordinates:v0})):e.createCommentVNode("",!0),Ce.value.import||Ce.value.export?(e.openBlock(),e.createElementBlock("div",Rd,[e.createElementVNode("div",Od,[Ce.value.import?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"importMenuRef",ref:I,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:B0,disabled:s.value},[g[8]||(g[8]=e.createTextVNode(" Імпорт ",-1)),e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition-transform",{"rotate-180":Q.value}])},null,8,["class"])],8,Pd),Q.value?(e.openBlock(),e.createElementBlock("div",zd,[Ce.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:V0}," З файлу ")):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:S0}," З координат ")])):e.createCommentVNode("",!0)],512)):e.createCommentVNode("",!0),Ce.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:M0,disabled:s.value||d.value===0}," Експорт ",8,jd)):e.createCommentVNode("",!0)]),e.createElementVNode("input",{ref_key:"importRef",ref:Y,type:"file",onChange:F0,accept:".json,.geojson",class:"hidden",disabled:s.value},null,40,Ud)])):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),e.createVNode(e.unref(pe.VsModal),{visible:ke.value,"onUpdate:visible":g[1]||(g[1]=C=>ke.value=C),title:"Імпорт координат полігону",size:"lg",teleport:"#modal"},{default:e.withCtx(()=>[e.createVNode(ot,{schema:me,values:J.value,"onUpdate:values":g[0]||(g[0]=C=>J.value=C)},null,8,["values"]),e.createElementVNode("div",Hd,[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:$0}," Скасувати "),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:N0,disabled:s.value}," Побудувати ",8,qd)])]),_:1},8,["visible"]),e.createElementVNode("div",Kd,[e.createElementVNode("div",Wd,[Ce.value.point?(e.openBlock(),e.createElementBlock("button",{key:0,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="marker"}]),title:"Point",onClick:g[2]||(g[2]=C=>qn("marker")),disabled:s.value},[e.createVNode(e.unref(q.MapPin),{class:"h-4 w-4"})],10,Gd)):e.createCommentVNode("",!0),Ce.value.line?(e.openBlock(),e.createElementBlock("button",{key:1,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polyline"}]),title:"Line",onClick:g[3]||(g[3]=C=>qn("polyline")),disabled:s.value},[e.createVNode(ac)],10,Yd)):e.createCommentVNode("",!0),Ce.value.polygon?(e.openBlock(),e.createElementBlock("button",{key:2,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="polygon"}]),title:"Polygon",onClick:g[4]||(g[4]=C=>qn("polygon")),disabled:s.value},[e.createVNode(dc)],10,Xd)):e.createCommentVNode("",!0),Ce.value.rectangle?(e.openBlock(),e.createElementBlock("button",{key:3,class:e.normalizeClass(["vs-btn",{"vs-active":u.value==="rectangle"}]),title:"Rectangle",onClick:g[5]||(g[5]=C=>qn("rectangle")),disabled:s.value},[e.createVNode(mc)],10,Zd)):e.createCommentVNode("",!0),Ce.value.ruler?(e.openBlock(),e.createElementBlock("button",{key:4,class:e.normalizeClass(["vs-btn mt-3",{"vs-active":e.unref(h).isRulerActive.value}]),title:"Ruler",onClick:b},[e.createVNode(e.unref(q.Ruler),{class:"h-4 w-4"})],2)):e.createCommentVNode("",!0),e.createElementVNode("button",{class:"vs-btn mt-5",onClick:g[6]||(g[6]=C=>i.value=!i.value),title:"Full Screen"},[e.createVNode(e.unref(q.Maximize),{class:"h-4 w-4"})])])]),Ce.value.ruler&&e.unref(h).isRulerActive.value?(e.openBlock(),e.createBlock(Dd,{key:1,ref_key:"rulerPanelRefEl",ref:m,onClose:g[7]||(g[7]=C=>e.unref(h).closeRuler()),onTabChange:e.unref(h).onRulerTabChange,onPointsChange:e.unref(h).onRulerPointsChange,onShapeClosedChange:e.unref(h).onRulerShapeClosedChange},null,8,["onTabChange","onPointsChange","onShapeClosedChange"])):e.createCommentVNode("",!0),Ce.value.ruler&&e.unref(h).isRulerActive.value&&e.unref(h).hasRulerPoints.value?(e.openBlock(),e.createBlock(Td,{key:2,map:k.value,points:e.unref(h).rulerPoints.value,"is-shape-closed":e.unref(h).rulerShapeClosed.value,"label-mode":e.unref(h).rulerActiveTab.value},null,8,["map","points","is-shape-closed","label-mode"])):e.createCommentVNode("",!0),Oe.value.length?(e.openBlock(),e.createElementBlock("div",{key:3,class:"absolute z-[1500] pointer-events-none",style:e.normalizeStyle(Te.value)},[e.createElementVNode("div",Jd,[e.createElementVNode("dl",Qd,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Oe.value,C=>(e.openBlock(),e.createElementBlock("div",{key:`${C.key}-${C.value}`,class:"flex justify-between gap-2"},[e.createElementVNode("dt",eu,e.toDisplayString(C.key),1),e.createElementVNode("dd",tu,e.toDisplayString(C.value),1)]))),128))])])],4)):e.createCommentVNode("",!0),e.createElementVNode("div",nu,[e.createElementVNode("div",ou,[e.createVNode(kc,{basemaps:e.unref(Me),onOnLayerChange:jn},null,8,["basemaps"]),Se.value.length?(e.openBlock(),e.createElementBlock("div",ru,[g[9]||(g[9]=e.createElementVNode("p",{class:"font-semibold text-[11px] uppercase tracking-wide text-gray-500 mb-2"},"Шари",-1)),e.createElementVNode("div",lu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Se.value,C=>(e.openBlock(),e.createElementBlock("label",{key:C.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:C.visible,disabled:s.value,onChange:F=>wo(C.id)},null,40,au),e.createElementVNode("span",su,e.toDisplayString(C.config.title||C.config.name||C.id),1)]))),128))])])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",iu,[y.value.length||p.value?(e.openBlock(),e.createElementBlock("div",cu,[e.createElementVNode("div",du,[e.createElementVNode("div",uu,[g[10]||(g[10]=e.createTextVNode(" Тип: ",-1)),y.value.length<=1?(e.openBlock(),e.createElementBlock("span",pu,e.toDisplayString(p.value?Gr(p.value.type):y.value[0]?.label||"—"),1)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(y.value,(C,F)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:C.id},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["font-bold underline-offset-2",C.id===e.unref(w)?"text-blue-700 underline":"text-gray-700 hover:text-blue-700 hover:underline"]),onClick:D=>w0(C.id),disabled:s.value},e.toDisplayString(C.label),11,fu),F<y.value.length-1?(e.openBlock(),e.createElementBlock("span",mu,", ")):e.createCommentVNode("",!0)],64))),128))])]),e.createElementVNode("div",hu,[e.createElementVNode("div",gu,[g[11]||(g[11]=e.createTextVNode(" Центр: ",-1)),p.value?(e.openBlock(),e.createElementBlock("b",yu,e.toDisplayString(p.value.center.lng.toFixed(5))+", "+e.toDisplayString(p.value.center.lat.toFixed(5)),1)):(e.openBlock(),e.createElementBlock("b",bu,"—"))]),p.value&&p.value.areaKm2!==null?(e.openBlock(),e.createElementBlock("div",ku,[g[12]||(g[12]=e.createTextVNode(" Площа: ",-1)),e.createElementVNode("b",null,e.toDisplayString(p.value.areaKm2.toFixed(1))+" km²",1)])):(e.openBlock(),e.createElementBlock("div",xu,g[13]||(g[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:C0,disabled:s.value},[e.createVNode(e.unref(q.ZoomIn),{class:"h-3 w-3"})],8,wu),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:_0,disabled:s.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,_u)])])):e.createCommentVNode("",!0)])],2)],8,["disabled"]))}}),[["__scopeId","data-v-ae813935"]]),Cu=["data-focus"],vu={class:"flex items-center"},Eu={class:"overflow-hidden text-ellipsis whitespace-nowrap rounded-sm text-[#333] text-[85%] px-0.5 py-[3px] pl-1.5 box-border"},Bu=["onClick","aria-label"],Vu={key:0,class:"absolute text-gray-500 truncate pl-2"},Su={class:"flex-1 min-w-[2px]"},$u=["placeholder"],Nu={class:"flex items-center shrink-0"},Au=["disabled"],Yo=e.defineComponent({__name:"vs-input-tag",props:e.mergeModels({unique:{type:Boolean,default:!0},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:"Введіть тег"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t;Ue(n.style);const l=e.ref(null),a=e.ref(null),s=e.ref(null),i=e.ref(!1),c=e.ref(""),d=e.useModel(o,"modelValue"),u=e.computed(()=>n.placeholder||"Add tag…"),p=e.computed(()=>d.value?.length===0&&c.value===""),y=e.computed(()=>!n.disabled&&d.value?.length>0),k=e.computed(()=>n.disabled),m=async()=>{k.value||await e.nextTick(()=>s.value?.focus())},h=W=>{const L=W.trim();L!==""&&(!d.value||!Array.isArray(d.value)?d.value=[L]:n.unique?d.value.includes(L)||(d.value=[...d.value,L]):d.value=[...d.value,L],c.value="")},b=()=>{const W=c.value;W.trim()!==""&&h(W),c.value=""},_=W=>{const L=d.value.slice();L.splice(W,1),r("update:modelValue",L)},x=()=>{r("update:modelValue",[])},v=()=>{k.value||(i.value=!0)},N=()=>{i.value=!1,!k.value&&b()},U=W=>{const{key:L}=W;L==="Enter"?(W.preventDefault(),b()):L==="Backspace"&&c.value===""&&d.value.length>0&&_(d.value.length-1)};return(W,L)=>(e.openBlock(),e.createElementBlock("div",{class:"flex gap-1 w-full",ref_key:"root",ref:l,onClick:L[1]||(L[1]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{class:e.normalizeClass(["relative w-full font-sans",n.customClass]),role:"group","aria-label":"Tag input"},[e.createElementVNode("div",{class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white","border-gray-300 hover:border-gray-400",i.value?"border-blue-500 ring-1 ring-blue-500":"",k.value?"bg-gray-100 text-gray-400 cursor-not-allowed hover:border-gray-300":""]),"data-focus":i.value?"true":"false",onClick:m},[e.createElementVNode("div",{class:"flex flex-1 flex-wrap items-center gap-1 py-0.5 pl-2 pr-0 overflow-hidden",ref_key:"chipsRef",ref:a},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(B,S)=>(e.openBlock(),e.createElementBlock("div",{key:S,class:"flex min-w-0 bg-[#e6e6e6] rounded-sm m-0.5 box-border"},[e.createElementVNode("div",vu,[e.createElementVNode("div",Eu,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($=>_(S),["stop"]),"aria-label":`Remove ${B}`},[e.createVNode(e.unref(q.X),{"aria-hidden":"true",focusable:"false",class:"inline-block h-4 w-4"})],8,Bu)]))),128)),p.value?(e.openBlock(),e.createElementBlock("div",Vu,e.toDisplayString(u.value),1)):e.createCommentVNode("",!0),e.createElementVNode("div",Su,[k.value?e.createCommentVNode("",!0):e.withDirectives((e.openBlock(),e.createElementBlock("input",{key:0,ref_key:"inputRef",ref:s,class:"pl-2 w-full bg-transparent outline-none border-0 m-0 p-0 text-gray-900",autocapitalize:"none",autocomplete:"off",autocorrect:"off",spellcheck:"false",type:"text",tabindex:"0","aria-label":"Add tag","onUpdate:modelValue":L[0]||(L[0]=B=>c.value=B),onFocus:v,onBlur:N,onKeydown:U,placeholder:d.value&&d.value.length?"":void 0},null,40,$u)),[[e.vModelText,c.value]])])],512),e.createElementVNode("div",Nu,[y.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:k.value,onClick:e.withModifiers(x,["stop"])},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,Au)):e.createCommentVNode("",!0)])],10,Cu)],2)],512))}}),Fu={class:"relative flex gap-1 bg-white w-full"},Mu=["disabled","placeholder"],Xo=xe(e.defineComponent({__name:"vs-input-slug",props:e.mergeModels({disabled:{type:Boolean},placeholder:{},parent:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=e.inject("values"),n=o,r=e.useModel(o,"modelValue");function l(s){const i={а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"e",ж:"zh",з:"z",и:"i",й:"y",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"kh",ц:"ts",ч:"ch",ш:"sh",щ:"shch",ы:"y",э:"e",ю:"yu",я:"ya",ь:"",ъ:"",є:"ye",і:"i",ї:"yi",ґ:"g"};return s.toLowerCase().split("").map(c=>i[c]||c).join("").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").replace(/^-+|-+$/g,"")}const a=()=>{const s=t?.value?.[n.parent||""]?.toString(),i=l(s);r.value=i.toString()};return(s,i)=>(e.openBlock(),e.createElementBlock("div",Fu,[e.withDirectives(e.createElementVNode("input",{ref:"vsText",disabled:s.disabled,placeholder:s.placeholder,"onUpdate:modelValue":i[0]||(i[0]=c=>r.value=c),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Mu),[[e.vModelText,r.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200",onClick:a}," Gen ")]))}}),[["__scopeId","data-v-b0eba370"]]),Du={class:"relative flex gap-1 bg-white w-full"},Tu=["disabled","placeholder"],Lu=["disabled"],Iu={key:0},Ru={key:1},Zo=xe(e.defineComponent({__name:"vs-input-codegen",props:e.mergeModels({table:{},code:{},init:{type:Boolean},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(!1),l=e.computed(()=>t.init!==!1),a=e.computed(()=>!!t.table&&!!t.code),s=()=>{if(!a.value)return"";const d=encodeURIComponent(String(t.table)),u=encodeURIComponent(String(t.code));return`/api/code-gen/${d}/${u}`},i=async()=>{if(!a.value||r.value)return;const d=s();if(d){r.value=!0;try{const p=await(await fetch(d)).text();n.value=p}finally{r.value=!1}}},c=()=>{l.value&&(n.value||i())};return e.onMounted(()=>{c()}),e.watch(()=>[t.table,t.code,t.init],()=>{c()}),(d,u)=>(e.openBlock(),e.createElementBlock("div",Du,[e.withDirectives(e.createElementVNode("input",{disabled:d.disabled,placeholder:d.placeholder,"onUpdate:modelValue":u[0]||(u[0]=p=>n.value=p),class:"block w-full px-3 py-2 text-sm border border-solid rounded-lg placeholder:text-nowrap border-stone-200 text-stone-800 placeholder:text-stone-400 focus:outline focus:z-10 focus:border-blue-500 focus:ring-blue-500 focus:outline-blue-500"},null,8,Tu),[[e.vModelText,n.value]]),e.createElementVNode("button",{class:"px-2 bg-gray-100 border rounded-lg hover:bg-gray-200 disabled:opacity-50 disabled:cursor-not-allowed",disabled:r.value||d.disabled||!a.value,onClick:i},[r.value?(e.openBlock(),e.createElementBlock("span",Ru,"...")):(e.openBlock(),e.createElementBlock("span",Iu,"Gen"))],8,Lu)]))}}),[["__scopeId","data-v-6ee5237d"]]),Ou={class:"w-full"},Pu={ref:"sortableContainer",class:"flex flex-col gap-1"},zu=["onDragstart","onDrop"],ju={class:"cursor-move",type:"button"},Uu={class:"w-1/3"},Hu={class:"w-2/3"},qu=["onClick"],Ku={key:0,class:"text-[14px] text-gray-700"},Wu={class:"mt-2 w-full flex items-center"},Gu=["disabled"],Jo=xe(e.defineComponent({__name:"vs-input-key-value",props:{parent:{},ignore:{},addButtonText:{},modelValue:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=b=>`${b}-${Math.random().toString(36).substring(2,15)}`,r=e.inject("values"),l=o,a=t,s=l.addButtonText??"Додати",i=l.ignore??[],c=e.ref([]),d=e.ref(null);(()=>{const b=l.parent&&r?.value?.[l.parent]||l.modelValue||{};c.value=Object.entries(b).filter(([_])=>!i.includes(_)).map(([_,x])=>({id:n("key-value-"),key:_,value:x}))})();function p(b){d.value=b}function y(b){if(d.value===null||d.value===b)return;const _=c.value.splice(d.value,1)[0];c.value.splice(b,0,_),d.value=null}const k=e.computed(()=>c.value.some(b=>b.key&&!b.value||!b.key&&b.value)),m=()=>{c.value.push({id:n("key-value-"),key:"",value:""})},h=b=>{c.value=c.value.filter(_=>_.id!==b)};return e.watch(c,b=>{const _={};b.forEach(v=>{v.key&&v.value!==void 0&&(_[v.key]=v.value)});const x={};i.length&&i.forEach(v=>{x[v]=l.parent?r?.value?.[l.parent]?.[v]:void 0}),r?.value&&l.parent&&(r.value[l.parent]={...x,..._}),a("update:modelValue",_)},{deep:!0}),(b,_)=>(e.openBlock(),e.createElementBlock("div",Ou,[e.createElementVNode("div",Pu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(c.value,(x,v)=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":d.value===v}]),draggable:"true",onDragstart:N=>p(v),onDragover:_[0]||(_[0]=e.withModifiers(()=>{},["prevent"])),onDrop:N=>y(v)},[e.createElementVNode("button",ju,[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})]),e.createElementVNode("div",Uu,[e.createVNode(zt,{modelValue:x.key,"onUpdate:modelValue":N=>x.key=N,placeholder:"Ключ"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("div",Hu,[e.createVNode(zt,{modelValue:x.value,"onUpdate:modelValue":N=>x.value=N,placeholder:"Значення"},null,8,["modelValue","onUpdate:modelValue"])]),e.createElementVNode("button",{onClick:N=>h(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,qu)],42,zu))),128))],512),c.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",Ku," Дані для відображення відсутні ")),e.createElementVNode("div",Wu,[e.createElementVNode("button",{type:"button",onClick:m,disabled:k.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,Gu)])]))}}),[["__scopeId","data-v-d8c3f9d6"]]),Yu={class:"w-full"},Xu={ref:"sortableContainer",class:"flex flex-col gap-1"},Zu=["onDragstart","onDrop"],Ju=["disabled"],Qu={class:"flex-1"},ep=["onClick","disabled"],tp={key:0,class:"text-[14px] text-gray-700"},np={class:"mt-2 w-full flex items-center"},op=["disabled"],Qo=xe(e.defineComponent({__name:"vs-input-text-array",props:e.mergeModels({addButtonText:{default:"Додати"},inputType:{default:"text"},placeholder:{default:"Значення"},mask:{default:""},disabled:{type:Boolean,default:!1}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref(null),a=e.computed(()=>!!t.disabled),s=e.computed(()=>t.placeholder??""),i=e.computed(()=>t.addButtonText??"Додати");let c=!1;const d=b=>`${b}-${Math.random().toString(36).substring(2,15)}`,u=b=>{const _=b??n.value??[];r.value=_.map((x,v)=>({id:r.value[v]?.id??d("text-array"),value:x??""}))};u(),e.watch(()=>n.value,b=>{if(c){c=!1;return}u(b||[])},{deep:!0}),e.watch(r,b=>{c=!0,n.value=b.map(_=>_.value).filter(_=>_!=null&&_!=="")},{deep:!0});const p=e.computed(()=>a.value||r.value.some(b=>!b.value));function y(){p.value||(r.value=[...r.value,{id:d("text-array"),value:""}])}function k(b){a.value||(r.value=r.value.filter(_=>_.id!==b))}function m(b){a.value||(l.value=b)}function h(b){if(a.value||l.value===null||l.value===b)return;const _=[...r.value],[x]=_.splice(l.value,1);_.splice(b,0,x),r.value=_,l.value=null}return(b,_)=>(e.openBlock(),e.createElementBlock("div",Yu,[e.createElementVNode("div",Xu,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(x,v)=>(e.openBlock(),e.createElementBlock("div",{key:x.id,class:e.normalizeClass(["flex items-center gap-2 w-full",{"opacity-50":l.value===v}]),draggable:"true",onDragstart:N=>m(v),onDragover:_[0]||(_[0]=e.withModifiers(()=>{},["prevent"])),onDrop:N=>h(v)},[e.createElementVNode("button",{class:"cursor-move",type:"button",disabled:a.value},[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})],8,Ju),e.createElementVNode("div",Qu,[b.inputType==="text"?(e.openBlock(),e.createBlock(zt,{key:0,modelValue:x.value,"onUpdate:modelValue":N=>x.value=N,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),b.inputType==="tel"?(e.openBlock(),e.createBlock(Xn,{key:1,modelValue:x.value,"onUpdate:modelValue":N=>x.value=N,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),b.inputType==="email"?(e.openBlock(),e.createBlock(Yn,{key:2,modelValue:x.value,"onUpdate:modelValue":N=>x.value=N,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","disabled","placeholder"])):e.createCommentVNode("",!0),b.inputType==="mask"?(e.openBlock(),e.createBlock(mn,{key:3,modelValue:x.value,"onUpdate:modelValue":N=>x.value=N,mask:b.mask,disabled:a.value,placeholder:s.value},null,8,["modelValue","onUpdate:modelValue","mask","disabled","placeholder"])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:N=>k(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,ep)],42,Zu))),128))],512),r.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("span",tp," Дані для відображення відсутні ")),e.createElementVNode("div",np,[e.createElementVNode("button",{type:"button",onClick:y,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(i.value),1)],8,op)])]))}}),[["__scopeId","data-v-2c229b1f"]]),rp={class:"flex items-center gap-2 w-full"},lp=["disabled"],ap=["disabled"],er=e.defineComponent({__name:"vs-input-color",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=Ue(n.style),l=t,a=e.computed({get:()=>n.modelValue||"#000000",set:i=>l("update:modelValue",i)}),s=e.computed(()=>!!n.disabled);return(i,c)=>(e.openBlock(),e.createElementBlock("div",rp,[e.withDirectives(e.createElementVNode("input",{type:"color","onUpdate:modelValue":c[0]||(c[0]=d=>a.value=d),disabled:s.value,ref:"color",class:e.normalizeClass(["py-1.5 px-1 block w-full bg-white cursor-pointer max-w-[50px]",[i.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")]),style:{border:"1px solid #CFD9E0"}},null,10,lp),[[e.vModelText,a.value]]),e.withDirectives(e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2","onUpdate:modelValue":c[1]||(c[1]=d=>a.value=d),disabled:s.value},null,8,ap),[[e.vModelText,a.value]])]))}}),sp={class:"flex items-center gap-2 w-full"},ip=["min","max","step","disabled"],cp=["value","min","max","step","disabled"],tr=e.defineComponent({__name:"vs-input-range",props:{style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{},name:{},placeholder:{default:""},maxlength:{},minlength:{},min:{default:0},max:{default:100},step:{default:1}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,{inputClass:r}=Ue(n.style),l=t,a=u=>{const p=Number(u),y=Number(n.min),k=Number(n.max);return Number.isNaN(p)?y:Math.min(k,Math.max(y,p))},s=e.computed({get:()=>a(n.modelValue??n.min),set:u=>l("update:modelValue",a(u))}),i=u=>{const p=u.target,y=a(p.value);p.value=String(y),l("update:modelValue",y)},c=u=>{Number(n.min)>=0&&u.key==="-"&&u.preventDefault()},d=e.computed(()=>!!n.disabled);return(u,p)=>(e.openBlock(),e.createElementBlock("div",sp,[e.withDirectives(e.createElementVNode("input",{type:"range","onUpdate:modelValue":p[0]||(p[0]=y=>s.value=y),min:u.min,max:u.max,step:u.step,disabled:d.value,ref:"range",class:e.normalizeClass(["w-full cursor-pointer accent-blue-500",[u.modelValue?"":"text-opacity-50",e.unref(r)].join(" ")])},null,10,ip),[[e.vModelText,s.value]]),e.createElementVNode("input",{class:"text-sm text-gray-600 border border-solid border-stone-200 rounded-md p-2 max-w-[100px]",type:"number",value:s.value,min:u.min,max:u.max,step:u.step,onInput:i,onKeydown:c,disabled:d.value},null,40,cp)]))}}),dp=["placeholder","disabled","name"],up=["type","value","onInput","placeholder","disabled"],pp=["onClick"],nr=e.defineComponent({__name:"vs-input-array",props:e.mergeModels({count:{default:1},limit:{default:1},mask:{default:""},unmask:{type:Boolean,default:!1},inputType:{default:"text"},isAdded:{type:Boolean,default:!1},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.ref(t.count),r=e.computed(()=>t.limit),{inputClass:l}=Ue(t.style),a=e.useModel(o,"modelValue"),s=e.computed(()=>!!t.disabled),i=e.computed(()=>t.placeholder??"");e.watchEffect(()=>{const h=a.value?.length??0;h<n.value&&(a.value=[...a.value??[],...Array(n.value-h)])});const c=e.ref({}),d=e.ref({});function u(h,b){h&&(c.value[b]=h)}async function p(h,b){if(!h||t.inputType!=="mask")return;const{default:_}=await Promise.resolve().then(()=>Pn);d.value[b]&&d.value[b].destroy(),d.value[b]=_(h,{mask:t.mask||"",definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/},lazy:!1}),d.value[b].on("accept",()=>{const x=[...a.value||[]];x[b]=t.unmask?d.value[b].unmaskedValue:d.value[b].value,a.value=x}),d.value[b].on("complete",()=>{const x=[...a.value||[]];x[b]=t.unmask?d.value[b].unmaskedValue:d.value[b].value,a.value=x}),a.value?.[b]&&(d.value[b].value=a.value[b])}function y(h,b){if(s.value)return;const _=h.target.value??null,x=[...a.value];x[b]=t.inputType==="text"?_:Number(_),a.value=x}function k(){n.value+=1;const h=t.inputType==="text"||t.inputType==="mask"?null:0;a.value=[...a.value,h],t.inputType==="mask"&&setTimeout(()=>{const b=n.value-1;c.value[b]&&p(c.value[b],b)},0)}function m(h){if(n.value>1){d.value[h]&&(d.value[h].destroy(),delete d.value[h]),n.value-=1,a.value=a.value.filter((_,x)=>x!==h);const b={};Object.keys(d.value).forEach(_=>{const x=parseInt(_,10);x>h?b[x-1]=d.value[x]:x<h&&(b[x]=d.value[x])}),d.value=b}}return e.onMounted(()=>{if(t.inputType==="mask")for(let h=0;h<n.value;h+=1)c.value[h]&&p(c.value[h],h)}),e.onBeforeUnmount(()=>{Object.values(d.value).forEach(h=>{h&&h.destroy()})}),e.watch(()=>t.mask,h=>{t.inputType==="mask"&&Object.values(d.value).forEach(b=>{b&&b.updateOptions({mask:h,definitions:{9:/[0-9]/,A:/[a-zA-Z]/,"*":/[a-zA-Z0-9]/}})})}),e.watch(a,h=>{t.inputType==="mask"&&h&&h.forEach((b,_)=>{d.value[_]&&d.value[_].value!==b&&(d.value[_].value=b||"")})},{deep:!0}),(h,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["grid gap-2",`grid-cols-${r.value}`])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,_=>(e.openBlock(),e.createElementBlock("div",{key:_,class:"flex items-center gap-2 w-full"},[h.inputType==="mask"?(e.openBlock(),e.createElementBlock("input",{key:0,type:"text",ref_for:!0,ref:x=>u(x,_-1),placeholder:h.placeholder,disabled:h.disabled,name:`${h.name}[${_-1}]`,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,10,dp)):(e.openBlock(),e.createElementBlock("input",{key:1,type:h.inputType,value:a.value?.[_-1],onInput:x=>y(x,_-1),placeholder:i.value,disabled:s.value,class:e.normalizeClass(["py-1.5 px-3 block w-full placeholder:text[#767f8f] bg-white",[e.unref(l),{"!border-red-600":h.error}]]),style:{border:"1px solid #CFD9E0"}},null,42,up)),!h.disabled&&_===n.value&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:2,type:"button",onClick:e.withModifiers(k,["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),!h.disabled&&n.value>1&&h.isAdded?(e.openBlock(),e.createElementBlock("button",{key:3,type:"button",onClick:e.withModifiers(x=>m(_-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,pp)):e.createCommentVNode("",!0)]))),128))],2))}}),fp={class:"flex gap-1 w-full"},mp=["aria-expanded","data-focus"],hp=["placeholder","disabled","readonly"],gp={class:"max-h-full"},yp=["onClick","disabled"],bp={key:0,class:"px-3 py-2 text-sm text-stone-500"},kp=["disabled"],xp={class:"flex flex-col gap-1"},wp=["onDragstart","onDrop"],_p=["disabled"],Cp=["title"],vp=["disabled","onClick","aria-label"],Ep={key:0,class:"text-xs text-stone-500"},Bn=xe(e.defineComponent({__name:"vs-input-array-select",props:e.mergeModels({options:{default:()=>[]},data:{default:""},api:{default:""},prefix:{default:"api"},host:{default:""},parent:{},search:{type:Boolean,default:!0},maxHeight:{default:280},start:{default:0},slot:{},disabled:{type:Boolean,default:!1},add:{},style:{},customClass:{},modelValue:{},error:{},name:{},placeholder:{default:"Оберіть значення"},maxlength:{},minlength:{}},{modelValue:{default:[]},modelModifiers:{}}),emits:e.mergeModels(["change","update:modelValue","value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=t,l=e.useModel(o,"modelValue"),a=e.ref([]),s=e.ref(n.options??[]),i=e.ref({}),c=e.ref({}),d=e.ref({keyword:"",parent:null}),u=e.ref(""),p=e.ref(!1),y=e.ref(null),k=e.ref(null),m=e.ref(null),h=e.ref(null),b=e.ref(null),_=e.ref({});let x=!1,v=!1;const N=e.inject("values"),U=e.computed(()=>!!n.disabled),W=e.computed(()=>n.placeholder??"Оберіть значення"),L=e.computed(()=>n.search!==!1),B=e.computed(()=>{const w=n.parent??n.parentValue;return w?String(w):""}),S=e.computed(()=>B.value?N?.value?.[B.value]??null:null),$=w=>w==null?"__null__":String(w),V=w=>{if(!w)return"";const A=w.label??w.text??w.name??w.ua??w.en;return A?String(A):w.id!==void 0&&w.id!==null?String(w.id):""},M=w=>{const A=$(w);return c.value[A]||(c.value[A]=`array-select-${A}-${Math.random().toString(36).slice(2,8)}`),c.value[A]},O=e.computed(()=>new Set(a.value.map(w=>$(w.id)))),E=e.computed(()=>{const w=O.value;let A=[...s.value];if(!n.data&&u.value.trim()){const R=u.value.toLowerCase();A=A.filter(re=>V(re).toLowerCase().includes(R))}return A.filter(R=>!w.has($(R.id)))}),K=()=>{if(!n.data)return"";const w=n.prefix??"api",A=n.api??`/${w}/suggest/${n.data}`;return`${n.host??""}${A}`},T=()=>{a.value.length&&(x=!0,a.value=a.value.map(w=>({...w,text:i.value[$(w.id)]??w.text})))},Y=w=>{const A=$(w.id),R=V(w);R&&(i.value[A]=R)},I=w=>{s.value=w?[...w]:[],w?.forEach(Y),T()},X=w=>{if(!w.length)return;const A=new Map(s.value.map(R=>[$(R.id),R]));w.forEach(R=>{const re=$(R.id);A.set(re,R),Y(R)}),s.value=Array.from(A.values()),T()},Q=async(w="")=>{if(!n.data)return[];const A=K();if(!A)return[];const R=new URLSearchParams;R.set("json","1"),w&&R.set("key",w),n.start===1&&R.set("start","1"),S.value!==null&&S.value!==void 0&&S.value!==""&&R.set("parent",String(S.value));try{return(await(await fetch(`${A}?${R.toString()}`)).json())?.data??[]}catch{return[]}},ke=async w=>{if(!n.data||!w.length)return[];const A=K();if(!A)return[];const R=Array.from(new Set(w.map(ge=>$(ge)))),re=new URLSearchParams;re.set("json","1"),re.set("val",R.join(",")),n.start===1&&re.set("start","1"),S.value!==null&&S.value!==void 0&&S.value!==""&&re.set("parent",String(S.value));try{const $e=(await(await fetch(`${A}?${re.toString()}`)).json())?.data??[];return X($e),$e}catch{return[]}},he=async w=>{if(w==null||w==="")return null;const A=$(w),R=s.value.find(ge=>$(ge.id)===A);if(R)return R;const[re]=await ke([w]);return re??null},J=async(w="",{force:A=!1}={})=>{if(!n.data)return;const R=S.value??null;if(!A&&d.value.keyword===w&&d.value.parent===R&&s.value.length>0)return;d.value={keyword:w,parent:R};const ge=await Q(w);I(ge)},de=((w,A=200)=>{let R;return(...re)=>{R&&clearTimeout(R),R=setTimeout(()=>w(...re),A)}})(async w=>{n.data&&await J(w,{force:!0})},250),ne=e.ref(null),ae=()=>{if(!m.value)return;const w=m.value.getBoundingClientRect(),A=window.innerHeight??document.documentElement.clientHeight,R=window.innerWidth??document.documentElement.clientWidth,re=8,ge=8,Ae=n.maxHeight??280,$e=A-w.bottom-ge-re,We=w.top-ge-re,rt=$e>=We,pt=Math.max(R-re*2,0);let{width:Fe}=w;pt>0&&Fe>pt&&(Fe=pt);let{left:lt}=w;lt+Fe+re>R&&(lt=R-Fe-re),lt=Math.max(lt,re);const Ot=Math.min(Ae,Math.max(rt?$e:We,50));_.value={position:"fixed",left:`${lt}px`,width:`${Fe}px`,maxHeight:`${Ot}px`,transform:rt?"none":"translateY(-100%)",top:rt?`${w.bottom+ge}px`:`${w.top-ge}px`}},fe=async(w="click")=>{U.value||p.value||(ne.value=w,await J(u.value.trim()),p.value=!0,await e.nextTick(),ae(),b.value?.focus())},Se=()=>{p.value=!1,ne.value=null,e.nextTick(()=>{b.value?.blur()})},Ve=async w=>{if(w.stopPropagation(),!U.value){if(p.value){if(ne.value==="focus"){ne.value=null;return}Se();return}await fe("click")}},Oe=w=>{w.key==="Escape"&&Se()},Te=w=>{if(!p.value)return;const A=w.target;h.value?.contains(A)||Se()},Ne=w=>{const A=w.target;k.value?.contains(A)||h.value?.contains(A)||Se()},Ce=w=>{if(w.key==="Escape"){w.preventDefault(),Se();return}if(w.key==="Enter"){w.preventDefault();const A=E.value[0];A&&Ee(A)}},Ee=w=>{if(!w)return;const A=$(w.id);if(O.value.has(A))return;Y(w);const R={id:w.id,text:V(w)||String(w.id??""),key:M(w.id)};a.value=[...a.value,R],Pe(w),u.value="",e.nextTick(()=>{b.value?.focus()})},Pe=w=>{const A=a.value.map(R=>R.id);r("value-selected",{name:n.name,value:A,option:w})},Me=w=>{if(U.value)return;const A=a.value.filter(R=>$(R.id)!==$(w));a.value=A},{isOpenAdd:ze,addData:Ye,addSchema:H,addForm:Z,addTitle:te,addOption:ce,onAddValue:z}=Io({props:n,fetchOptionByValue:he,optionsList:s,selectedOption:e.ref(null),modelValue:l,onCreated:async(w,A)=>{const R=w??await he(A),re=R?.id??A;O.value.has($(re))||(R&&Y(R),a.value=[...a.value,{id:re,text:R?V(R):String(re),key:M(re)}],Pe(R??null))}}),oe=w=>{U.value||(y.value=w)},_e=w=>{if(U.value||y.value===null||y.value===w)return;const A=[...a.value],[R]=A.splice(y.value,1);A.splice(w,0,R),y.value=null,a.value=A},ve=async()=>{const A=(Array.isArray(l.value)?[...l.value]:[]).filter(re=>re!=null);if(n.data&&A.length){const re=A.filter(ge=>!i.value[$(ge)]);re.length&&await ke(re)}const R=A.map(re=>({id:re,text:i.value[$(re)]??String(re),key:M(re)}));x=!0,a.value=R};e.watch(a,w=>{if(x){x=!1;return}const A=w.map(R=>R.id);v=!0,l.value=A,r("change",A)},{deep:!0}),e.watch(l,()=>{if(v){v=!1;return}ve()},{deep:!0}),e.watch(u,w=>{!n.data||!p.value||de(w.trim())}),e.watch(U,w=>{w&&Se()}),e.watch(()=>n.options,async w=>{n.data||(I(w??[]),await ve())},{immediate:!0,deep:!0}),e.watch(()=>n.data,async w=>{w&&(await J(u.value.trim()),await ve())},{immediate:!0});const j=e.ref(!1);return e.watch(S,async()=>{if(n.data){if(!j.value){j.value=!0;return}a.value=[],await J(u.value.trim()),await ve()}}),e.onMounted(async()=>{document.addEventListener("click",Ne,!0),window.addEventListener("keydown",Oe),window.addEventListener("scroll",Te,!0),await ve()}),e.onUnmounted(()=>{document.removeEventListener("click",Ne,!0),window.removeEventListener("keydown",Oe),window.removeEventListener("scroll",Te,!0)}),(w,A)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(pe.VsModal),{visible:e.unref(ze),"onUpdate:visible":A[1]||(A[1]=R=>e.isRef(ze)?ze.value=R:null),class:"z-[1000]",title:e.unref(te),buttonText:"Додати",onDone:e.unref(ce)},{default:e.withCtx(()=>[e.createVNode(ot,{schema:e.unref(H),modelValue:e.unref(Ye),"onUpdate:modelValue":A[0]||(A[0]=R=>e.isRef(Ye)?Ye.value=R:null),ref_key:"addForm",ref:Z},null,8,["schema","modelValue"])]),_:1},8,["visible","title","onDone"]),e.createElementVNode("div",{class:"flex flex-col gap-2 w-full",ref_key:"rootRef",ref:k},[e.createElementVNode("div",fp,[e.createElementVNode("div",{class:"relative flex-1",onClick:A[4]||(A[4]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",{ref_key:"triggerRef",ref:m,class:e.normalizeClass(["flex min-h-[38px] items-center justify-between rounded border transition-colors bg-white px-3","border-gray-300 hover:border-[#b3d4ff]",p.value?"border-[#2684ff] ring-1 ring-[#2684ff] shadow-[0_0_0_1px_rgba(38,132,255,0.5)]":"",U.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:Ve},[e.withDirectives(e.createElementVNode("input",{ref_key:"inputRef",ref:b,"onUpdate:modelValue":A[2]||(A[2]=R=>u.value=R),placeholder:W.value,disabled:U.value,readonly:!L.value,onFocus:A[3]||(A[3]=()=>fe("focus")),onKeydown:Ce,class:"flex-1 bg-transparent border-0 outline-none px-0 py-1 text-sm text-stone-900 placeholder:text-stone-400"},null,40,hp),[[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,mp),(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:h,class:"fixed z-[3000] rounded-md border border-stone-200 bg-white shadow-lg overflow-auto",style:e.normalizeStyle(_.value)},[e.createElementVNode("div",gp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(E.value,R=>(e.openBlock(),e.createElementBlock("button",{key:$(R.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(re=>Ee(R),["stop"]),disabled:U.value},e.toDisplayString(V(R)),9,yp))),128)),E.value.length===0?(e.openBlock(),e.createElementBlock("p",bp," Немає варіантів ")):e.createCommentVNode("",!0)])],4)):e.createCommentVNode("",!0)]),_:1})]))]),n.add?(e.openBlock(),e.createElementBlock("button",{key:0,onClick:A[5]||(A[5]=(...R)=>e.unref(z)&&e.unref(z)(...R)),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:U.value,type:"button"},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),A[8]||(A[8]=e.createElementVNode("span",null,"Додати",-1))],8,kp)):e.createCommentVNode("",!0)]),e.createElementVNode("div",xp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.value,(R,re)=>(e.openBlock(),e.createElementBlock("div",{key:R.key,class:e.normalizeClass(["flex items-center gap-2 rounded-md border border-stone-200 bg-white px-2 py-2",{"opacity-60":y.value===re}]),draggable:"true",onDragstart:ge=>oe(re),onDragover:A[6]||(A[6]=e.withModifiers(()=>{},["prevent"])),onDrop:ge=>_e(re),onDragend:A[7]||(A[7]=ge=>y.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:U.value,"aria-label":"Перетягнути"},[e.createVNode(e.unref(q.GripVertical),{class:"h-4 w-4"})],8,_p),e.createElementVNode("div",{class:"flex-1 text-sm text-stone-900",title:R.text},e.toDisplayString(R.text),9,Cp),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:U.value,onClick:e.withModifiers(ge=>Me(R.id),["stop"]),"aria-label":`Видалити ${R.text}`},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})],8,vp)],42,wp))),128)),a.value.length===0?(e.openBlock(),e.createElementBlock("p",Ep,"Немає вибраних значень")):e.createCommentVNode("",!0)])],512)],64))}}),[["__scopeId","data-v-da4b4da7"]]),Bp={class:"flex items-center gap-2 w-full"},Vp={class:"relative flex-1"},Sp=["placeholder","disabled","onKeydown"],$p=["disabled"],Np={key:0,class:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50"},Ap={class:"bg-white text-gray-900 rounded-lg shadow-lg w-[480px] max-h-[80vh] overflow-y-auto"},Fp={class:"p-3 border-b font-semibold text-gray-900 flex justify-between items-center"},Mp=["onClick"],Dp={key:0,class:"p-4 text-sm text-gray-500"},or=e.defineComponent({__name:"vs-input-address",props:e.mergeModels({api:{default:""},geom:{default:""},includes:{default:()=>[]},bbox:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue","update:geom"],["update:modelValue"]),setup(o,{emit:t}){const n=/{{\s*([^}]+?)\s*}}/g,r=o,l=t,{inputClass:a}=Ue(r.style),s=e.useModel(o,"modelValue"),i=e.computed({get:()=>s.value,set:L=>{s.value=L}}),c=e.ref(!1),d=e.ref([]),u=e.ref(!1),p=e.ref(null);e.watch(u,L=>{typeof document>"u"||(L?(p.value=document.body.style.overflow,document.body.style.overflow="hidden"):p.value!=null?(document.body.style.overflow=p.value,p.value=null):document.body.style.removeProperty("overflow"))}),e.onBeforeUnmount(()=>{typeof document>"u"||(p.value!=null?document.body.style.overflow=p.value:document.body.style.removeProperty("overflow"))});const y=e.computed(()=>r.placeholder??""),k=e.computed(()=>!!r.disabled),m=L=>{if(!L)return null;if(Array.isArray(L))return L;if(typeof L=="string"){const B=L.split(",").map(S=>S.trim()).filter(Boolean);return B.length!==4?null:B.map(Number)}return null},h=e.computed(()=>{const L=m(r.bbox);if(!L||L.length!==4)return null;const B=L.map(Number);return B.some(S=>Number.isNaN(S))?null:B}),b=e.computed(()=>{const L=h.value;if(!L)return"";const[B,S,$,V]=L;return`${B},${Math.max(S,V)},${$},${Math.min(S,V)}`});e.computed(()=>b.value?"1":"0");const _=e.inject("values");function x(){!k.value&&i.value.trim()&&v()}async function v(){const L=(i.value||"").trim();if(!L)return;let B=L;if(r.includes?.length&&_?.value){const $=r.includes.map(V=>_.value?.[V]).filter(Boolean);$.length&&(B=`${$.join(", ")}, ${L}`)}const S=W(B);if(S){c.value=!0;try{const V=await(await fetch(S)).json();d.value=Array.isArray(V)?V:[],u.value=!0}catch($){console.error("Address search error:",$)}finally{c.value=!1}}}function N(){u.value=!u.value}function U(L){if(!L)return;u.value=!1;const B=parseFloat(L.lat),$={type:"Point",coordinates:[parseFloat(L.lon),B]};r.geom&&_?.value&&(_.value[r.geom]=$),l("update:geom",$)}function W(L){if(!r.api)return"";const B={value:encodeURIComponent(L),bbox:h.value?h.value.join(","):""};return r.api.replace(n,(S,$)=>B[$.trim()]??"")}return(L,B)=>(e.openBlock(),e.createElementBlock("div",Bp,[e.createElementVNode("div",Vp,[e.withDirectives(e.createElementVNode("input",{type:"text","onUpdate:modelValue":B[0]||(B[0]=S=>i.value=S),placeholder:y.value,disabled:k.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,Sp),[[e.vModelText,i.value]]),d.value.length?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"absolute right-2 top-1/2 -translate-y-1/2 text-gray-500 hover:text-blue-600",onClick:N,title:"Show search results"},[e.createVNode(e.unref(q.Info),{class:"h-4 w-4"})])):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",onClick:v,class:"flex items-center justify-center px-2 py-2 border rounded-md bg-white hover:bg-gray-50 text-gray-600 hover:text-blue-600 disabled:opacity-50 h-[38px]",disabled:c.value||!i.value?.trim()},[c.value?(e.openBlock(),e.createBlock(e.unref(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,$p),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[u.value?(e.openBlock(),e.createElementBlock("div",Np,[e.createElementVNode("div",Ap,[e.createElementVNode("div",Fp,[B[2]||(B[2]=e.createElementVNode("span",null,"Результати пошуку",-1)),e.createElementVNode("button",{class:"text-gray-500 hover:text-blue-600",onClick:B[1]||(B[1]=S=>u.value=!1),title:"Close"},[e.createVNode(e.unref(q.X),{class:"h-4 w-4"})])]),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(S,$)=>(e.openBlock(),e.createElementBlock("li",{key:$,onClick:V=>U(S),class:"px-3 py-2 cursor-pointer hover:bg-gray-100 border-b text-sm"},e.toDisplayString(S.display_name),9,Mp))),128))]),d.value.length?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",Dp," Не знайдено результатів "))])])):e.createCommentVNode("",!0)]))]))}}),Tp={class:"vs-datalist space-y-3"},Lp={class:"space-y-3"},Ip=["onClick","disabled"],Rp={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Op=["disabled"],Pp=xe(e.defineComponent({__name:"vs-input-datalist",props:e.mergeModels({schema:{default:()=>[]},minItems:{default:0},maxItems:{default:void 0},addButtonText:{default:"Додати позицію"},emptyLabel:{default:"Немає рядків"},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.computed(()=>Array.isArray(n.value)?n.value:[]),l=e.ref([]),a=e.computed(()=>t.schema?.map(h=>({...h,disabled:t.disabled||h.disabled}))??[]),s=e.computed(()=>a.value.map(h=>m(h))),i=e.computed(()=>t.disabled?!1:t.maxItems?r.value.length<t.maxItems:!0),c=e.computed(()=>t.disabled||r.value.length<=(t.minItems||0));e.watch(()=>r.value.length,()=>{d(),u()},{immediate:!0}),e.watch(()=>t.schema,u,{immediate:!0,deep:!0});function d(){const h=r.value.length;l.value.length<h?l.value=[...l.value,...Array.from({length:h-l.value.length},()=>to())]:l.value.length>h&&l.value.splice(h)}function u(){if(!t.minItems||r.value.length>=t.minItems)return;const h=t.minItems-r.value.length,b=Array.from({length:h},p);n.value=[...r.value,...b]}function p(){const h={};return a.value.forEach(b=>{h[b.name]=b?.default??null}),h}function y(){i.value&&(n.value=[...r.value,p()],d())}function k(h){c.value||(n.value=r.value.filter((b,_)=>_!==h),d(),u())}function m(h){return{...h}}return(h,b)=>(e.openBlock(),e.createElementBlock("div",Tp,[e.createElementVNode("div",Lp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,(_,x)=>(e.openBlock(),e.createElementBlock("div",{key:l.value[x],class:"flex items-center gap-3"},[e.createVNode(ot,{schema:s.value,layout:"inline",navigation:!1,values:r.value[x],"onUpdate:values":v=>r.value[x]=v,"form-id":l.value[x]},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:v=>k(x),disabled:c.value},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Ip)]))),128)),r.value.length===0?(e.openBlock(),e.createElementBlock("div",Rp,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,Op)]))}}),[["__scopeId","data-v-260e3e66"]]),zp={class:"vs-dataform space-y-4"},jp=["draggable","onDragstart","onDragover","onDragenter","onDrop"],Up={class:"flex items-center gap-2"},Hp=["onClick"],qp={class:"text-sm font-medium text-gray-700"},Kp={class:"flex items-center gap-2"},Wp=["title","onClick","disabled"],Gp=["title","onClick","disabled"],Yp={key:0,class:"rounded-lg border border-dashed border-gray-200 p-4 text-sm text-gray-500"},Xp=["disabled"],Zp=xe(e.defineComponent({__name:"vs-input-dataform",props:e.mergeModels({schema:{default:()=>[]},minGroups:{default:0},maxGroups:{default:void 0},addButtonText:{default:"Додати групу фільтрів"},groupLabel:{default:void 0},duplicateTitle:{default:"Дублювати групу"},removeTitle:{default:"Видалити групу"},emptyLabel:{},view:{default:"default"},collapsible:{type:Boolean,default:!1},draggable:{type:Boolean,default:!0},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:()=>[]},modelModifiers:{}}),emits:["update:modelValue"],setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref([]),l=e.ref([]),a=e.ref(0),s=e.ref(null),i=e.ref(null),c=e.ref(null),d=e.computed(()=>t.groupLabel??"Group"),u=e.computed(()=>t.emptyLabel??"Ще немає груп"),p=e.computed(()=>t.schema?.map(J=>({...J,disabled:t.disabled||J.disabled}))??[]),y=e.computed(()=>p.value.map(J=>S(J))),k=e.computed(()=>t.view==="accordion"),m=e.computed(()=>!!(t.collapsible||k.value)),h=e.computed(()=>t.draggable!==!1),b=e.computed(()=>t.disabled?!1:t.maxGroups?n.value.length<t.maxGroups:!0),_=e.computed(()=>t.disabled||n.value.length<=(t.minGroups||0));e.watch(()=>n.value.length,()=>{x(),v(),N()},{immediate:!0}),e.watch(()=>t.schema,N,{immediate:!0,deep:!0}),e.watch(()=>t.view,()=>{v()},{immediate:!0});function x(){const J=n.value.length;r.value.length<J?r.value=[...r.value,...Array.from({length:J-r.value.length},()=>to())]:r.value.length>J&&r.value.splice(J)}function v(){const J=n.value.length;k.value?J===0?a.value=-1:a.value>=J?a.value=J-1:a.value<0&&(a.value=0):l.value.length<J?l.value=[...l.value,...Array.from({length:J-l.value.length},()=>!1)]:l.value.length>J&&l.value.splice(J)}function N(){if(!t.minGroups||n.value.length>=t.minGroups)return;const J=t.minGroups-n.value.length,me=Array.from({length:J},U);n.value=[...n.value,...me],v()}function U(){const J={};return p.value.forEach(me=>{J[me.name]=me?.default??null}),J}function W(){b.value&&(n.value=[...n.value,U()],x(),v())}function L(J){_.value||(n.value=n.value.filter((me,de)=>de!==J),x(),k.value?a.value>=n.value.length&&(a.value=n.value.length-1):l.value.splice(J,1),N())}function B(J){if(t.disabled)return;const me=JSON.parse(JSON.stringify(n.value[J]??{}));n.value=[...n.value.slice(0,J+1),me,...n.value.slice(J+1)],x(),k.value?a.value>J&&(a.value+=1):l.value.splice(J+1,0,l.value[J]??!1)}function S(J){return{...J}}function $(J){return k.value?a.value===-1&&J===0?!1:a.value!==J:!!l.value[J]}function V(J){if(m.value){if(k.value){a.value=J;return}l.value[J]=!l.value[J]}}function M(J,me){if(!h.value||t.disabled){me.preventDefault();return}s.value=J,i.value=J,c.value={groups:JSON.parse(JSON.stringify(n.value)),keys:[...r.value],states:[...l.value]},me.dataTransfer?.setData("text/plain",String(J)),me.dataTransfer?.setDragImage?.(me.currentTarget,0,0)}function O(J,me){!h.value||t.disabled||s.value!==null&&X(J,me)}function E(J,me){X(J,me)}function K(J){!h.value||t.disabled||he()}function T(){c.value&&I(),s.value=null,i.value=null,c.value=null}function Y(J,me){const de=[...n.value],[ne]=de.splice(J,1);de.splice(me,0,ne),n.value=de;const ae=[...r.value],[fe]=ae.splice(J,1);if(ae.splice(me,0,fe),r.value=ae,k.value)a.value===J&&(a.value=me);else{const Se=[...l.value],[Ve]=Se.splice(J,1);Se.splice(me,0,Ve),l.value=Se}}function I(){c.value&&(n.value=c.value.groups,r.value=c.value.keys,l.value=c.value.states,c.value=null,i.value=null)}function X(J,me){if(s.value===null)return;const de=Q(J,me);i.value=de,ke(de)}function Q(J,me){if(!me?.currentTarget)return J;const de=me.currentTarget.getBoundingClientRect(),ae=me.clientY-de.top>de.height/2?J+1:J;return Math.max(0,Math.min(ae,n.value.length))}function ke(J){const me=s.value;if(me===null)return;let de=J;if(de>n.value.length&&(de=n.value.length),de===me||de===me+1)return;const ne=de>me?de-1:de;Y(me,ne),s.value=ne,i.value=de>me?ne+1:ne}function he(){c.value=null,s.value=null,i.value=null}return(J,me)=>(e.openBlock(),e.createElementBlock("div",zp,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,(de,ne)=>(e.openBlock(),e.createElementBlock("div",{key:r.value[ne],class:e.normalizeClass(["relative border border-gray-200 rounded-lg bg-white transition vs-dataform__group",[t.view==="accordion"?"overflow-hidden":$(ne)?"pt-6 px-6":"p-6"]]),draggable:h.value&&!t.disabled,onDragstart:ae=>M(ne,ae),onDragend:T,onDragover:e.withModifiers(ae=>O(ne,ae),["prevent"]),onDragenter:e.withModifiers(ae=>E(ne,ae),["prevent"]),onDrop:e.withModifiers(ae=>K(),["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"&&!$(ne)?"rounded-t-lg":"rounded-lg"]])},[e.createElementVNode("div",Up,[h.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),m.value?(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"rounded-full p-1 text-gray-500 transition hover:bg-gray-100",onClick:ae=>V(ne)},[e.createVNode(e.unref(q.ChevronDown),{class:e.normalizeClass(["h-4 w-4 transition",$(ne)?"-rotate-90":"rotate-0"])},null,8,["class"])],8,Hp)):e.createCommentVNode("",!0),e.createElementVNode("div",qp,e.toDisplayString(`${d.value} (${ne+1})`),1)]),e.createElementVNode("div",Kp,[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:ae=>B(ne),disabled:t.disabled,draggable:"false"},[e.createVNode(e.unref(q.Copy),{class:"h-4 w-4"})],8,Wp),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:ae=>L(ne),disabled:_.value,draggable:"false"},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Gp)])],2),e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(t.view==="accordion"?"p-6":"pt-6")},[e.createVNode(ot,{class:"vs-dataform__form",schema:y.value,layout:"inline",navigation:!1,values:n.value[ne],"onUpdate:values":ae=>n.value[ne]=ae,"form-id":r.value[ne],disabled:t.disabled},null,8,["schema","values","onUpdate:values","form-id","disabled"])],2),[[e.vShow,!$(ne)]])],42,jp))),128)),n.value.length===0?(e.openBlock(),e.createElementBlock("div",Yp,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:W,disabled:!b.value},[e.createVNode(e.unref(q.Plus),{class:"h-4 w-4"}),e.createTextVNode(" "+e.toDisplayString(t.addButtonText),1)],8,Xp)]))}}),[["__scopeId","data-v-cfbcfed8"]]),Vn="__vs_form_monaco_loader__",It="__vs_form_monaco_script_loader__",Sn="__vs_form_monaco_editor_loader__",no=e.defineComponent({__name:"vs-input-monaco",props:e.mergeModels({syntax:{default:"xml"},theme:{default:"vs-light"},height:{default:280},minimap:{type:Boolean,default:!1},style:{},customClass:{},disabled:{type:Boolean},modelValue:{},error:{},name:{},placeholder:{},maxlength:{},minlength:{}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:t}){const n=o,r=e.useModel(o,"modelValue"),l=e.ref(null),a=e.computed(()=>typeof n.height=="number"?`${n.height}px`:n.height||"280px");let s=null,i=null,c=!1;const d=()=>{if(i)return Promise.resolve(i);if(typeof window>"u")return Promise.resolve(null);const m=window;if(m.monaco?.editor?.create)return i=m.monaco,Promise.resolve(i);if(m[Vn])return m[Vn];const b=(async()=>{const _=N=>{if(Array.from(document.styleSheets||[]).some(L=>L?.href?.includes(N)))return;const W=document.createElement("link");W.rel="stylesheet",W.href=N,document.head.appendChild(W)},x=N=>{if(m[It]?.[N])return m[It][N];m[It]||={};const U=Array.from(document.scripts).find(W=>W.src===N);return U?(m[It][N]=new Promise((W,L)=>{const B=U.readyState;if(U.dataset.loaded==="true"||B==="loaded"||B==="complete"){W();return}U.addEventListener("load",()=>{U.dataset.loaded="true",W()},{once:!0}),U.addEventListener("error",S=>L(S),{once:!0})}),m[It][N]):(m[It][N]=new Promise((W,L)=>{const B=document.createElement("script");B.src=N,B.async=!0,B.onload=()=>{B.dataset.loaded="true",W()},B.onerror=S=>L(S),document.body.appendChild(B)}),m[It][N])},v="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.52.0/min/vs";return _(`${v}/editor/editor.main.min.css`),await x(`${v}/loader.min.js`),m[Sn]||(m[Sn]=new Promise((N,U)=>{window.require.config({paths:{vs:v}}),window.require(["vs/editor/editor.main"],()=>{i=window.monaco,m.monaco=i,N(i)},W=>U(W))}).catch(N=>{throw delete m[Sn],N})),m[Sn]})().catch(_=>{throw delete m[Vn],_});return m[Vn]=b,b},u=()=>{!l.value||!i||(s&&(s.dispose(),s=null),s=i.editor.create(l.value,{value:r.value||"",language:n.syntax,theme:n.theme,automaticLayout:!0,minimap:{enabled:!!n.minimap},readOnly:!!n.disabled}),s.onDidChangeModelContent(()=>{c||(r.value=s.getValue())}))},p=()=>{s?.focus()},y=()=>s,k=()=>i;return e.watch(()=>r.value,m=>{if(!s)return;const h=s.getValue();m!==h&&(c=!0,s.setValue(m||""),c=!1)}),e.watch(()=>n.syntax,m=>{!s||!i||i.editor.setModelLanguage(s.getModel(),m||"xml")}),e.watch(()=>n.theme,m=>{i&&i.editor.setTheme(m||"vs-light")}),e.watch(()=>n.disabled,m=>{s&&s.updateOptions({readOnly:!!m})}),e.watch(()=>n.minimap,m=>{s&&s.updateOptions({minimap:{enabled:!!m}})}),e.onMounted(async()=>{try{const m=await d();if(!m||!m.editor)return;i=m,u()}catch(m){console.error("Failed to load Monaco editor",m)}}),e.onBeforeUnmount(()=>{s&&(s.dispose(),s=null)}),t({focus:p,getEditor:y,getMonaco:k}),(m,h)=>(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))}}),rr={VsInputText:zt,VsInputRadio:Zn,VsInputInlineSelect:kn,"vs-input-text":zt,"vs-input-password":xl,"vs-input-textarea":Oo,"vs-input-richtext":Po,"vs-input-mask":mn,"vs-input-number":Vo,"vs-input-radio":Zn,"vs-input-select":eo,"vs-input-inline-select":kn,"inline-select":kn,"vs-input-switcher":Wn,"vs-input-static":Gn,"vs-input-container":Lo,"vs-input-date":ga,"vs-input-checkbox":No,"vs-input-file":Mo,"vs-input-file2":Qn,file2:Qn,File2:Qn,"vs-input-html":Gn,"vs-input-email":Yn,"vs-input-tel":Xn,"vs-input-datatable":zo,"vs-input-map":Go,"vs-input-file-list":Do,"vs-input-tags":Yo,"vs-input-slug":Xo,"vs-input-codegen":Zo,"vs-input-key-value":Jo,"vs-input-text[]":Qo,"vs-input-range":tr,"vs-input-color":er,"vs-input-native-select":eo,VsInputArraySelect:Bn,"vs-input-array":nr,"vs-input-array-select":Bn,"array-select":Bn,"vs-input-address":or,"vs-input-datalist":Pp,"vs-input-dataform":Zp,"vs-input-monaco":no},Jp=e.defineComponent({__name:"behavior",props:{api:{},set:{},button:{},error:{},value:{}},setup(o){const t=o,n=e.inject("values");async function r(){try{if(!t.api)return;const l=t.api.replace("{{value}}",t.value),a=await fetch(l);if(!a.ok){pe.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const s=await a.json();if(!t.set||!n)return;for(const[i,c]of Object.entries(t.set))n.value[i]=s.result[c]}catch(l){console.error(t.error,l)}}return(l,a)=>(e.openBlock(),e.createElementBlock("button",{onClick:r,class:"vs-button relative inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-blue-500 hover:border-blue-500 hover:bg-blue-500 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 ml-0 md:ml-2 mt-2 md:mt-0 py-[8px] md:w-2/4 whitespace-nowrap w-full"},e.toDisplayString(l.button),1))}}),Qp={class:"flex flex-col gap-1 w-full"},ef={class:"w-full"},tf=["disabled"],nf=["innerHTML"],of=2e3,rf=10,lr=e.defineComponent({__name:"vs-compact-form-layout",props:e.mergeModels({item:{default:{}},layout:{default:"default"},style:{default:{}},type:{default:""},error:{type:[String,Boolean]},columns:{default:()=>({container:12,label:3})}},{modelValue:{default:null},modelModifiers:{}}),emits:e.mergeModels(["value-selected"],["update:modelValue"]),setup(o,{emit:t}){const n=o,r=e.useModel(o,"modelValue"),l=t,a=e.computed(()=>bl[`${n.layout}`]),s=["label","placeholder","info","description","text","html"],i=e.ref(S()),c=e.computed(()=>W(n.item,i.value)),d=e.computed(()=>rr?.[`vs-input-${n.item.type}`]),u=e.inject("field-props"),p=e.computed(()=>{const V=e.unref(d);if(!V)return new Set;const M=V.props??V.__vccOpts?.props;if(!M)return new Set;const O=Array.isArray(M)?M:Object.keys(M);return new Set(O)}),k=[...["min","max","step"],"api","set","mask"],m=e.computed(()=>{const V={...c.value??{}},M=n.item?.name;M&&u?.value?.[M]&&Object.assign(V,u.value[M]);const O=p.value;let E;return O.size?E=Object.fromEntries(Object.entries(V).filter(([K])=>O.has(K))):E=V,k.forEach(K=>{const T=V[K];T!=null&&(E[K]=T)}),E}),h=V=>{const M=typeof V=="object"&&V!==null?V:{value:V};l("value-selected",{...M,name:M.name??n.item?.name})},b=/{{\s*([^}]+?)\s*}}/g,_=e.inject("values"),x=e.ref(!1),v=e.computed(()=>{const V=n.item?.api,M=n.item?.type?.toLowerCase();return typeof V=="string"&&V.trim().length>0&&(M==="text"||M==="mask")});function N(V,M){if(!(V==null||!M))return M.split(".").reduce((O,E)=>O?.[E.trim()],V)}async function U(){const V=String(r.value??"").trim();if(!V)return;const M=(n.item?.api??"").trim();if(!M)return;const O=M.replace(b,(E,K)=>K.trim()==="value"?encodeURIComponent(V):"");x.value=!0;try{let E=await fetch(O),K=0;for(;E.status===202&&K<rf;)K+=1,await new Promise(Q=>{setTimeout(Q,of)}),E=await fetch(O);if(E.status===202){pe.notify({type:"warning",title:"Validation",message:"Сервер ще обробляє запит. Спробуйте пізніше."});return}if(!E.ok){pe.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."});return}const T=await E.json(),Y=T?.result!==void 0?T.result:T,I=n.item?.set;if(!I||!_?.value)return;const X=n.item?.name;Object.entries(I).forEach(([Q,ke])=>{if(!Q)return;let he=ke;X&&he.startsWith(`${X}.`)&&(he=he.slice(X.length+1));const J=N(Y,he);_.value[Q]=J??null})}catch(E){console.error("API lookup error:",E),pe.notify({type:"warning",title:"Validation",message:"При спробі завантажити дані виникла помилка."})}finally{x.value=!1}}e.onMounted(()=>{i.value=S(),window.addEventListener("storage",$)}),e.onUnmounted(()=>{window.removeEventListener("storage",$)});function W(V,M){if(!V)return{};const O={...V};return s.forEach(E=>{const K=B(V,E,M);K!=null&&(O[E]=K)}),Array.isArray(V.options)&&(O.options=V.options.map(E=>L(E,M))),O}function L(V,M){if(!V)return V;const O={...V},E=B(V,"label",M),K=B(V,"text",M);return E!=null&&(O.label=E),K!=null?O.text=K:E!=null&&(O.text=E),O}function B(V,M,O){const E=`${M}:${O}`;if(V?.[E]!=null)return V[E];if(M==="label"&&V?.[O]!=null)return V[O];if(V?.[M]!=null)return V[M];if(M==="label"){if(V?.ua!=null)return V.ua;if(V?.en!=null)return V.en}if(M==="text"||M==="html"){if(V?.ua!=null)return V.ua;if(V?.en!=null)return V.en}return null}function S(){return typeof window>"u"?"uk":localStorage.getItem("locale")||"uk"}function $(){i.value=S()}return(V,M)=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(a.value),{ua:c.value.ua,error:n.error||"",item:c.value,columns:n.columns,label:c.value.label},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["flex w-full",`${n.item.type}-component`])},[e.createElementVNode("div",Qp,[e.createElementVNode("div",{class:e.normalizeClass(["flex items-center gap-2 w-full",{"flex-1":v.value}])},[e.createElementVNode("div",ef,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(d.value),e.mergeProps(m.value,{modelValue:r.value,"onUpdate:modelValue":M[0]||(M[0]=O=>r.value=O),onValueSelected:h}),null,16,["modelValue"]))]),v.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:x.value||!r.value?.toString().trim(),onClick:U},[x.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,tf)):e.createCommentVNode("",!0)],2),c.value.description&&n.layout!=="settings"?(e.openBlock(),e.createElementBlock("p",{key:0,class:"text-sm text-gray-500",innerHTML:c.value.description},null,8,nf)):e.createCommentVNode("",!0)]),c.value.behavior?.api&&c.value.behavior?.button?(e.openBlock(),e.createBlock(Jp,e.mergeProps({key:0},c.value.behavior,{value:r.value}),null,16,["value"])):e.createCommentVNode("",!0)],2)]),_:1},8,["ua","error","item","columns","label"]))}}),lf={class:"text-sm text-gray-800 mb-[4px] font-medium dark:text-neutral-300"},af={class:"vs-compact-form-navigation__rail mt-[6px]"},sf=["onClick"],cf=xe(e.defineComponent({__name:"vs-compact-form-navigation",props:{target:{},scrollContainer:{},title:{default:"Навігація"},enabled:{type:Boolean,default:!0},width:{default:400}},setup(o,{expose:t}){const n=o,r=e.ref([]),l=e.ref(""),a=e.ref(""),s=e.computed(()=>!!n.enabled),i=e.computed(()=>["vs-compact-form-navigation flex flex-col pl-[6px] pt-[8px] pr-[8px]","sticky top-0 self-start shrink-0","max-h-full min-h-0 overflow-y-auto"]),c=e.computed(()=>{const V=n.width;if(V==null)return{};const M=typeof V=="number"?`${V}px`:`${V}`;return{width:M,minWidth:M}});let d=null,u=0,p=0,y=null,k=null,m=null;const h=()=>S(),b=()=>x();e.watch(()=>n.target,async V=>{if(W(),!V){y=null,r.value=[],l.value="";return}y=V,s.value&&(await e.nextTick(),U(V),x())},{immediate:!0}),e.watch(()=>n.scrollContainer,V=>{if(!s.value){k=V??null;return}_(V??null),e.nextTick(()=>x())},{immediate:!0}),e.onMounted(()=>{n.scrollContainer||_(null),x()}),e.onBeforeUnmount(()=>{W(),_(null,!0),y=null,typeof window<"u"&&(u&&window.cancelAnimationFrame(u),p&&window.cancelAnimationFrame(p))});function _(V,M=!1){if(m&&(m(),m=null),M){k=null;return}if(k=V??null,typeof window>"u")return;const O=V??window,E=window;O.addEventListener("scroll",h,{passive:!0}),E.addEventListener("resize",b),m=()=>{O.removeEventListener("scroll",h),E.removeEventListener("resize",b)}}function x(){if(!s.value||!y)return;u&&typeof window<"u"&&window.cancelAnimationFrame(u);const V=()=>{v(),u=0};typeof window>"u"?V():u=window.requestAnimationFrame(V)}function v(){if(!s.value||!y)return;const V=Array.from(y.querySelectorAll("h1, h2")),M=new Set,O=[];V.forEach((E,K)=>{const T=E.textContent?.trim()??"";if(!T)return;let Y=(E.getAttribute("id")??"").trim();Y||(Y=N(T)||`heading-${K+1}`);let I=Y,X=1;for(;M.has(I);)I=`${Y}-${X+=1}`;E.id!==I&&Object.assign(E,{id:I}),M.add(I),O.push({id:I,text:T,level:E.tagName.toLowerCase()==="h1"?1:2})}),r.value=O,O.length||(l.value=""),B()}function N(V){return V.toLowerCase().replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-")}function U(V){!V||!s.value||typeof MutationObserver>"u"||(W(),d=new MutationObserver(()=>x()),d.observe(V,{childList:!0,subtree:!0}))}function W(){d&&(d.disconnect(),d=null)}function L(V){const M=k;if(!M)return typeof window>"u"?V.offsetTop:V.getBoundingClientRect().top+window.scrollY;const O=V.getBoundingClientRect(),E=M.getBoundingClientRect();return O.top-E.top+M.scrollTop}function B(){if(!s.value||!r.value.length)return;const V=k,M=(V?V.scrollTop:null)||(typeof window<"u"?window.scrollY:0),O=(V?V.clientHeight:null)||(typeof window<"u"?window.innerHeight:0),E=M+O;let K=null;for(let Y=0;Y<r.value.length;Y+=1){const I=r.value[Y],X=document.getElementById(I.id);if(X){const Q=L(X);Q+X.offsetHeight>M&&Q<E&&(K=I.id)}}!K&&a.value&&(K=a.value),K&&(a.value=K);const T=V?V.scrollHeight-V.clientHeight:document.documentElement.scrollHeight-window.innerHeight;M+5>=T&&(K=r.value[r.value.length-1].id),K&&(l.value=K)}function S(){s.value&&(p&&window.cancelAnimationFrame(p),p=window.requestAnimationFrame(()=>{B(),p=0}))}function $(V){if(!s.value)return;const M=document.getElementById(V);if(!M)return;const O=k,E=Math.max(0,L(M));O?O.scrollTo({top:E,behavior:"smooth"}):typeof window<"u"&&window.scrollTo({top:E,behavior:"smooth"})}return t({refresh:x}),(V,M)=>s.value&&r.value.length?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(i.value),style:e.normalizeStyle(c.value)},[e.createElementVNode("h2",lf,e.toDisplayString(V.title),1),e.createElementVNode("div",af,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,O=>(e.openBlock(),e.createElementBlock("div",{key:O.id,class:e.normalizeClass(["vs-compact-form-navigation__item relative",O.level===2?"vs-compact-form-navigation__item--nested":"",O.id===l.value?"vs-compact-form-navigation__item--active":""])},[e.createElementVNode("button",{type:"button",onClick:E=>$(O.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",O.level===2?"pl-[15px]":"pl-[18px]",O.id===l.value?"text-gray-800":"text-gray-500"])},[e.createElementVNode("span",null,e.toDisplayString(O.text),1)],10,sf)],2))),128))])],6)):e.createCommentVNode("",!0)}}),[["__scopeId","data-v-1584a562"]]),dt={required:"Це поле є обов’язковим",email:"Неправильний email",tel:"Неправильний телефон",minlength:o=>`Мінімальна довжина — ${o} символів`,maxlength:o=>`Максимальна довжина — ${o} символів`,min:o=>`Значення має бути не менше ${o}`,max:o=>`Значення має бути не більше ${o}`},df=o=>typeof o=="string"?o.trim()?!1:dt.required:Array.isArray(o)?o.map(n=>typeof n=="string"?n.trim():n).filter(n=>n!=null&&n!=="").length?!1:dt.required:typeof o=="number"?Number?.isNaN(o)?dt?.required:!1:o?!1:dt.required,uf=o=>{const t=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;return o?t.test(o)?!1:dt.email:!1},pf=(o,t)=>{if(!o)return!1;const n=String(o).trim();if(!/^\+[1-9]\d{1,14}$/.test(n))return dt.tel;const a=(typeof t?.digits=="number"&&Number.isFinite(t.digits)&&t.digits>0?t.digits:Vt(xt))||Vt(xt);return n.length-1!==a?dt.tel:!1},ar=o=>o==null?0:typeof o=="string"?o.trim().length:Array.isArray(o)?o.length:typeof o=="number"?o.toString().length:String(o).length,ff=(o,t)=>{if(o==null)return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&ar(o)<n?t?.message||dt.minlength(n):!1},mf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value??t?.length);return Number.isFinite(n)&&ar(o)>n?t?.message||dt.maxlength(n):!1},sr=o=>{if(typeof o=="number")return o;if(typeof o=="string"){const t=o.trim().replace(",",".");return t?Number(t):Number.NaN}return Number(o)},hf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=sr(o);return Number.isFinite(r)&&r<n?t?.message||dt.min(n):!1},gf=(o,t)=>{if(o==null||o==="")return!1;const n=Number(t?.value);if(!Number.isFinite(n))return!1;const r=sr(o);return Number.isFinite(r)&&r>n?t?.message||dt.max(n):!1},yf=(o,t)=>{const n=t.pattern??t.regexp,r=typeof n=="string"?new RegExp(n):n;if(Array.isArray(o)){const l=o.filter(Boolean);return l.length===0||l.every(a=>r.test(a))?!1:t.message}return!r.test(o)&&o?t.message:!1},bf=(o,t)=>!1,kf=(o,t)=>{switch(typeof t=="string"?t:t.type){case"required":return df(o);case"email":return uf(o);case"tel":return pf(o,typeof t=="object"?t:void 0);case"regexp":return yf(o,t);case"minlength":return ff(o,t);case"maxlength":return mf(o,t);case"min":return hf(o,t);case"max":return gf(o,t);case"custom":return bf();default:return!1}},xf={autocomplete:"select",combobox:"select",datepicker:"date",markedtext:"mask",html:"static",geom:"map",filelist:"file-list",file:"file",dropzone:"file",inlineselect:"inline-select"};function ir(o){const t=o?.toLowerCase();return xf[t]||t}function oo(o,t=!1){if(Array.isArray(o)){const r=[];return o.forEach(l=>{const a={...l};if(a.name=(l.name||l.id||l.key||"").toString(),a.type=ir(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||xt,i=Vt(s)||Vt(xt);a.rules=[{type:"tel",digits:i}]}l.data&&(a.api=`/api/suggest/${l.data}`),a.disabled=a.disabled??t,Array.isArray(a.schema)&&(a.schema=oo(a.schema,a.disabled)),r.push(a)}),r}const n=[];return Object.entries(o).forEach(r=>{const l={name:r[0],...r[1],type:ir(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||xt,s=Vt(a)||Vt(xt);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=oo(l.schema,l.disabled)),n.push(l)}),n}function wf(o,t,n=!1){const r=e.computed(()=>oo((Array.isArray(t),t),typeof n=="boolean"?n:n.value)),l=e.ref({});function a(d){return To(o?.value,d?.conditions)}const s=(d=r.value,u=!0)=>(d.forEach(p=>{const y=[],k=Number(p?.minlength),m=Number(p?.maxlength),h=Number(p?.min),b=Number(p?.max);!Number.isNaN(k)&&Number.isFinite(k)&&y.push({type:"minlength",value:k}),!Number.isNaN(m)&&Number.isFinite(m)&&y.push({type:"maxlength",value:m}),!Number.isNaN(h)&&Number.isFinite(h)&&y.push({type:"min",value:h}),!Number.isNaN(b)&&Number.isFinite(b)&&y.push({type:"max",value:b});const _=[...y,...p.rules||[]];if(_.length){if(!a(p)){delete l.value[p.name];return}let x=!1,v=null;_.forEach(N=>{const U=kf(o.value[p.name],N);U&&(x=!0,!v&&typeof U=="string"&&(v=U))}),x&&v?l.value[p.name]=v:delete l.value[p.name]}p.schema&&s(p.schema,!1)}),u&&Object.values(l.value).some(Boolean)?l.value:null),i=e.computed(()=>r.value?.filter(d=>d.hidden!==!0&&a(d)));return{errors:l,validate:s,reset:()=>{o.value={},l.value={}},visibleSchema:i}}const _f={class:"flex w-full h-full min-h-0 gap-6"},Cf={key:0,"data-orientation":"horizontal",role:"none",class:"mt-1 shrink-0 h-[1px] w-full bg-slate-100 dark:bg-slate-600"},ot=e.defineComponent({__name:"vs-compact-form",props:e.mergeModels({schema:{default:()=>[]},style:{default:()=>({})},modelValue:{},layout:{default:()=>"default"},formId:{default:()=>""},disabled:{type:Boolean,default:!1},navigation:{type:Boolean,default:!1},navWidth:{default:400},columns:{}},{form:{default:()=>({})},formModifiers:{},modelValue:{default:()=>({})},modelModifiers:{},values:{default:void 0},valuesModifiers:{}}),emits:e.mergeModels(["handle-submit","update:modelValue","value-selected"],["update:form","update:modelValue","update:values"]),setup(o,{expose:t,emit:n}){const r=n,l=o,a=e.useModel(o,"form"),s=e.useModel(o,"modelValue"),i=e.useModel(o,"values"),c=e.computed({get:()=>i.value??s.value,set:E=>{s.value=E,i.value=E}}),{errors:d,validate:u,reset:p,visibleSchema:y}=wf(c,l.schema,e.toRef(l,"disabled")),k=e.ref(null),m=e.ref(null),h=e.ref({}),b=e.computed(()=>l.navigation),_=e.computed(()=>l.navWidth),x=e.computed(()=>l.style?.columns),v=Object.freeze({container:12,label:3}),N=e.computed(()=>l.columns??x.value??v),U=e.computed(()=>l.columns!=null||x.value!=null),W=e.computed(()=>U.value?"horizontal":l.layout),L=E=>E?.columns?"horizontal":W.value,B=E=>E?.columns??N.value,S=()=>{!l.formId&&c.value&&delete c.value.id,r("update:modelValue",c.value),u(),r("handle-submit",c.value)},$=E=>{r("value-selected",E)};t({validate:u,reset:p,errors:d}),e.onMounted(()=>{a.value={value:c.value,errors:d.value,reset:p,validate:u,formId:l.formId}});function V(E,K){if(E===K)return!0;if(typeof E!="object"||typeof K!="object"||!E||!K)return!1;const T=Object.keys(E),Y=Object.keys(K);return T.length!==Y.length?!1:T.every(I=>E[I]===K[I])}function M(E){return Array.isArray(E)?[...E]:E&&typeof E=="object"?{...E}:E}function O(E){Array.isArray(E)&&E.forEach(K=>{if(!K)return;const T=K.name,Y=K.default!==void 0;T&&Y&&c.value[T]===void 0&&(c.value[T]=M(K.default)),Array.isArray(K.schema)&&O(K.schema)})}return e.watch(y,E=>{O(E)},{immediate:!0,deep:!0}),e.provide("form",a),e.provide("values",c),e.provide("field-props",h),(E,K)=>(e.openBlock(),e.createElementBlock("div",_f,[e.createElementVNode("div",{class:"flex-1 min-h-0 overflow-y-auto overflow-x-visible",ref_key:"formScrollContainer",ref:m},[e.createElementVNode("form",{ref_key:"formRef",ref:k,onSubmit:e.withModifiers(S,["prevent"]),class:e.normalizeClass(["grid grid-cols-12 p-1",W.value==="default"?"gap-6":"gap-4"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(y),(T,Y)=>(e.openBlock(),e.createElementBlock("div",{key:T.name,class:e.normalizeClass(L(T)==="horizontal"?"col-span-12":`col-span-${T.col||12}`)},[e.createVNode(lr,{style:e.normalizeStyle(E.style),item:T,layout:L(T),columns:B(T),"model-value":c.value[T.name],"onUpdate:modelValue":I=>{if(T.name==="id"&&!E.formId)return;const X=c.value[T.name];V(X,I)||(c.value[T.name]=I)},error:e.unref(d)[T.name],onValueSelected:$},null,8,["style","item","layout","columns","model-value","onUpdate:modelValue","error"]),L(T)==="settings"&&Y+1!==e.unref(y).length?(e.openBlock(),e.createElementBlock("div",Cf)):e.createCommentVNode("",!0)],2))),128))],34)],512),e.createVNode(cf,{target:k.value,"scroll-container":m.value,enabled:b.value,width:_.value},null,8,["target","scroll-container","enabled","width"])]))}}),vf={class:"relative"},Ef={class:"w-full h-full fixed top-0 start-0 bg-black bg-opacity-50"},Bf={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"},Vf={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},Sf={class:"font-medium text-gray-800 dark:text-[#ffffff]"},$f={class:"p-4 mim-h-0 h-full overflow-auto"},cr=e.defineComponent({__name:"modal-edit",props:{schema:{},defaultValue:{},mode:{},token:{},form:{},api:{},method:{}},emits:["close","save","edit"],setup(o,{emit:t}){const n=o,r=t,l=e.ref(n.schema),a=e.ref(n.defaultValue?JSON.parse(JSON.stringify(n.defaultValue)):{}),s=e.ref({}),i=e.ref(n.token||""),c=e.ref(n.token||""),d=e.ref(n.mode),u=()=>{const b=n.method?.trim().toUpperCase();return b==="GET"||b==="POST"||b==="PUT"?b:d.value==="add"?"POST":"PUT"},p=()=>{pe.notify({type:"success",title:"Успішно",message:`Дані успішно ${d.value==="add"?"збережено":"оновлено"}`})},y=b=>{const _={};b.id!==void 0&&b.id!==null&&(_.id=b.id,c.value=b.id.toString()),b.obj&&typeof b.obj=="object"&&Object.assign(_,b.obj),Object.keys(_).length&&(a.value={...a.value,..._})},k=async b=>{if(console.log(b),b.ok){await b.json().catch(()=>({})),p(),r("save",a.value);return}const _=await b.json().catch(()=>({})),x=_.message||_.error;if(b.status===400){pe.notify({type:"warning",title:"Помилка валідації",message:x||"Некоректні дані (400)"});return}if(b.status===500){pe.notify({type:"error",title:"Серверна помилка",message:x||"Виникла помилка на сервері (500)"});return}pe.notify({type:"error",title:"Помилка",message:`Статус: ${b.status}`})};async function m(){const b=s.value.validate();if(b){pe.notify({type:"warning",title:"Помилка валідації",message:Object.entries(b).map(([x,v])=>`${x}: ${v}`).join(`
5
+ `)});return}d.value==="add"&&a.value&&delete a.value.id;const _=n.api?.trim();if(_){const x=u();try{const v=await fetch(_,{method:x,headers:x==="GET"?void 0:{"Content-Type":"application/json"},body:x==="GET"?void 0:JSON.stringify(a.value)});await k(v)}catch(v){pe.notify({type:"error",title:"Помилка з’єднання",message:v.message||"Не вдалося виконати запит"})}return}if(i.value)try{const x=await fetch(`/api/table/${i.value}`,{method:d.value==="add"?"POST":"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a.value)});await k(x)}catch(x){pe.notify({type:"error",title:"Помилка з’єднання",message:x.message||"Не вдалося виконати запит"})}else r("edit",a.value),h()}function h(){r("close")}return e.onMounted(async()=>{try{if(n.form&&!n.schema){const b=await fetch(`/api/template/form/${n.form}`);if(!b.ok){pe.notify({type:b.status>=400&&b.status<500?"warning":"error",title:"Error",message:`Error code: ${b.status}`});return}const _=await b.json();l.value=_.schema,_.id&&(c.value=_.id),_.token&&(i.value=_.token,c.value||(c.value=_.token))}else if(n.token&&!n.defaultValue){i.value=n.token;const b=await fetch(`/api/form/${i.value}`);if(!b.ok){pe.notify({type:b.status>=400&&b.status<500?"warning":"error",title:"Error",message:`Error code: ${b.status}`});return}const _=await b.json();l.value=_.schema,_.data?a.value=_.data:d.value="add",y({id:_.id,obj:_.obj})}}catch(b){pe.notify({type:"error",title:"Error",message:b.message||"Unexpected error"}),console.error(b)}}),(b,_)=>(e.openBlock(),e.createElementBlock("div",vf,[e.createElementVNode("div",Ef,[e.createElementVNode("div",Bf,[e.createElementVNode("div",Vf,[e.createElementVNode("h3",Sf,e.toDisplayString(d.value==="add"?"Додати":"Змінити"),1),e.createElementVNode("button",{onClick:h,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"},[_[2]||(_[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",$f,[l.value?(e.openBlock(),e.createBlock(ot,{key:0,schema:l.value,values:a.value,"onUpdate:values":_[0]||(_[0]=x=>a.value=x),form:s.value,"onUpdate:form":_[1]||(_[1]=x=>s.value=x),formId:c.value},null,8,["schema","values","form","formId"])):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:"vs-form__head mr-5 mb-5 mt-3 flex items-center justify-end sticky top-0 left-0 z-[60] bg-white"},[e.createElementVNode("button",{type:"button",onClick:h,class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border !border-gray-200 hover:text-white bg-white text-red-500 hover:border-red-500 hover:bg-red-500 focus:ring-red-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1 mr-2"}," Скасувати "),e.createElementVNode("button",{onClick:m,type:"button",class:"vs-button inline-flex border-solid justify-center items-center gap-2 rounded-md font-semibold focus:outline-none text-sm transition-all border-1 border-transparent text-white bg-blue-500 hover:bg-blue-600 focus:ring-blue-500 py-1.5 px-5 focus:ring-1 focus:ring-offset-1"}," Зберегти ")])])])]))}}),Nf=1440*60*1e3,Af=["січень","лютий","березень","квітень","травень","червень","липень","серпень","вересень","жовтень","листопад","грудень"],Ff=["січ","лют","бер","квіт","трав","черв","лип","серп","вер","жовт","лист","груд"],Mf=["нд","пн","вт","ср","чт","пт","сб"];function He(o){return o instanceof Date&&!Number.isNaN(o.getTime())}const jt=o=>new Date(o.getTime());function Rt(o){const t=jt(o);return t.setHours(0,0,0,0),t}function Gt(o){const t=jt(o);return t.setHours(23,59,59,999),t}function ro(o){return Rt(new Date(o.getFullYear(),o.getMonth(),1))}function lo(o){return Gt(new Date(o.getFullYear(),o.getMonth()+1,0))}function ao(o,t){const n=new Date(o),r=n.getDate();n.setDate(1),n.setMonth(n.getMonth()+t);const l=new Date(n.getFullYear(),n.getMonth()+1,0).getDate();return n.setDate(Math.min(r,l)),n}function Df(o,t){return ao(o,-1)}function $n(o,t){const n=new Date(o);return n.setFullYear(n.getFullYear()+t),n}function dr(o,t){return $n(o,-t)}function ur(o){return Rt(new Date(o.getFullYear(),0,1))}function pr(o){return Gt(new Date(o.getFullYear(),11,31))}function Tf(o){const t=Math.floor(o.getFullYear()/10)*10;return Rt(new Date(t,0,1))}function Lf(o){const t=Math.floor(o.getFullYear()/10)*10+9;return Gt(new Date(t,11,31))}const ut=o=>o.getFullYear(),Nn=o=>Math.floor(o.getFullYear()/10)*10;function If(o){const t=[];let n=Rt(o.start);const r=Rt(o.end);for(;n<=r;)t.push(jt(n)),n=new Date(n.getTime()+Nf);return t}function Rf(o){const t=[];let n=ro(o.start);const r=lo(o.end);for(;n<=r;)t.push(jt(n)),n=ao(n,1);return t}function Of(o){const t=[];let n=ur(o.start);const r=pr(o.end);for(;n<=r;)t.push(jt(n)),n=$n(n,1);return t}function so(o,t=1){const n=Rt(o),r=(n.getDay()-t+7)%7;return n.setDate(n.getDate()-r),n}function Pf(o,t=1){const n=so(o,t);return n.setDate(n.getDate()+6),Gt(n)}function zf(o,t,n=0){const r=so(o,n),l=(t-n+7)%7;return r.setDate(r.getDate()+l),r}const An=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth()&&o.getDate()===t.getDate(),io=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear()&&o.getMonth()===t.getMonth(),fr=(o,t)=>!!o&&!!t&&o.getFullYear()===t.getFullYear(),mr=(o,t)=>!!o&&!!t&&An(o,t)&&o.getHours()===t.getHours(),jf=(o,t)=>!!o&&!!t&&mr(o,t)&&o.getMinutes()===t.getMinutes();function Uf(o,t){const n=o.getTime();return n>=t.start.getTime()&&n<=t.end.getTime()}const Yt=(o,t)=>!!o&&!!t&&o.getTime()<t.getTime(),Xt=(o,t)=>!!o&&!!t&&o.getTime()>t.getTime();function Hf(o){const t=o.filter(n=>He(n));if(t.length)return t.reduce((n,r)=>n.getTime()>=r.getTime()?n:r)}function qf(o){const t=o.filter(n=>He(n));if(t.length)return t.reduce((n,r)=>n.getTime()<=r.getTime()?n:r)}function hr(o,t){const n=jt(o);return typeof t.year=="number"&&n.setFullYear(t.year),typeof t.month=="number"&&n.setMonth(t.month),typeof t.date=="number"&&n.setDate(t.date),typeof t.hours=="number"&&n.setHours(t.hours),typeof t.minutes=="number"&&n.setMinutes(t.minutes),typeof t.seconds=="number"&&n.setSeconds(t.seconds),typeof t.milliseconds=="number"&&n.setMilliseconds(t.milliseconds),n}const Fn=(o,t=2)=>String(o).padStart(t,"0");function gr(o,t){return t==="wide"?Af[o]:Ff[o]}function Kf(o){return Mf[o]}const Wf=[{token:"LLLL",format:o=>gr(o.getMonth(),"wide")},{token:"LLL",format:o=>gr(o.getMonth(),"abbreviated")},{token:"EE",format:o=>Kf(o.getDay())},{token:"yyyy",format:o=>String(o.getFullYear())},{token:"MM",format:o=>Fn(o.getMonth()+1)},{token:"dd",format:o=>Fn(o.getDate())},{token:"HH",format:o=>Fn(o.getHours())},{token:"mm",format:o=>Fn(o.getMinutes())}];function Mn(o,t){if(!He(o))return"";let n="",r=0;for(;r<t.length;){const l=Wf.find(a=>t.startsWith(a.token,r));l?(n+=l.format(o),r+=l.token.length):(n+=t[r],r+=1)}return n}const Gf={"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 yr(o,t){const n=Gf[t];if(!n){const l=new Date(o);return He(l)?l:null}const r=o.match(n);if(!r)return null;switch(t){case"yyyy-MM-dd":{const[,l,a,s]=r,i=new Date(Number(l),Number(a)-1,Number(s));return He(i)?i:null}case"dd.MM.yyyy":{const[,l,a,s]=r,i=new Date(Number(s),Number(a)-1,Number(l));return He(i)?i:null}case"dd.MM.yyyy HH:mm":{const[,l,a,s,i,c]=r,d=new Date(Number(s),Number(a)-1,Number(l),Number(i),Number(c));return He(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 Yf=["year","month","day","time","custom"],Xf=e.defineComponent({components:{ChevronLeft:q.ChevronLeft,ChevronRight:q.ChevronRight},emits:{elementClick:o=>He(o),left:()=>!0,right:()=>!0,heading:()=>!0},props:{headingClickable:{type:Boolean,default:!1},leftDisabled:{type:Boolean,default:!1},rightDisabled:{type:Boolean,default:!1},columnCount:{type:Number,default:7},items:{type:Array,default:()=>[]},viewMode:{type:String,required:!0,validate:o=>typeof o=="string"&&Yf.includes(o)}}}),Zf={class:"v3dp__heading"},Jf=["disabled"],Qf=["disabled"],em={class:"v3dp__body"},tm={class:"v3dp__subheading"},nm={class:"v3dp__elements"},om=["disabled","onClick"];function rm(o,t,n,r,l,a){const s=e.resolveComponent("ChevronLeft"),i=e.resolveComponent("ChevronRight");return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["v3dp__popout",`v3dp__popout-${o.viewMode}`]),style:e.normalizeStyle({"--popout-column-definition":`repeat(${o.columnCount}, 1fr)`}),onMousedown:t[3]||(t[3]=e.withModifiers(()=>{},["prevent"]))},[e.createElementVNode("div",Zf,[e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__left",disabled:o.leftDisabled,onClick:t[0]||(t[0]=e.withModifiers(c=>o.$emit("left"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-left",{},()=>[e.createVNode(s,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,Jf),(e.openBlock(),e.createBlock(e.resolveDynamicComponent(o.headingClickable?"button":"span"),{class:"v3dp__heading__center",onClick:t[1]||(t[1]=e.withModifiers(c=>o.$emit("heading"),["stop","prevent"]))},{default:e.withCtx(()=>[e.renderSlot(o.$slots,"heading",{},void 0,!0)]),_:3})),e.createElementVNode("button",{class:"v3dp__heading__button v3dp__heading__button__right",disabled:o.rightDisabled,onClick:t[2]||(t[2]=e.withModifiers(c=>o.$emit("right"),["stop","prevent"]))},[e.renderSlot(o.$slots,"arrow-right",{},()=>[e.createVNode(i,{class:"v3dp__heading__icon h-4 w-4"})],!0)],8,Qf)]),e.createElementVNode("div",em,["subheading"in o.$slots?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createElementVNode("div",tm,[e.renderSlot(o.$slots,"subheading",{},void 0,!0)]),t[4]||(t[4]=e.createElementVNode("hr",{class:"v3dp__divider"},null,-1))],64)):e.createCommentVNode("",!0),e.createElementVNode("div",nm,[e.renderSlot(o.$slots,"body",{},()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.items,c=>(e.openBlock(),e.createElementBlock("button",{key:c.key,disabled:c.disabled,class:e.normalizeClass([{selected:c.selected,current:c.current},`v3dp__element__button__${o.viewMode}`]),onClick:e.withModifiers(d=>o.$emit("elementClick",c.value),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(c.display),1)],10,om))),128))],!0)])])],38)}const Dn=xe(Xf,[["render",rm],["__scopeId","data-v-111981fe"]]),lm=e.defineComponent({components:{PickerPopup:Dn},emits:{"update:pageDate":o=>He(o),select:o=>He(o)},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>Tf(o.pageDate)),r=e.computed(()=>Lf(o.pageDate)),l=(p,y,k)=>!y&&!k?!0:!(y&&ut(p)<ut(y)||k&&ut(p)>ut(k)),a=e.computed(()=>Of({start:n.value,end:r.value}).map(p=>({value:p,key:String(ut(p)),display:ut(p),selected:!!o.selected&&ut(p)===ut(o.selected),disabled:!l(p,o.lowerLimit,o.upperLimit)}))),s=e.computed(()=>{const p=ut(n.value),y=ut(r.value);return`${p} - ${y}`}),i=e.computed(()=>o.lowerLimit&&(Nn(o.lowerLimit)===Nn(o.pageDate)||Yt(o.pageDate,o.lowerLimit))),c=e.computed(()=>o.upperLimit&&(Nn(o.upperLimit)===Nn(o.pageDate)||Xt(o.pageDate,o.upperLimit)));return{years:a,heading:s,leftDisabled:i,rightDisabled:c,previousPage:()=>t("update:pageDate",dr(o.pageDate,10)),nextPage:()=>t("update:pageDate",$n(o.pageDate,10))}}});function am(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{columnCount:3,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.years,viewMode:"year",onLeft:o.previousPage,onRight:o.nextPage,onElementClick:t[0]||(t[0]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const sm=xe(lm,[["render",am]]),im=e.defineComponent({components:{PickerPopup:Dn},emits:{"update:pageDate":o=>He(o),select:o=>He(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"LLL"},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1}},setup(o,{emit:t}){const n=e.computed(()=>ur(o.pageDate)),r=e.computed(()=>pr(o.pageDate)),l=e.computed(()=>y=>Mn(y,o.format)),a=(y,k,m)=>!k&&!m?!0:!(k&&Yt(y,ro(k))||m&&Xt(y,lo(m))),s=e.computed(()=>Rf({start:n.value,end:r.value}).map(y=>({value:y,display:l.value(y),key:l.value(y),selected:!!o.selected&&io(o.selected,y),disabled:!a(y,o.lowerLimit,o.upperLimit)}))),i=e.computed(()=>ut(n.value)),c=e.computed(()=>o.lowerLimit&&(fr(o.lowerLimit,o.pageDate)||Yt(o.pageDate,o.lowerLimit))),d=e.computed(()=>o.upperLimit&&(fr(o.upperLimit,o.pageDate)||Xt(o.pageDate,o.upperLimit)));return{months:s,heading:i,leftDisabled:c,rightDisabled:d,previousPage:()=>t("update:pageDate",dr(o.pageDate,1)),nextPage:()=>t("update:pageDate",$n(o.pageDate,1))}}});function cm(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:3,items:o.months,leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,viewMode:"month",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=i=>o.$emit("back")),onElementClick:t[1]||(t[1]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),_:1},8,["items","leftDisabled","rightDisabled","onLeft","onRight"])}const dm=xe(im,[["render",cm]]),um=e.defineComponent({components:{PickerPopup:Dn},emits:{"update:pageDate":o=>He(o),select:o=>He(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},format:{type:String,required:!1,default:"dd"},headingFormat:{type:String,required:!1,default:"LLLL yyyy"},weekdayFormat:{type:String,required:!1,default:"EE"},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>typeof o=="number"&&Number.isInteger(o)&&o>=0&&o<=6},customWeekdays:{type:Array,required:!1},lowerLimit:{type:Date,required:!1},upperLimit:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1}},setup(o,{emit:t}){const n=e.computed(()=>b=>_=>Mn(_,b)),r=e.computed(()=>ro(o.pageDate)),l=e.computed(()=>lo(o.pageDate)),a=e.computed(()=>({start:r.value,end:l.value})),s=e.computed(()=>({start:so(r.value,o.weekStartsOn),end:Pf(l.value,o.weekStartsOn)})),i=e.computed(()=>o.customWeekdays?.length===7?o.customWeekdays:null),c=e.computed(()=>{const b=o.weekStartsOn,_=i.value;if(_)return Array.from({length:7}).map((v,N)=>_[(b+N)%7]);const x=n.value(o.weekdayFormat);return Array.from(Array(7)).map((v,N)=>(b+N)%7).map(v=>zf(new Date,v,o.weekStartsOn)).map(x)}),d=(b,_,x,v)=>v?.dates?.some(N=>An(b,N))||v?.predicate?.(b)?!1:!_&&!x?!0:!(_&&Yt(b,Rt(_))||x&&Xt(b,Gt(x))),u=e.computed(()=>{const b=new Date,_=n.value(o.format);return If(s.value).map(x=>({value:x,display:_(x),selected:!!o.selected&&An(o.selected,x),current:An(b,x),disabled:!o.allowOutsideInterval&&!Uf(x,a.value)||!d(x,o.lowerLimit,o.upperLimit,o.disabledDates),key:n.value("yyyy-MM-dd")(x)}))}),p=e.computed(()=>n.value(o.headingFormat)(o.pageDate)),y=e.computed(()=>o.lowerLimit&&(io(o.lowerLimit,o.pageDate)||Yt(o.pageDate,o.lowerLimit))),k=e.computed(()=>o.upperLimit&&(io(o.upperLimit,o.pageDate)||Xt(o.pageDate,o.upperLimit)));return{weekDays:c,days:u,heading:p,leftDisabled:y,rightDisabled:k,previousPage:()=>t("update:pageDate",Df(o.pageDate)),nextPage:()=>t("update:pageDate",ao(o.pageDate,1))}}});function pm(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",leftDisabled:o.leftDisabled,rightDisabled:o.rightDisabled,items:o.days,viewMode:"day",onLeft:o.previousPage,onRight:o.nextPage,onHeading:t[0]||(t[0]=i=>o.$emit("back")),onElementClick:t[1]||(t[1]=i=>o.$emit("select",i))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.heading),1)]),subheading:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.weekDays,(i,c)=>(e.openBlock(),e.createElementBlock("span",{key:i,class:e.normalizeClass(`v3dp__subheading__weekday__${c}`)},e.toDisplayString(i),3))),128))]),_:1},8,["leftDisabled","rightDisabled","items","onLeft","onRight"])}const fm=xe(um,[["render",pm]]);function br(o,t){const n=o.getBoundingClientRect(),r={height:o.clientHeight,width:o.clientWidth},l=t.getBoundingClientRect();if(!(l.top>=n.top&&l.bottom<=n.top+r.height)){const s=l.top-n.top,i=l.bottom-n.bottom;Math.abs(s)<Math.abs(i)?o.scrollTop+=s:o.scrollTop+=i}}const mm=e.defineComponent({components:{PickerPopup:Dn},emits:{select:o=>He(o),back:()=>!0},props:{selected:{type:Date,required:!1},pageDate:{type:Date,required:!0},visible:{type:Boolean,required:!0},disabledTime:{type:Object,required:!1}},setup(o,{emit:t}){const n=e.ref(null),r=e.ref(null),l=e.computed(()=>o.pageDate??o.selected),a=e.ref(l.value.getHours()),s=e.ref(l.value.getMinutes());e.watch(()=>o.selected,k=>{let m=0,h=0;k&&(m=k.getHours(),h=k.getMinutes()),a.value=m,s.value=h});const i=e.computed(()=>[...Array(24).keys()].map(k=>({value:k,date:hr(new Date(l.value.getTime()),{hours:k,minutes:s.value,seconds:0}),selected:a.value===k,ref:e.ref(null)}))),c=e.computed(()=>[...Array(60).keys()].map(k=>({value:k,date:hr(new Date(l.value.getTime()),{hours:a.value,minutes:k,seconds:0}),selected:s.value===k,ref:e.ref(null)}))),d=k=>{s.value=k.value,t("select",k.date)},u=()=>{const k=i.value.find(h=>h.ref.value?.classList?.contains("selected")??!1),m=c.value.find(h=>h.ref.value?.classList?.contains("selected")??!1);k&&m&&(br(n.value,k.ref.value),br(r.value,m.ref.value))};return e.watch(()=>o.visible,k=>{k&&e.nextTick(u)}),{hoursListRef:n,minutesListRef:r,hours:a,minutes:s,hoursList:i,minutesList:c,padStartZero:k=>`0${k}`.substr(-2),selectMinutes:d,isEnabled:k=>!(o.disabledTime?.dates?.some(m=>mr(k,m)&&jf(k,m))||o.disabledTime?.predicate?.(k)),scroll:u}}}),hm={ref:"hoursListRef",class:"v3dp__column"},gm=["disabled","onClick"],ym={ref:"minutesListRef",class:"v3dp__column"},bm=["disabled","onClick"];function km(o,t,n,r,l,a){const s=e.resolveComponent("picker-popup");return e.openBlock(),e.createBlock(s,{headingClickable:"",columnCount:2,leftDisabled:!0,rightDisabled:!0,viewMode:"time",onHeading:t[0]||(t[0]=i=>o.$emit("back"))},{heading:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(o.padStartZero(o.hours))+":"+e.toDisplayString(o.padStartZero(o.minutes)),1)]),body:e.withCtx(()=>[e.createElementVNode("div",hm,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.hoursList,i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,ref_for:!0,ref:i.ref,class:e.normalizeClass([{selected:i.selected},"v3dp__element_button__hour"]),disabled:!o.isEnabled(i.date),onClick:e.withModifiers(c=>o.hours=i.value,["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(o.padStartZero(i.value)),1)],10,gm))),128))],512),e.createElementVNode("div",ym,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.minutesList,i=>(e.openBlock(),e.createElementBlock("button",{key:i.value,ref_for:!0,ref:i.ref,class:e.normalizeClass([{selected:i.selected},"v3dp__element_button__minute"]),disabled:!o.isEnabled(i.date),onClick:e.withModifiers(c=>o.selectMinutes(i),["stop","prevent"])},[e.createElementVNode("span",null,e.toDisplayString(o.padStartZero(i.value)),1)],10,bm))),128))],512)]),_:1})}const xm=xe(mm,[["render",km],["__scopeId","data-v-610b89e1"]]),Tn=["time","day","month","year"],wm=(o,t,n=void 0)=>{let r=n||new Date;const l=Hf([o,r]);l&&(r=l);const a=qf([t,r]);return a&&(r=a),r},_m=e.defineComponent({components:{YearPicker:sm,MonthPicker:dm,DayPicker:fm,TimePicker:xm},inheritAttrs:!1,props:{placeholder:{type:String,default:""},modelValue:{type:Date,required:!1},disabledDates:{type:Object,required:!1},allowOutsideInterval:{type:Boolean,required:!1,default:!1},disabledTime:{type:Object,required:!1},upperLimit:{type:Date,required:!1},lowerLimit:{type:Date,required:!1},startingView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Tn.includes(o)},startingViewDate:{type:Date,required:!1,default:()=>new Date},dayPickerHeadingFormat:{type:String,required:!1,default:"LLLL yyyy"},monthListFormat:{type:String,required:!1,default:"LLL"},weekdayFormat:{type:String,required:!1,default:"EE"},dayFormat:{type:String,required:!1,default:"dd"},inputFormat:{type:String,required:!1,default:"yyyy-MM-dd"},weekDayNames:{type:Array,required:!1},weekStartsOn:{type:Number,required:!1,default:1,validator:o=>[0,1,2,3,4,5,6].includes(o)},disabled:{type:Boolean,required:!1,default:!1},clearable:{type:Boolean,required:!1,default:!1},typeable:{type:Boolean,required:!1,default:!1},minimumView:{type:String,required:!1,default:"day",validate:o=>typeof o=="string"&&Tn.includes(o)}},emits:{"update:modelValue":o=>o==null||He(o),decadePageChanged:o=>!0,yearPageChanged:o=>!0,monthPageChanged:o=>!0,opened:()=>!0,closed:()=>!0},setup(o,{emit:t,attrs:n}){const r=e.ref("none"),l=e.ref(o.startingViewDate),a=e.ref(null),s=e.ref(!1),i=e.ref({}),c=e.ref(""),d=I=>{const X=I.replace(/[a-zA-Z]/g,"0");return/0/.test(X)?X:""},u=e.computed(()=>d(o.inputFormat));let p=null,y=null;const k=()=>{p?.destroy(),p=null},m=async()=>{if(!y){const{default:I}=await Promise.resolve().then(()=>Pn);y=I}return y},h=()=>{p&&p.value!==c.value&&(p.value=c.value??"")},b=async()=>{if(k(),!a.value||!u.value)return;p=(await m())(a.value,{mask:u.value,lazy:!0,overwrite:!0}),h()};e.watchEffect(()=>{if(!c.value)return;const I=yr(c.value,o.inputFormat);I&&(l.value=I)}),e.watchEffect(()=>{c.value=o.modelValue&&He(o.modelValue)?Mn(o.modelValue,o.inputFormat):""}),e.onMounted(()=>{u.value&&e.nextTick(()=>{b()})}),e.onBeforeUnmount(()=>{k()}),e.watch(u,I=>{I?e.nextTick(()=>{b()}):k()}),e.watch(c,()=>{h()});const _=(I="none")=>{o.disabled||(I!=="none"&&r.value==="none"&&(l.value=o.modelValue||wm(o.lowerLimit,o.upperLimit,l.value)),r.value=I,I!=="none"?(e.nextTick(()=>T()),t("opened")):t("closed"))};e.watchEffect(()=>{o.disabled&&(r.value="none")});const x=(I,X)=>{l.value=X,I==="year"?t("decadePageChanged",X):I==="month"?t("yearPageChanged",X):I==="day"&&t("monthPageChanged",X)},v=I=>{l.value=I,o.minimumView==="year"?(_("none"),t("update:modelValue",I)):r.value="month"},N=I=>{l.value=I,o.minimumView==="month"?(_("none"),t("update:modelValue",I)):r.value="day"},U=I=>{l.value=I,o.minimumView==="day"?(_("none"),t("update:modelValue",I)):r.value="time"},W=I=>{_("none"),t("update:modelValue",I)},L=()=>{o.clearable&&(_("none"),t("update:modelValue",null),l.value=o.startingViewDate)},B=()=>s.value=!0,S=()=>_(M.value),$=()=>{s.value=!1,_()},V=I=>{const X=I.keyCode?I.keyCode:I.which;if([27,13].includes(X)&&a.value.blur(),o.typeable){const ke=yr(a.value.value,o.inputFormat);ke&&c.value===Mn(ke,o.inputFormat)&&(c.value=a.value.value,t("update:modelValue",ke))}},M=e.computed(()=>{const I=Tn.indexOf(o.startingView),X=Tn.indexOf(o.minimumView);return I<X?o.minimumView:o.startingView}),O=I=>Object.fromEntries(Object.entries(I??{}).filter(([X,Q])=>X.startsWith("--"))),E=e.computed(()=>o.weekDayNames?.length===7?o.weekDayNames:void 0),K=()=>o.startingView==="time"&&o.minimumView==="time"?null:r.value="day",T=()=>{if(!a.value)return;const I=a.value.getBoundingClientRect();i.value={position:"fixed",top:`${Math.round(I.bottom+4)}px`,left:`${Math.round(I.left)}px`,zIndex:"100100"}},Y=()=>{r.value!=="none"&&T()};return e.onMounted(()=>{window.addEventListener("resize",Y),window.addEventListener("scroll",Y,!0)}),e.onBeforeUnmount(()=>{window.removeEventListener("resize",Y),window.removeEventListener("scroll",Y,!0)}),{blur:$,focus:S,click:B,input:c,inputRef:a,pageDate:l,renderView:_,updatePageDate:x,selectYear:v,selectMonth:N,selectDay:U,selectTime:W,keyUp:V,normalizedWeekdayNames:E,viewShown:r,goBackFromTimepicker:K,clearModelValue:L,initialView:M,log:I=>console.log(I),variables:O,popupAnchorStyle:i}}}),Cm={class:"v3dp__input_wrapper"},vm=["readonly","placeholder","disabled","tabindex"],Em={class:"v3dp__clearable"};function Bm(o,t,n,r,l,a){const s=e.resolveComponent("year-picker"),i=e.resolveComponent("month-picker"),c=e.resolveComponent("day-picker"),d=e.resolveComponent("time-picker");return e.openBlock(),e.createElementBlock("div",{class:"v3dp__datepicker v3dp__theme_vars",style:e.normalizeStyle(o.variables(o.$attrs.style))},[e.createElementVNode("div",Cm,[e.withDirectives(e.createElementVNode("input",e.mergeProps({type:"text",ref:"inputRef",readonly:!o.typeable,"onUpdate:modelValue":t[0]||(t[0]=u=>o.input=u)},o.$attrs,{placeholder:o.placeholder,disabled:o.disabled,tabindex:o.disabled?-1:0,onKeyup:t[1]||(t[1]=(...u)=>o.keyUp&&o.keyUp(...u)),onBlur:t[2]||(t[2]=(...u)=>o.blur&&o.blur(...u)),onFocus:t[3]||(t[3]=(...u)=>o.focus&&o.focus(...u)),onClick:t[4]||(t[4]=(...u)=>o.click&&o.click(...u))}),null,16,vm),[[e.vModelText,o.input]]),e.withDirectives(e.createElementVNode("div",Em,[e.renderSlot(o.$slots,"clear",{onClear:o.clearModelValue},()=>[e.createElementVNode("i",{onClick:t[5]||(t[5]=u=>o.clearModelValue())},"x")])],512),[[e.vShow,o.clearable&&o.modelValue]])]),(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.withDirectives(e.createElementVNode("div",{style:e.normalizeStyle({...o.variables(o.$attrs.style),...o.popupAnchorStyle}),class:"v3dp__popup_anchor v3dp__theme_vars"},[e.withDirectives(e.createVNode(s,{pageDate:o.pageDate,"onUpdate:pageDate":t[6]||(t[6]=u=>o.updatePageDate("year",u)),selected:o.modelValue,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,onSelect:o.selectYear},null,8,["pageDate","selected","lowerLimit","upperLimit","onSelect"]),[[e.vShow,o.viewShown==="year"]]),e.withDirectives(e.createVNode(i,{pageDate:o.pageDate,"onUpdate:pageDate":t[7]||(t[7]=u=>o.updatePageDate("month",u)),selected:o.modelValue,onSelect:o.selectMonth,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,format:o.monthListFormat,onBack:t[8]||(t[8]=u=>o.viewShown="year")},null,8,["pageDate","selected","onSelect","lowerLimit","upperLimit","format"]),[[e.vShow,o.viewShown==="month"]]),e.withDirectives(e.createVNode(c,{pageDate:o.pageDate,"onUpdate:pageDate":t[9]||(t[9]=u=>o.updatePageDate("day",u)),selected:o.modelValue,weekStartsOn:o.weekStartsOn,lowerLimit:o.lowerLimit,upperLimit:o.upperLimit,headingFormat:o.dayPickerHeadingFormat,disabledDates:o.disabledDates,weekdayFormat:o.weekdayFormat,"allow-outside-interval":o.allowOutsideInterval,format:o.dayFormat,"custom-weekdays":o.normalizedWeekdayNames,onSelect:o.selectDay,onBack:t[10]||(t[10]=u=>o.viewShown="month")},null,8,["pageDate","selected","weekStartsOn","lowerLimit","upperLimit","headingFormat","disabledDates","weekdayFormat","allow-outside-interval","format","custom-weekdays","onSelect"]),[[e.vShow,o.viewShown==="day"]]),e.withDirectives(e.createVNode(d,{pageDate:o.pageDate,visible:o.viewShown==="time",selected:o.modelValue,disabledTime:o.disabledTime,onSelect:o.selectTime,onBack:o.goBackFromTimepicker},null,8,["pageDate","visible","selected","disabledTime","onSelect","onBack"]),[[e.vShow,o.viewShown==="time"]])],4),[[e.vShow,o.viewShown!=="none"]])]))],4)}const Vm=xe(_m,[["render",Bm]]),Sm=xe(e.defineComponent({__name:"vs-input-date2",props:{clearable:{type:Boolean,default:!0},now:{type:Boolean},editable:{type:Boolean,default:!0},time:{type:Boolean},isInfinity:{type:Boolean},mode:{default:"date"},weekStart:{},dayNames:{},style:{default:()=>({})},customClass:{default:""},disabled:{type:Boolean,default:!1},modelValue:{},error:{default:""},name:{},placeholder:{default:""},maxlength:{},minlength:{}},emits:["update:modelValue"],setup(o,{emit:t}){const n=o,r=t,{inputClass:l}=Ue(n.style),a=e.computed(()=>n.mode?n.mode:n.time?"datetime":"date"),s={date:"дд.мм.рррр",datetime:"дд.мм.рррр гг:хх",month:"мм.рррр",week:"рррр-тиждень",time:"гг:хх",year:"рррр"},i=e.computed(()=>n.placeholder||s[a.value]||""),c=e.computed(()=>["py-1.5 px-3 block w-full placeholder:text-[#767f8f] bg-white",l.value,n.customClass,{"!border-red-600":n.error}]),d=e.computed(()=>!n.modelValue&&n.now?new Date:null),u=e.computed({get:()=>v(n.modelValue??d.value,a.value)||void 0,set:T=>r("update:modelValue",N(T,a.value))}),p=["Пн","Вт","Ср","Чт","Пт","Сб","Нд"],y=e.computed(()=>{if(n.dayNames?.length)return n.dayNames.length===7?n.dayNames:p}),k=e.computed(()=>{const T=n.weekStart,Y=typeof T=="string"?Number(T):T;return Y===void 0||Number.isNaN(Y)?1:Math.min(6,Math.max(0,Y))}),m=e.computed(()=>{switch(a.value){case"time":return{startingView:"time",minimumView:"time"};case"month":return{startingView:"month",minimumView:"month"};case"year":return{startingView:"year",minimumView:"year"};case"datetime":return{startingView:"day",minimumView:"time"};default:return{startingView:"day",minimumView:"day"}}}),h={date:"dd.MM.yyyy",datetime:"dd.MM.yyyy HH:mm",month:"MM.yyyy",time:"HH:mm",week:"dd.MM.yyyy",year:"yyyy"},b=e.computed(()=>h[a.value]||"dd.MM.yyyy"),_=e.computed(()=>({"--vdp-selected-bg-color":n.style?.primaryColor||"#2563eb","--vdp-hover-bg-color":n.style?.primaryColor||"#2563eb","--vdp-selected-color":"#ffffff","--vdp-hover-color":"#ffffff","--vdp-border-radius":n.style?.size==="sm"?"6px":"8px","--vdp-elem-font-size":n.style?.size==="sm"?"0.75em":"0.85em"})),x=e.ref(!1);e.watch(()=>n.modelValue,T=>{T?x.value=!0:n.now||(x.value=!1)},{immediate:!0}),e.watchEffect(()=>{n.now&&!n.modelValue&&!x.value&&(r("update:modelValue",N(new Date,a.value)),x.value=!0)});function v(T,Y){if(!T)return null;if(T instanceof Date&&!Number.isNaN(T.getTime()))return T;if(typeof T!="string")return null;switch(Y){case"datetime":return B(T);case"time":return V(T);case"month":return S(T);case"year":return $(T);case"week":return M(T);case"date":default:return L(T)}}function N(T,Y){if(!T)return null;const I=T instanceof Date?T:v(T,Y);if(!I)return null;switch(Y){case"datetime":return`${U(I)}T${W(I)}`;case"time":return W(I);case"month":return`${I.getFullYear()}-${K(I.getMonth()+1)}`;case"year":return`${I.getFullYear()}`;case"week":{const{year:X,week:Q}=O(I);return`${X}-W${K(Q)}`}case"date":default:return U(I)}}function U(T){return`${T.getFullYear()}-${K(T.getMonth()+1)}-${K(T.getDate())}`}function W(T){return`${K(T.getHours())}:${K(T.getMinutes())}`}function L(T){const Y=T.split("-");if(Y.length<3)return null;const[I,X,Q]=Y.map(Number);return!I||!X||!Q?null:new Date(I,X-1,Q)}function B(T){const Y=T.includes("T")?T:T.replace(" ","T"),I=new Date(Y);return Number.isNaN(I.getTime())?null:I}function S(T){const[Y,I]=T.split("-").map(Number);return!Y||Number.isNaN(I)?null:new Date(Y,(I||1)-1,1)}function $(T){const Y=Number(T);return Y?new Date(Y,0,1):null}function V(T){const Y=T.match(/^(\d{1,2}):(\d{2})$/);if(!Y)return null;const[,I,X]=Y,Q=new Date;return Q.setHours(Number(I),Number(X),0,0),Q}function M(T){const Y=T.match(/^(\d{4})-W(\d{2})$/);if(!Y)return null;const[,I,X]=Y,Q=Number(X);return E(Number(I),Q)}function O(T){const Y=new Date(Date.UTC(T.getFullYear(),T.getMonth(),T.getDate())),I=Y.getUTCDay()||7;Y.setUTCDate(Y.getUTCDate()+4-I);const X=new Date(Date.UTC(Y.getUTCFullYear(),0,1)),Q=Math.ceil(((Y.getTime()-X.getTime())/864e5+1)/7);return{year:Y.getUTCFullYear(),week:Q}}function E(T,Y){if(!T||!Y)return null;const I=new Date(T,0,1+(Y-1)*7),X=I.getDay(),Q=I;return X<=4?Q.setDate(I.getDate()-I.getDay()+1):Q.setDate(I.getDate()+8-I.getDay()),Q}function K(T){return String(T).padStart(2,"0")}return(T,Y)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["vs-date-picker",n.customClass]),style:e.normalizeStyle(_.value)},[e.createVNode(Vm,{modelValue:u.value,"onUpdate:modelValue":Y[0]||(Y[0]=I=>u.value=I),style:e.normalizeStyle(_.value),placeholder:i.value,disabled:n.disabled,clearable:n.clearable,typeable:n.editable,"week-day-names":y.value,"week-starts-on":k.value,"starting-view":m.value.startingView,"minimum-view":m.value.minimumView,"input-format":b.value,name:n.name,class:e.normalizeClass(c.value)},null,8,["modelValue","style","placeholder","disabled","clearable","typeable","week-day-names","week-starts-on","starting-view","minimum-view","input-format","name","class"])],6))}}),[["__scopeId","data-v-f292c667"]]),$m={form:{richtext:{paragraph:"Paragraph",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3",heading4:"Heading 4",heading5:"Heading 5",heading6:"Heading 6",createTable:"Create Table",addColumn:"Add Column",addRow:"Add Row",deleteColumn:"Delete Column",deleteRow:"Delete Row",deleteTable:"Delete Table",mergeCells:"Merge Cells",splitCells:"Split Cells",linkTitle:"Enter Link",link:"Link",linkUrl:"Enter URL",editLink:"Edit Link",openLink:"Open Link",removeLink:"Remove Link",openInNewTab:"Open in New Tab",editor:"Editor",html:"HTML",markdown:"Markdown",create:"Create",update:"Update",cancel:"Cancel"}}},Nm={form:{richtext:{paragraph:"Звичайний текст",heading1:"Заголовок 1",heading2:"Заголовок 2",heading3:"Заголовок 3",heading4:"Заголовок 4",heading5:"Заголовок 5",heading6:"Заголовок 6",createTable:"Створити таблицю",addColumn:"Додати колонку",addRow:"Додати рядок",deleteColumn:"Видалити колонку",deleteRow:"Видалити рядок",deleteTable:"Видалити таблицю",mergeCells:"Об'єднати комірки",splitCells:"Розділити комірки",linkTitle:"Додати посилання",link:"Посилання",linkUrl:"Введіть URL",editLink:"Редагувати посилання",openLink:"Відкрити посилання",removeLink:"Видалити посилання",openInNewTab:"Відкривати в новій вкладці",editor:"Редактор",html:"HTML",markdown:"Markdown",create:"Створити",update:"Оновити",cancel:"Скасувати"}}},kr=$m.form.richtext,xr=Nm.form.richtext,co={en:{form:{richtext:kr}},uk:{form:{richtext:xr}}},wr=(o={mode:"edit",schema:null})=>new Promise(t=>{const{close:n}=pe.modal({title:o.mode==="add"?"Додати":"Редагувати",template:"",visible:!0,size:"medium",closeClickBack:!0,content:cr,contentProps:{...o,onClose:()=>{t(null),n()},onSave:r=>{t(r),n()}}})});ot.install=function(t){t.component("VForm",ot),Object.assign(t.config.globalProperties,{$form:wr}),t.provide("form",wr),window.v3plugin||(window.v3plugin={})};function St(o){return typeof o=="string"||o instanceof String}function _r(o){var t;return typeof o=="object"&&o!=null&&(o==null||(t=o.constructor)==null?void 0:t.name)==="Object"}function Cr(o,t){return Array.isArray(t)?Cr(o,(n,r)=>t.includes(r)):Object.entries(o).reduce((n,r)=>{let[l,a]=r;return t(a,l)&&(n[l]=a),n},{})}const ue={NONE:"NONE",LEFT:"LEFT",FORCE_LEFT:"FORCE_LEFT",RIGHT:"RIGHT",FORCE_RIGHT:"FORCE_RIGHT"};function vr(o){switch(o){case ue.LEFT:return ue.FORCE_LEFT;case ue.RIGHT:return ue.FORCE_RIGHT;default:return o}}function uo(o){return o.replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")}function Ln(o,t){if(t===o)return!0;const n=Array.isArray(t),r=Array.isArray(o);let l;if(n&&r){if(t.length!=o.length)return!1;for(l=0;l<t.length;l++)if(!Ln(t[l],o[l]))return!1;return!0}if(n!=r)return!1;if(t&&o&&typeof t=="object"&&typeof o=="object"){const a=t instanceof Date,s=o instanceof Date;if(a&&s)return t.getTime()==o.getTime();if(a!=s)return!1;const i=t instanceof RegExp,c=o instanceof RegExp;if(i&&c)return t.toString()==o.toString();if(i!=c)return!1;const d=Object.keys(t);for(l=0;l<d.length;l++)if(!Object.prototype.hasOwnProperty.call(o,d[l]))return!1;for(l=0;l<d.length;l++)if(!Ln(o[d[l]],t[d[l]]))return!1;return!0}else if(t&&o&&typeof t=="function"&&typeof o=="function")return t.toString()===o.toString();return!1}class Am{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?ue.NONE:(this.oldSelection.end===this.cursorPos||this.oldSelection.start===this.cursorPos)&&this.oldSelection.end===this.oldSelection.start?ue.RIGHT:ue.LEFT}}function be(o,t){return new be.InputMask(o,t)}function Er(o){if(o==null)throw new Error("mask property should be defined");return o instanceof RegExp?be.MaskedRegExp:St(o)?be.MaskedPattern:o===Date?be.MaskedDate:o===Number?be.MaskedNumber:Array.isArray(o)||o===Array?be.MaskedDynamic:be.Masked&&o.prototype instanceof be.Masked?o:be.Masked&&o instanceof be.Masked?o.constructor:o instanceof Function?be.MaskedFunction:(console.warn("Mask not found for mask",o),be.Masked)}function Ut(o){if(!o)throw new Error("Options in not defined");if(be.Masked){if(o.prototype instanceof be.Masked)return{mask:o};const{mask:t=void 0,...n}=o instanceof be.Masked?{mask:o}:_r(o)&&o.mask instanceof be.Masked?o:{};if(t){const r=t.mask;return{...Cr(t,(l,a)=>!a.startsWith("_")),mask:t.constructor,_mask:r,...n}}}return _r(o)?{...o}:{mask:o}}function ht(o){if(be.Masked&&o instanceof be.Masked)return o;const t=Ut(o),n=Er(t.mask);if(!n)throw new Error("Masked class is not found for provided mask "+t.mask+", appropriate module needs to be imported manually before creating mask.");return t.mask===n&&delete t.mask,t._mask&&(t.mask=t._mask,delete t._mask),new n(t)}be.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,n){if(!(t==null||n==null||t===this.selectionStart&&n===this.selectionEnd))try{this._unsafeSelect(t,n)}catch{}}get isActive(){return!1}}be.MaskElement=In;const Br=90,Fm=89;class Zt 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,n,r;return(t=(n=(r=this.input).getRootNode)==null?void 0:n.call(r))!=null?t:document}get isActive(){return this.input===this.rootElement.activeElement}bindEvents(t){this.input.addEventListener("keydown",this._onKeydown),this.input.addEventListener("input",this._onInput),this.input.addEventListener("beforeinput",this._onBeforeinput),this.input.addEventListener("compositionend",this._onCompositionEnd),this.input.addEventListener("drop",t.drop),this.input.addEventListener("click",t.click),this.input.addEventListener("focus",t.focus),this.input.addEventListener("blur",t.commit),this._handlers=t}_onKeydown(t){if(this._handlers.redo&&(t.keyCode===Br&&t.shiftKey&&(t.metaKey||t.ctrlKey)||t.keyCode===Fm&&t.ctrlKey))return t.preventDefault(),this._handlers.redo(t);if(this._handlers.undo&&t.keyCode===Br&&(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={}}}be.HTMLMaskElement=Zt;class Vr extends Zt{constructor(t){super(t),this.input=t}get _unsafeSelectionStart(){return this.input.selectionStart!=null?this.input.selectionStart:this.value.length}get _unsafeSelectionEnd(){return this.input.selectionEnd}_unsafeSelect(t,n){this.input.setSelectionRange(t,n)}get value(){return this.input.value}set value(t){this.input.value=t}}be.HTMLMaskElement=Zt;class po extends Zt{get _unsafeSelectionStart(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||r==null||r<l?r:l}get _unsafeSelectionEnd(){const t=this.rootElement,n=t.getSelection&&t.getSelection(),r=n&&n.anchorOffset,l=n&&n.focusOffset;return l==null||r==null||r>l?r:l}_unsafeSelect(t,n){if(!this.rootElement.createRange)return;const r=this.rootElement.createRange();r.setStart(this.input.firstChild||this.input,t),r.setEnd(this.input.lastChild||this.input,n);const l=this.rootElement,a=l.getSelection&&l.getSelection();a&&(a.removeAllRanges(),a.addRange(r))}get value(){return this.input.textContent||""}set value(t){this.input.textContent=t}}be.HTMLContenteditableMaskElement=po;class Rn{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>Rn.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}}Rn.MAX_LENGTH=100;class Sr{constructor(t,n){this.el=t instanceof In?t:t.isContentEditable&&t.tagName!=="INPUT"&&t.tagName!=="TEXTAREA"?new po(t):new Vr(t),this.masked=ht(n),this._listeners={},this._value="",this._unmaskedValue="",this._rawInputValue="",this.history=new Rn,this._saveSelection=this._saveSelection.bind(this),this._onInput=this._onInput.bind(this),this._onChange=this._onChange.bind(this),this._onDrop=this._onDrop.bind(this),this._onFocus=this._onFocus.bind(this),this._onClick=this._onClick.bind(this),this._onUndo=this._onUndo.bind(this),this._onRedo=this._onRedo.bind(this),this.alignCursor=this.alignCursor.bind(this),this.alignCursorFriendly=this.alignCursorFriendly.bind(this),this._bindEvents(),this.updateValue(),this._onChange()}maskEquals(t){var n;return t==null||((n=this.masked)==null?void 0:n.maskEquals(t))}get mask(){return this.masked.mask}set mask(t){if(this.maskEquals(t))return;if(!(t instanceof be.Masked)&&this.masked.constructor===Er(t)){this.masked.updateOptions({mask:t});return}const n=t instanceof be.Masked?t:ht({mask:t});n.unmaskedValue=this.masked.unmaskedValue,this.masked=n}get value(){return this._value}set value(t){this.value!==t&&(this.masked.value=t,this.updateControl("auto"))}get unmaskedValue(){return this._unmaskedValue}set unmaskedValue(t){this.unmaskedValue!==t&&(this.masked.unmaskedValue=t,this.updateControl("auto"))}get rawInputValue(){return this._rawInputValue}set rawInputValue(t){this.rawInputValue!==t&&(this.masked.rawInputValue=t,this.updateControl(),this.alignCursor())}get typedValue(){return this.masked.typedValue}set typedValue(t){this.masked.typedValueEquals(t)||(this.masked.typedValue=t,this.updateControl("auto"))}get displayValue(){return this.masked.displayValue}_bindEvents(){this.el.bindEvents({selectionChange:this._saveSelection,input:this._onInput,drop:this._onDrop,click:this._onClick,focus:this._onFocus,commit:this._onChange,undo:this._onUndo,redo:this._onRedo})}_unbindEvents(){this.el&&this.el.unbindEvents()}_fireEvent(t,n){const r=this._listeners[t];r&&r.forEach(l=>l(n))}get selectionStart(){return this._cursorChanging?this._changingCursorPos:this.el.selectionStart}get cursorPos(){return this._cursorChanging?this._changingCursorPos:this.el.selectionEnd}set cursorPos(t){!this.el||!this.el.isActive||(this.el.select(t,t),this._saveSelection())}_saveSelection(){this.displayValue!==this.el.value&&console.warn("Element value was changed outside of mask. Syncronize mask using `mask.updateValue()` to work properly."),this._selection={start:this.selectionStart,end:this.cursorPos}}updateValue(){this.masked.value=this.el.value,this._value=this.masked.value,this._unmaskedValue=this.masked.unmaskedValue,this._rawInputValue=this.masked.rawInputValue}updateControl(t){const n=this.masked.unmaskedValue,r=this.masked.value,l=this.masked.rawInputValue,a=this.displayValue,s=this.unmaskedValue!==n||this.value!==r||this._rawInputValue!==l;this._unmaskedValue=n,this._value=r,this._rawInputValue=l,this.el.value!==a&&(this.el.value=a),t==="auto"?this.alignCursor():t!=null&&(this.cursorPos=t),s&&this._fireChangeEvents(),!this._historyChanging&&(s||this.history.isEmpty)&&this.history.push({unmaskedValue:n,selection:{start:this.selectionStart,end:this.cursorPos}})}updateOptions(t){const{mask:n,...r}=t,l=!this.maskEquals(n),a=this.masked.optionsIsChanged(r);l&&(this.mask=n),a&&this.masked.updateOptions(r),(l||a)&&this.updateControl()}updateCursor(t){t!=null&&(this.cursorPos=t,this._delayUpdateCursor(t))}_delayUpdateCursor(t){this._abortUpdateCursor(),this._changingCursorPos=t,this._cursorChanging=setTimeout(()=>{this.el&&(this.cursorPos=this._changingCursorPos,this._abortUpdateCursor())},10)}_fireChangeEvents(){this._fireEvent("accept",this._inputEvent),this.masked.isComplete&&this._fireEvent("complete",this._inputEvent)}_abortUpdateCursor(){this._cursorChanging&&(clearTimeout(this._cursorChanging),delete this._cursorChanging)}alignCursor(){this.cursorPos=this.masked.nearestInputPos(this.masked.nearestInputPos(this.cursorPos,ue.LEFT))}alignCursorFriendly(){this.selectionStart===this.cursorPos&&this.alignCursor()}on(t,n){return this._listeners[t]||(this._listeners[t]=[]),this._listeners[t].push(n),this}off(t,n){if(!this._listeners[t])return this;if(!n)return delete this._listeners[t],this;const r=this._listeners[t].indexOf(n);return r>=0&&this._listeners[t].splice(r,1),this}_onInput(t){this._inputEvent=t,this._abortUpdateCursor();const n=new Am({value:this.el.value,cursorPos:this.cursorPos,oldValue:this.displayValue,oldSelection:this._selection}),r=this.masked.rawInputValue,l=this.masked.splice(n.startChangePos,n.removed.length,n.inserted,n.removeDirection,{input:!0,raw:!0}).offset,a=r===this.masked.rawInputValue?n.removeDirection:ue.NONE;let s=this.masked.nearestInputPos(n.startChangePos+l,a);a!==ue.NONE&&(s=this.masked.nearestInputPos(s,ue.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}}be.InputMask=Sr;class we{static normalize(t){return Array.isArray(t)?t:[t,new we]}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}}be.ChangeDetails=we;class gt{constructor(t,n,r){t===void 0&&(t=""),n===void 0&&(n=0),this.value=t,this.from=n,this.stop=r}toString(){return this.value}extend(t){this.value+=String(t)}appendTo(t){return t.append(this.toString(),{tail:!0}).aggregate(t._appendPlaceholder())}get state(){return{value:this.value,from:this.from,stop:this.stop}}set state(t){Object.assign(this,t)}unshift(t){if(!this.value.length||t!=null&&this.from>=t)return"";const n=this.value[0];return this.value=this.value.slice(1),n}shift(){if(!this.value.length)return"";const t=this.value[this.value.length-1];return this.value=this.value.slice(0,-1),t}}class qe{constructor(t){this._value="",this._update({...qe.DEFAULTS,...t}),this._initialized=!0}updateOptions(t){this.optionsIsChanged(t)&&this.withValueRefresh(this._update.bind(this,t))}_update(t){Object.assign(this,t)}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value}reset(){this._value=""}get value(){return this._value}set value(t){this.resolve(t,{input:!0})}resolve(t,n){n===void 0&&(n={input:!0}),this.reset(),this.append(t,n,""),this.doCommit()}get unmaskedValue(){return this.value}set unmaskedValue(t){this.resolve(t,{})}get typedValue(){return this.parse?this.parse(this.value,this):this.unmaskedValue}set typedValue(t){this.format?this.value=this.format(t,this):this.unmaskedValue=String(t)}get rawInputValue(){return this.extractInput(0,this.displayValue.length,{raw:!0})}set rawInputValue(t){this.resolve(t,{raw:!0})}get displayValue(){return this.value}get isComplete(){return!0}get isFilled(){return this.isComplete}nearestInputPos(t,n){return t}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),Math.min(this.displayValue.length,n-t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this.displayValue.slice(t,n)}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new gt(this.extractInput(t,n),t)}appendTail(t){return St(t)&&(t=new gt(String(t))),t.appendTo(this)}_appendCharRaw(t,n){return t?(this._value+=t,new we({inserted:t,rawInserted:t})):new we}_appendChar(t,n,r){n===void 0&&(n={});const l=this.state;let a;if([t,a]=this.doPrepareChar(t,n),t&&(a=a.aggregate(this._appendCharRaw(t,n)),!a.rawInserted&&this.autofix==="pad")){const s=this.state;this.state=l;let i=this.pad(n);const c=this._appendCharRaw(t,n);i=i.aggregate(c),c.rawInserted||i.equals(a)?a=i:this.state=s}if(a.inserted){let s,i=this.doValidate(n)!==!1;if(i&&r!=null){const c=this.state;if(this.overwrite===!0){s=r.state;for(let u=0;u<a.rawInserted.length;++u)r.unshift(this.displayValue.length-a.tailShift)}let d=this.appendTail(r);if(i=d.rawInserted.length===r.toString().length,!(i&&d.inserted)&&this.overwrite==="shift"){this.state=c,s=r.state;for(let u=0;u<a.rawInserted.length;++u)r.shift();d=this.appendTail(r),i=d.rawInserted.length===r.toString().length}i&&d.inserted&&(this.state=c)}i||(a=new we,this.state=l,r&&s&&(r.state=s))}return a}_appendPlaceholder(){return new we}_appendEager(){return new we}append(t,n,r){if(!St(t))throw new Error("value should be string");const l=St(r)?new gt(String(r)):r;n!=null&&n.tail&&(n._beforeTailState=this.state);let a;[t,a]=this.doPrepare(t,n);for(let s=0;s<t.length;++s){const i=this._appendChar(t[s],n,l);if(!i.rawInserted&&!this.doSkipInvalid(t[s],n,l))break;a.aggregate(i)}return(this.eager===!0||this.eager==="append")&&n!=null&&n.input&&t&&a.aggregate(this._appendEager()),l!=null&&(a.tailShift+=this.appendTail(l).tailShift),a}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),this._value=this.displayValue.slice(0,t)+this.displayValue.slice(n),new we}withValueRefresh(t){if(this._refreshing||!this._initialized)return t();this._refreshing=!0;const n=this.rawInputValue,r=this.value,l=t();return this.rawInputValue=n,this.value&&this.value!==r&&r.indexOf(this.value)===0&&(this.append(r.slice(this.displayValue.length),{},""),this.doCommit()),delete this._refreshing,l}runIsolated(t){if(this._isolated||!this._initialized)return t(this);this._isolated=!0;const n=this.state,r=t(this);return this.state=n,delete this._isolated,r}doSkipInvalid(t,n,r){return!!this.skipInvalid}doPrepare(t,n){return n===void 0&&(n={}),we.normalize(this.prepare?this.prepare(t,this,n):t)}doPrepareChar(t,n){return n===void 0&&(n={}),we.normalize(this.prepareChar?this.prepareChar(t,this,n):t)}doValidate(t){return(!this.validate||this.validate(this.value,this,t))&&(!this.parent||this.parent.doValidate(t))}doCommit(){this.commit&&this.commit(this.value,this)}splice(t,n,r,l,a){r===void 0&&(r=""),l===void 0&&(l=ue.NONE),a===void 0&&(a={input:!0});const s=t+n,i=this.extractTail(s),c=this.eager===!0||this.eager==="remove";let d;c&&(l=vr(l),d=this.extractInput(0,s,{raw:!0}));let u=t;const p=new we;if(l!==ue.NONE&&(u=this.nearestInputPos(t,n>1&&t!==0&&!c?ue.NONE:l),p.tailShift=u-t),p.aggregate(this.remove(u)),c&&l!==ue.NONE&&d===this.rawInputValue)if(l===ue.FORCE_LEFT){let y;for(;d===this.rawInputValue&&(y=this.displayValue.length);)p.aggregate(new we({tailShift:-1})).aggregate(this.remove(y-1))}else l===ue.FORCE_RIGHT&&i.unshift();return p.aggregate(this.append(r,a,i))}maskEquals(t){return this.mask===t}optionsIsChanged(t){return!Ln(this,t)}typedValueEquals(t){const n=this.typedValue;return t===n||qe.EMPTY_VALUES.includes(t)&&qe.EMPTY_VALUES.includes(n)||(this.format?this.format(t,this)===this.format(this.typedValue,this):!1)}pad(t){return new we}}qe.DEFAULTS={skipInvalid:!0},qe.EMPTY_VALUES=[void 0,null,""],be.Masked=qe;class $t{constructor(t,n){t===void 0&&(t=[]),n===void 0&&(n=0),this.chunks=t,this.from=n}toString(){return this.chunks.map(String).join("")}extend(t){if(!String(t))return;t=St(t)?new gt(String(t)):t;const n=this.chunks[this.chunks.length-1],r=n&&(n.stop===t.stop||t.stop==null)&&t.from===n.from+n.toString().length;if(t instanceof gt)r?n.extend(t.toString()):this.chunks.push(t);else if(t instanceof $t){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 be.MaskedPattern))return new gt(this.toString()).appendTo(t);const n=new we;for(let r=0;r<this.chunks.length;++r){const l=this.chunks[r],a=t._mapPosToBlock(t.displayValue.length),s=l.stop;let i;if(s!=null&&(!a||a.index<=s)&&((l instanceof $t||t._stops.indexOf(s)>=0)&&n.aggregate(t._appendPlaceholder(s)),i=l instanceof $t&&t._blocks[s]),i){const c=i.appendTail(l);n.aggregate(c);const d=l.toString().slice(c.rawInserted.length);d&&n.aggregate(t.append(d,{tail:!0}))}else n.aggregate(t.append(l.toString(),{tail:!0}))}return n}get state(){return{chunks:this.chunks.map(t=>t.state),from:this.from,stop:this.stop,blockIndex:this.blockIndex}}set state(t){const{chunks:n,...r}=t;Object.assign(this,r),this.chunks=n.map(l=>{const a="chunks"in l?new $t:new gt;return a.state=l,a})}unshift(t){if(!this.chunks.length||t!=null&&this.from>=t)return"";const n=t!=null?t-this.from:t;let r=0;for(;r<this.chunks.length;){const l=this.chunks[r],a=l.unshift(n);if(l.toString()){if(!a)break;++r}else this.chunks.splice(r,1);if(a)return a}return""}shift(){if(!this.chunks.length)return"";let t=this.chunks.length-1;for(;0<=t;){const n=this.chunks[t],r=n.shift();if(n.toString()){if(!r)break;--t}else this.chunks.splice(t,1);if(r)return r}return""}}class Mm{constructor(t,n){this.masked=t,this._log=[];const{offset:r,index:l}=t._mapPosToBlock(n)||(n<0?{index:0,offset:0}:{index:this.masked._blocks.length,offset:0});this.offset=r,this.index=l,this.ok=!1}get block(){return this.masked._blocks[this.index]}get pos(){return this.masked._blockStartPos(this.index)+this.offset}get state(){return{index:this.index,offset:this.offset,ok:this.ok}}set state(t){Object.assign(this,t)}pushState(){this._log.push(this.state)}popState(){const t=this._log.pop();return t&&(this.state=t),t}bindBlock(){this.block||(this.index<0&&(this.index=0,this.offset=0),this.index>=this.masked._blocks.length&&(this.index=this.masked._blocks.length-1,this.offset=this.block.displayValue.length))}_pushLeft(t){for(this.pushState(),this.bindBlock();0<=this.index;--this.index,this.offset=((n=this.block)==null?void 0:n.displayValue.length)||0){var n;if(t())return this.ok=!0}return this.ok=!1}_pushRight(t){for(this.pushState(),this.bindBlock();this.index<this.masked._blocks.length;++this.index,this.offset=0)if(t())return this.ok=!0;return this.ok=!1}pushLeftBeforeFilled(){return this._pushLeft(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,ue.FORCE_LEFT),this.offset!==0))return!0})}pushLeftBeforeInput(){return this._pushLeft(()=>{if(!this.block.isFixed)return this.offset=this.block.nearestInputPos(this.offset,ue.LEFT),!0})}pushLeftBeforeRequired(){return this._pushLeft(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ue.LEFT),!0})}pushRightBeforeFilled(){return this._pushRight(()=>{if(!(this.block.isFixed||!this.block.value)&&(this.offset=this.block.nearestInputPos(this.offset,ue.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,ue.NONE),!0})}pushRightBeforeRequired(){return this._pushRight(()=>{if(!(this.block.isFixed||this.block.isOptional&&!this.block.value))return this.offset=this.block.nearestInputPos(this.offset,ue.NONE),!0})}}class fo{constructor(t){Object.assign(this,t),this._value="",this.isFixed=!0}get value(){return this._value}get unmaskedValue(){return this.isUnmasking?this.value:""}get rawInputValue(){return this._isRawInput?this.value:""}get displayValue(){return this.value}reset(){this._isRawInput=!1,this._value=""}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._value=this._value.slice(0,t)+this._value.slice(n),this._value||(this._isRawInput=!1),new we}nearestInputPos(t,n){n===void 0&&(n=ue.NONE);const r=0,l=this._value.length;switch(n){case ue.LEFT:case ue.FORCE_LEFT:return r;case ue.NONE:case ue.RIGHT:case ue.FORCE_RIGHT:default:return l}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),this._isRawInput?n-t:0}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this._value.length),r===void 0&&(r={}),r.raw&&this._isRawInput&&this._value.slice(t,n)||""}get isComplete(){return!0}get isFilled(){return!!this._value}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new we;const r=this.eager===!0||this.eager==="append",a=this.char===t&&(this.isUnmasking||n.input||n.raw)&&(!n.raw||!r)&&!n.tail,s=new we({inserted:this.char,rawInserted:a?this.char:""});return this._value=this.char,this._isRawInput=a&&(n.raw||n.input),s}_appendEager(){return this._appendChar(this.char,{tail:!0})}_appendPlaceholder(){const t=new we;return this.isFilled||(this._value=t.inserted=this.char),t}extractTail(){return new gt("")}appendTail(t){return St(t)&&(t=new gt(String(t))),t.appendTo(this)}append(t,n,r){const l=this._appendChar(t[0],n);return r!=null&&(l.tailShift+=this.appendTail(r).tailShift),l}doCommit(){}get state(){return{_value:this._value,_rawInputValue:this.rawInputValue}}set state(t){this._value=t._value,this._isRawInput=!!t._rawInputValue}pad(t){return this._appendPlaceholder()}}class Jt{constructor(t){const{parent:n,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:i,...c}=t;this.masked=ht(c),Object.assign(this,{parent:n,isOptional:r,placeholderChar:l,displayChar:a,lazy:s,eager:i})}reset(){this.isFilled=!1,this.masked.reset()}remove(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),t===0&&n>=1?(this.isFilled=!1,this.masked.remove(t,n)):new we}get value(){return this.masked.value||(this.isFilled&&!this.isOptional?this.placeholderChar:"")}get unmaskedValue(){return this.masked.unmaskedValue}get rawInputValue(){return this.masked.rawInputValue}get displayValue(){return this.masked.value&&this.displayChar||this.value}get isComplete(){return!!this.masked.value||this.isOptional}_appendChar(t,n){if(n===void 0&&(n={}),this.isFilled)return new we;const r=this.masked.state;let l=this.masked._appendChar(t,this.currentMaskFlags(n));return l.inserted&&this.doValidate(n)===!1&&(l=new we,this.masked.state=r),!l.inserted&&!this.isOptional&&!this.lazy&&!n.input&&(l.inserted=this.placeholderChar),l.skip=!l.inserted&&!this.isOptional,this.isFilled=!!l.inserted,l}append(t,n,r){return this.masked.append(t,this.currentMaskFlags(n),r)}_appendPlaceholder(){return this.isFilled||this.isOptional?new we:(this.isFilled=!0,new we({inserted:this.placeholderChar}))}_appendEager(){return new we}extractTail(t,n){return this.masked.extractTail(t,n)}appendTail(t){return this.masked.appendTail(t)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.masked.extractInput(t,n,r)}nearestInputPos(t,n){n===void 0&&(n=ue.NONE);const r=0,l=this.value.length,a=Math.min(Math.max(t,r),l);switch(n){case ue.LEFT:case ue.FORCE_LEFT:return this.isComplete?a:r;case ue.RIGHT:case ue.FORCE_RIGHT:return this.isComplete?a:l;case ue.NONE:default:return a}}totalInputPositions(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.value.length),this.value.slice(t,n).length}doValidate(t){return this.masked.doValidate(this.currentMaskFlags(t))&&(!this.parent||this.parent.doValidate(this.currentMaskFlags(t)))}doCommit(){this.masked.doCommit()}get state(){return{_value:this.value,_rawInputValue:this.rawInputValue,masked:this.masked.state,isFilled:this.isFilled}}set state(t){this.masked.state=t.masked,this.isFilled=t.isFilled}currentMaskFlags(t){var n;return{...t,_beforeTailState:(t==null||(n=t._beforeTailState)==null?void 0:n.masked)||t?._beforeTailState}}pad(t){return new we}}Jt.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 $r extends qe{updateOptions(t){super.updateOptions(t)}_update(t){const n=t.mask;n&&(t.validate=r=>r.search(n)>=0),super._update(t)}}be.MaskedRegExp=$r;class Ke extends qe{constructor(t){super({...Ke.DEFAULTS,...t,definitions:Object.assign({},Jt.DEFAULT_DEFINITIONS,t?.definitions)})}updateOptions(t){super.updateOptions(t)}_update(t){t.definitions=Object.assign({},this.definitions,t.definitions),super._update(t),this._rebuildMask()}_rebuildMask(){const t=this.definitions;this._blocks=[],this.exposeBlock=void 0,this._stops=[],this._maskedBlocks={};const n=this.mask;if(!n||!t)return;let r=!1,l=!1;for(let a=0;a<n.length;++a){if(this.blocks){const d=n.slice(a),u=Object.keys(this.blocks).filter(y=>d.indexOf(y)===0);u.sort((y,k)=>k.length-y.length);const p=u[0];if(p){const{expose:y,repeat:k,...m}=Ut(this.blocks[p]),h={lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,overwrite:this.overwrite,autofix:this.autofix,...m,repeat:k,parent:this},b=k!=null?new be.RepeatBlock(h):ht(h);b&&(this._blocks.push(b),y&&(this.exposeBlock=b),this._maskedBlocks[p]||(this._maskedBlocks[p]=[]),this._maskedBlocks[p].push(this._blocks.length-1)),a+=p.length-1;continue}}let s=n[a],i=s in t;if(s===Ke.STOP_CHAR){this._stops.push(this._blocks.length);continue}if(s==="{"||s==="}"){r=!r;continue}if(s==="["||s==="]"){l=!l;continue}if(s===Ke.ESCAPE_CHAR){if(++a,s=n[a],!s)break;i=!1}const c=i?new Jt({isOptional:l,lazy:this.lazy,eager:this.eager,placeholderChar:this.placeholderChar,displayChar:this.displayChar,...Ut(t[s]),parent:this}):new fo({char:s,eager:this.eager,isUnmasking:r});this._blocks.push(c)}}get state(){return{...super.state,_blocks:this._blocks.map(t=>t.state)}}set state(t){if(!t){this.reset();return}const{_blocks:n,...r}=t;this._blocks.forEach((l,a)=>l.state=n[a]),super.state=r}reset(){super.reset(),this._blocks.forEach(t=>t.reset())}get isComplete(){return this.exposeBlock?this.exposeBlock.isComplete:this._blocks.every(t=>t.isComplete)}get isFilled(){return this._blocks.every(t=>t.isFilled)}get isFixed(){return this._blocks.every(t=>t.isFixed)}get isOptional(){return this._blocks.every(t=>t.isOptional)}doCommit(){this._blocks.forEach(t=>t.doCommit()),super.doCommit()}get unmaskedValue(){return this.exposeBlock?this.exposeBlock.unmaskedValue:this._blocks.reduce((t,n)=>t+=n.unmaskedValue,"")}set unmaskedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.unmaskedValue=t,this.appendTail(n),this.doCommit()}else super.unmaskedValue=t}get value(){return this.exposeBlock?this.exposeBlock.value:this._blocks.reduce((t,n)=>t+=n.value,"")}set value(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.value=t,this.appendTail(n),this.doCommit()}else super.value=t}get typedValue(){return this.exposeBlock?this.exposeBlock.typedValue:super.typedValue}set typedValue(t){if(this.exposeBlock){const n=this.extractTail(this._blockStartPos(this._blocks.indexOf(this.exposeBlock))+this.exposeBlock.displayValue.length);this.exposeBlock.typedValue=t,this.appendTail(n),this.doCommit()}else super.typedValue=t}get displayValue(){return this._blocks.reduce((t,n)=>t+=n.displayValue,"")}appendTail(t){return super.appendTail(t).aggregate(this._appendPlaceholder())}_appendEager(){var t;const n=new we;let r=(t=this._mapPosToBlock(this.displayValue.length))==null?void 0:t.index;if(r==null)return n;this._blocks[r].isFilled&&++r;for(let l=r;l<this._blocks.length;++l){const a=this._blocks[l]._appendEager();if(!a.inserted)break;n.aggregate(a)}return n}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._mapPosToBlock(this.displayValue.length),l=new we;if(!r)return l;for(let s=r.index,i;i=this._blocks[s];++s){var a;const c=i._appendChar(t,{...n,_beforeTailState:(a=n._beforeTailState)==null||(a=a._blocks)==null?void 0:a[s]});if(l.aggregate(c),c.consumed)break}return l}extractTail(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=new $t;return t===n||this._forEachBlocksInRange(t,n,(l,a,s,i)=>{const c=l.extractTail(s,i);c.stop=this._findStopBefore(a),c.from=this._blockStartPos(a),c instanceof $t&&(c.blockIndex=a),r.extend(c)}),r}extractInput(t,n,r){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),r===void 0&&(r={}),t===n)return"";let l="";return this._forEachBlocksInRange(t,n,(a,s,i,c)=>{l+=a.extractInput(i,c,r)}),l}_findStopBefore(t){let n;for(let r=0;r<this._stops.length;++r){const l=this._stops[r];if(l<=t)n=l;else break}return n}_appendPlaceholder(t){const n=new we;if(this.lazy&&t==null)return n;const r=this._mapPosToBlock(this.displayValue.length);if(!r)return n;const l=r.index,a=t??this._blocks.length;return this._blocks.slice(l,a).forEach(s=>{if(!s.lazy||t!=null){var i;n.aggregate(s._appendPlaceholder((i=s._blocks)==null?void 0:i.length))}}),n}_mapPosToBlock(t){let n="";for(let r=0;r<this._blocks.length;++r){const l=this._blocks[r],a=n.length;if(n+=l.displayValue,t<=n.length)return{index:r,offset:t-a}}}_blockStartPos(t){return this._blocks.slice(0,t).reduce((n,r)=>n+=r.displayValue.length,0)}_forEachBlocksInRange(t,n,r){n===void 0&&(n=this.displayValue.length);const l=this._mapPosToBlock(t);if(l){const a=this._mapPosToBlock(n),s=a&&l.index===a.index,i=l.offset,c=a&&s?a.offset:this._blocks[l.index].displayValue.length;if(r(this._blocks[l.index],l.index,i,c),a&&!s){for(let d=l.index+1;d<a.index;++d)r(this._blocks[d],d,0,this._blocks[d].displayValue.length);r(this._blocks[a.index],a.index,0,a.offset)}}}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._forEachBlocksInRange(t,n,(l,a,s,i)=>{r.aggregate(l.remove(s,i))}),r}nearestInputPos(t,n){if(n===void 0&&(n=ue.NONE),!this._blocks.length)return 0;const r=new Mm(this,t);if(n===ue.NONE)return r.pushRightBeforeInput()||(r.popState(),r.pushLeftBeforeInput())?r.pos:this.displayValue.length;if(n===ue.LEFT||n===ue.FORCE_LEFT){if(n===ue.LEFT){if(r.pushRightBeforeFilled(),r.ok&&r.pos===t)return t;r.popState()}if(r.pushLeftBeforeInput(),r.pushLeftBeforeRequired(),r.pushLeftBeforeFilled(),n===ue.LEFT){if(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.ok&&r.pos<=t||(r.popState(),r.ok&&r.pos<=t))return r.pos;r.popState()}return r.ok?r.pos:n===ue.FORCE_LEFT?0:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:0)}return n===ue.RIGHT||n===ue.FORCE_RIGHT?(r.pushRightBeforeInput(),r.pushRightBeforeRequired(),r.pushRightBeforeFilled()?r.pos:n===ue.FORCE_RIGHT?this.displayValue.length:(r.popState(),r.ok||(r.popState(),r.ok)?r.pos:this.nearestInputPos(t,ue.LEFT))):t}totalInputPositions(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);let r=0;return this._forEachBlocksInRange(t,n,(l,a,s,i)=>{r+=l.totalInputPositions(s,i)}),r}maskedBlock(t){return this.maskedBlocks(t)[0]}maskedBlocks(t){const n=this._maskedBlocks[t];return n?n.map(r=>this._blocks[r]):[]}pad(t){const n=new we;return this._forEachBlocksInRange(0,this.displayValue.length,r=>n.aggregate(r.pad(t))),n}}Ke.DEFAULTS={...qe.DEFAULTS,lazy:!0,placeholderChar:"_"},Ke.STOP_CHAR="`",Ke.ESCAPE_CHAR="\\",Ke.InputDefinition=Jt,Ke.FixedDefinition=fo,be.MaskedPattern=Ke;class Qt extends Ke{get _matchFrom(){return this.maxLength-String(this.from).length}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){const{to:n=this.to||0,from:r=this.from||0,maxLength:l=this.maxLength||0,autofix:a=this.autofix,...s}=t;this.to=n,this.from=r,this.maxLength=Math.max(String(n).length,l),this.autofix=a;const i=String(this.from).padStart(this.maxLength,"0"),c=String(this.to).padStart(this.maxLength,"0");let d=0;for(;d<c.length&&c[d]===i[d];)++d;s.mask=c.slice(0,d).replace(/0/g,"\\0")+"0".repeat(this.maxLength-d),super._update(s)}get isComplete(){return super.isComplete&&!!this.value}boundaries(t){let n="",r="";const[,l,a]=t.match(/^(\D*)(\d*)(\D*)/)||[];return a&&(n="0".repeat(l.length)+a,r="9".repeat(l.length)+a),n=n.padEnd(this.maxLength,"0"),r=r.padEnd(this.maxLength,"9"),[n,r]}doPrepareChar(t,n){n===void 0&&(n={});let r;return[t,r]=super.doPrepareChar(t.replace(/\D/g,""),n),t||(r.skip=!this.isComplete),[t,r]}_appendCharRaw(t,n){if(n===void 0&&(n={}),!this.autofix||this.value.length+1>this.maxLength)return super._appendCharRaw(t,n);const r=String(this.from).padStart(this.maxLength,"0"),l=String(this.to).padStart(this.maxLength,"0"),[a,s]=this.boundaries(this.value+t);return Number(s)<this.from?super._appendCharRaw(r[this.value.length],n):Number(a)>this.to?!n.tail&&this.autofix==="pad"&&this.value.length+1<this.maxLength?super._appendCharRaw(r[this.value.length],n).aggregate(this._appendCharRaw(t,n)):super._appendCharRaw(l[this.value.length],n):super._appendCharRaw(t,n)}doValidate(t){const n=this.value;if(n.search(/[^0]/)===-1&&n.length<=this._matchFrom)return!0;const[l,a]=this.boundaries(n);return this.from<=Number(a)&&Number(l)<=this.to&&super.doValidate(t)}pad(t){const n=new we;if(this.value.length===this.maxLength)return n;const r=this.value,l=this.maxLength-this.value.length;if(l){this.reset();for(let a=0;a<l;++a)n.aggregate(super._appendCharRaw("0",t));r.split("").forEach(a=>this._appendCharRaw(a))}return n}}be.MaskedRange=Qt;const Dm="d{.}`m{.}`Y";class yt extends Ke{static extractPatternOptions(t){const{mask:n,pattern:r,...l}=t;return{...l,mask:St(n)?n:r}}constructor(t){super(yt.extractPatternOptions({...yt.DEFAULTS,...t}))}updateOptions(t){super.updateOptions(t)}_update(t){const{mask:n,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:St(n)?n:r,blocks:s})}doValidate(t){const n=this.date;return super.doValidate(t)&&(!this.isComplete||this.isDateExist(this.value)&&n!=null&&(this.min==null||this.min<=n)&&(this.max==null||n<=this.max))}isDateExist(t){return this.format(this.parse(t,this),this).indexOf(t)>=0}get date(){return this.typedValue}set date(t){this.typedValue=t}get typedValue(){return this.isComplete?super.typedValue:null}set typedValue(t){super.typedValue=t}maskEquals(t){return t===Date||super.maskEquals(t)}optionsIsChanged(t){return super.optionsIsChanged(yt.extractPatternOptions(t))}}yt.GET_DEFAULT_BLOCKS=()=>({d:{mask:Qt,from:1,to:31,maxLength:2},m:{mask:Qt,from:1,to:12,maxLength:2},Y:{mask:Qt,from:1900,to:9999}}),yt.DEFAULTS={...Ke.DEFAULTS,mask:Date,pattern:Dm,format:(o,t)=>{if(!o)return"";const n=String(o.getDate()).padStart(2,"0"),r=String(o.getMonth()+1).padStart(2,"0"),l=o.getFullYear();return[n,r,l].join(".")},parse:(o,t)=>{const[n,r,l]=o.split(".").map(Number);return new Date(l,r-1,n)}},be.MaskedDate=yt;class en extends qe{constructor(t){super({...en.DEFAULTS,...t}),this.currentMask=void 0}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),"mask"in t&&(this.exposeMask=void 0,this.compiledMasks=Array.isArray(t.mask)?t.mask.map(n=>{const{expose:r,...l}=Ut(n),a=ht({overwrite:this._overwrite,eager:this._eager,skipInvalid:this._skipInvalid,...l});return r&&(this.exposeMask=a),a}):[])}_appendCharRaw(t,n){n===void 0&&(n={});const r=this._applyDispatch(t,n);return this.currentMask&&r.aggregate(this.currentMask._appendChar(t,this.currentMaskFlags(n))),r}_applyDispatch(t,n,r){t===void 0&&(t=""),n===void 0&&(n={}),r===void 0&&(r="");const l=n.tail&&n._beforeTailState!=null?n._beforeTailState._value:this.value,a=this.rawInputValue,s=n.tail&&n._beforeTailState!=null?n._beforeTailState._rawInputValue:a,i=a.slice(s.length),c=this.currentMask,d=new we,u=c?.state;return this.currentMask=this.doDispatch(t,{...n},r),this.currentMask&&(this.currentMask!==c?(this.currentMask.reset(),s&&(this.currentMask.append(s,{raw:!0}),d.tailShift=this.currentMask.value.length-l.length),i&&(d.tailShift+=this.currentMask.append(i,{raw:!0,tail:!0}).tailShift)):u&&(this.currentMask.state=u)),d}_appendPlaceholder(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendPlaceholder()),t}_appendEager(){const t=this._applyDispatch();return this.currentMask&&t.aggregate(this.currentMask._appendEager()),t}appendTail(t){const n=new we;return t&&n.aggregate(this._applyDispatch("",{},t)),n.aggregate(this.currentMask?this.currentMask.appendTail(t):super.appendTail(t))}currentMaskFlags(t){var n,r;return{...t,_beforeTailState:((n=t._beforeTailState)==null?void 0:n.currentMaskRef)===this.currentMask&&((r=t._beforeTailState)==null?void 0:r.currentMask)||t._beforeTailState}}doDispatch(t,n,r){return n===void 0&&(n={}),r===void 0&&(r=""),this.dispatch(t,this,n,r)}doValidate(t){return super.doValidate(t)&&(!this.currentMask||this.currentMask.doValidate(this.currentMaskFlags(t)))}doPrepare(t,n){n===void 0&&(n={});let[r,l]=super.doPrepare(t,n);if(this.currentMask){let a;[r,a]=super.doPrepare(r,this.currentMaskFlags(n)),l=l.aggregate(a)}return[r,l]}doPrepareChar(t,n){n===void 0&&(n={});let[r,l]=super.doPrepareChar(t,n);if(this.currentMask){let a;[r,a]=super.doPrepareChar(r,this.currentMaskFlags(n)),l=l.aggregate(a)}return[r,l]}reset(){var t;(t=this.currentMask)==null||t.reset(),this.compiledMasks.forEach(n=>n.reset())}get value(){return this.exposeMask?this.exposeMask.value:this.currentMask?this.currentMask.value:""}set value(t){this.exposeMask?(this.exposeMask.value=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.value=t}get unmaskedValue(){return this.exposeMask?this.exposeMask.unmaskedValue:this.currentMask?this.currentMask.unmaskedValue:""}set unmaskedValue(t){this.exposeMask?(this.exposeMask.unmaskedValue=t,this.currentMask=this.exposeMask,this._applyDispatch()):super.unmaskedValue=t}get typedValue(){return this.exposeMask?this.exposeMask.typedValue:this.currentMask?this.currentMask.typedValue:""}set typedValue(t){if(this.exposeMask){this.exposeMask.typedValue=t,this.currentMask=this.exposeMask,this._applyDispatch();return}let n=String(t);this.currentMask&&(this.currentMask.typedValue=t,n=this.currentMask.unmaskedValue),this.unmaskedValue=n}get displayValue(){return this.currentMask?this.currentMask.displayValue:""}get isComplete(){var t;return!!((t=this.currentMask)!=null&&t.isComplete)}get isFilled(){var t;return!!((t=this.currentMask)!=null&&t.isFilled)}remove(t,n){const r=new we;return this.currentMask&&r.aggregate(this.currentMask.remove(t,n)).aggregate(this._applyDispatch()),r}get state(){var t;return{...super.state,_rawInputValue:this.rawInputValue,compiledMasks:this.compiledMasks.map(n=>n.state),currentMaskRef:this.currentMask,currentMask:(t=this.currentMask)==null?void 0:t.state}}set state(t){const{compiledMasks:n,currentMaskRef:r,currentMask:l,...a}=t;n&&this.compiledMasks.forEach((s,i)=>s.state=n[i]),r!=null&&(this.currentMask=r,this.currentMask.state=l),super.state=a}extractInput(t,n,r){return this.currentMask?this.currentMask.extractInput(t,n,r):""}extractTail(t,n){return this.currentMask?this.currentMask.extractTail(t,n):super.extractTail(t,n)}doCommit(){this.currentMask&&this.currentMask.doCommit(),super.doCommit()}nearestInputPos(t,n){return this.currentMask?this.currentMask.nearestInputPos(t,n):super.nearestInputPos(t,n)}get overwrite(){return this.currentMask?this.currentMask.overwrite:this._overwrite}set overwrite(t){this._overwrite=t}get eager(){return this.currentMask?this.currentMask.eager:this._eager}set eager(t){this._eager=t}get skipInvalid(){return this.currentMask?this.currentMask.skipInvalid:this._skipInvalid}set skipInvalid(t){this._skipInvalid=t}get autofix(){return this.currentMask?this.currentMask.autofix:this._autofix}set autofix(t){this._autofix=t}maskEquals(t){return Array.isArray(t)?this.compiledMasks.every((n,r)=>{if(!t[r])return;const{mask:l,...a}=t[r];return Ln(n,a)&&n.maskEquals(l)}):super.maskEquals(t)}typedValueEquals(t){var n;return!!((n=this.currentMask)!=null&&n.typedValueEquals(t))}}en.DEFAULTS={...qe.DEFAULTS,dispatch:(o,t,n,r)=>{if(!t.compiledMasks.length)return;const l=t.rawInputValue,a=t.compiledMasks.map((s,i)=>{const c=t.currentMask===s,d=c?s.displayValue.length:s.nearestInputPos(s.displayValue.length,ue.FORCE_LEFT);return s.rawInputValue!==l?(s.reset(),s.append(l,{raw:!0})):c||s.remove(d),s.append(o,t.currentMaskFlags(n)),s.appendTail(r),{index:i,weight:s.rawInputValue.length,totalInputPositions:s.totalInputPositions(0,Math.max(d,s.nearestInputPos(s.displayValue.length,ue.FORCE_LEFT)))}});return a.sort((s,i)=>i.weight-s.weight||i.totalInputPositions-s.totalInputPositions),t.compiledMasks[a[0].index]}},be.MaskedDynamic=en;class tn extends Ke{constructor(t){super({...tn.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){const{enum:n,...r}=t;if(n){const l=n.map(i=>i.length),a=Math.min(...l),s=Math.max(...l)-a;r.mask="*".repeat(a),s&&(r.mask+="["+"*".repeat(s)+"]"),this.enum=n}super._update(r)}_appendCharRaw(t,n){n===void 0&&(n={});const r=Math.min(this.nearestInputPos(0,ue.FORCE_RIGHT),this.value.length),l=this.enum.filter(a=>this.matchValue(a,this.unmaskedValue+t,r));if(l.length){l.length===1&&this._forEachBlocksInRange(0,this.value.length,(s,i)=>{const c=l[0][i];i>=this.value.length||c===s.value||(s.reset(),s._appendChar(c,n))});const a=super._appendCharRaw(l[0][this.value.length],n);return l.length===1&&l[0].slice(this.unmaskedValue.length).split("").forEach(s=>a.aggregate(super._appendCharRaw(s))),a}return new we({skip:!this.isComplete})}extractTail(t,n){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),new gt("",t)}remove(t,n){if(t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),t===n)return new we;const r=Math.min(super.nearestInputPos(0,ue.FORCE_RIGHT),this.value.length);let l;for(l=t;l>=0&&!(this.enum.filter(i=>this.matchValue(i,this.value.slice(r,l),r)).length>1);--l);const a=super.remove(l,n);return a.tailShift+=l-t,a}get isComplete(){return this.enum.indexOf(this.value)>=0}}tn.DEFAULTS={...Ke.DEFAULTS,matchValue:(o,t,n)=>o.indexOf(t,n)===n},be.MaskedEnum=tn;class Nr extends qe{updateOptions(t){super.updateOptions(t)}_update(t){super._update({...t,validate:t.mask})}}be.MaskedFunction=Nr;var Ar;class Ge extends qe{constructor(t){super({...Ge.DEFAULTS,...t})}updateOptions(t){super.updateOptions(t)}_update(t){super._update(t),this._updateRegExps()}_updateRegExps(){const t="^"+(this.allowNegative?"[+|\\-]?":""),n="\\d*",r=(this.scale?"("+uo(this.radix)+"\\d{0,"+this.scale+"})?":"")+"$";this._numberRegExp=new RegExp(t+n+r),this._mapToRadixRegExp=new RegExp("["+this.mapToRadix.map(uo).join("")+"]","g"),this._thousandsSeparatorRegExp=new RegExp(uo(this.thousandsSeparator),"g")}_removeThousandsSeparators(t){return t.replace(this._thousandsSeparatorRegExp,"")}_insertThousandsSeparators(t){const n=t.split(this.radix);return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,this.thousandsSeparator),n.join(this.radix)}doPrepareChar(t,n){n===void 0&&(n={});const[r,l]=super.doPrepareChar(this._removeThousandsSeparators(this.scale&&this.mapToRadix.length&&(n.input&&n.raw||!n.input&&!n.raw)?t.replace(this._mapToRadixRegExp,this.radix):t),n);return t&&!r&&(l.skip=!0),r&&!this.allowPositive&&!this.value&&r!=="-"&&l.aggregate(this._appendChar("-")),[r,l]}_separatorsCount(t,n){n===void 0&&(n=!1);let r=0;for(let l=0;l<t;++l)this._value.indexOf(this.thousandsSeparator,l)===l&&(++r,n&&(t+=this.thousandsSeparator.length));return r}_separatorsCountFromSlice(t){return t===void 0&&(t=this._value),this._separatorsCount(this._removeThousandsSeparators(t).length,!0)}extractInput(t,n,r){return t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n),this._removeThousandsSeparators(super.extractInput(t,n,r))}_appendCharRaw(t,n){n===void 0&&(n={});const r=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,l=this._separatorsCountFromSlice(r);this._value=this._removeThousandsSeparators(this.value);const a=this._value;this._value+=t;const s=this.number;let i=!isNaN(s),c=!1;if(i){let y;this.min!=null&&this.min<0&&this.number<this.min&&(y=this.min),this.max!=null&&this.max>0&&this.number>this.max&&(y=this.max),y!=null&&(this.autofix?(this._value=this.format(y,this).replace(Ge.UNMASKED_RADIX,this.radix),c||(c=a===this._value&&!n.tail)):i=!1),i&&(i=!!this._value.match(this._numberRegExp))}let d;i?d=new we({inserted:this._value.slice(a.length),rawInserted:c?"":t,skip:c}):(this._value=a,d=new we),this._value=this._insertThousandsSeparators(this._value);const u=n.tail&&n._beforeTailState?n._beforeTailState._value:this._value,p=this._separatorsCountFromSlice(u);return d.tailShift+=(p-l)*this.thousandsSeparator.length,d}_findSeparatorAround(t){if(this.thousandsSeparator){const n=t-this.thousandsSeparator.length+1,r=this.value.indexOf(this.thousandsSeparator,n);if(r<=t)return r}return-1}_adjustRangeWithSeparators(t,n){const r=this._findSeparatorAround(t);r>=0&&(t=r);const l=this._findSeparatorAround(n);return l>=0&&(n=l+this.thousandsSeparator.length),[t,n]}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length),[t,n]=this._adjustRangeWithSeparators(t,n);const r=this.value.slice(0,t),l=this.value.slice(n),a=this._separatorsCount(r.length);this._value=this._insertThousandsSeparators(this._removeThousandsSeparators(r+l));const s=this._separatorsCountFromSlice(r);return new we({tailShift:(s-a)*this.thousandsSeparator.length})}nearestInputPos(t,n){if(!this.thousandsSeparator)return t;switch(n){case ue.NONE:case ue.LEFT:case ue.FORCE_LEFT:{const r=this._findSeparatorAround(t-1);if(r>=0){const l=r+this.thousandsSeparator.length;if(t<l||this.value.length<=l||n===ue.FORCE_LEFT)return r}break}case ue.RIGHT:case ue.FORCE_RIGHT:{const r=this._findSeparatorAround(t);if(r>=0)return r+this.thousandsSeparator.length}}return t}doCommit(){if(this.value){const t=this.number;let n=t;this.min!=null&&(n=Math.max(n,this.min)),this.max!=null&&(n=Math.min(n,this.max)),n!==t&&(this.unmaskedValue=this.format(n,this));let r=this.value;this.normalizeZeros&&(r=this._normalizeZeros(r)),this.padFractionalZeros&&this.scale>0&&(r=this._padFractionalZeros(r)),this._value=r}super.doCommit()}_normalizeZeros(t){const n=this._removeThousandsSeparators(t).split(this.radix);return n[0]=n[0].replace(/^(\D*)(0*)(\d*)/,(r,l,a,s)=>l+s),t.length&&!/\d$/.test(n[0])&&(n[0]=n[0]+"0"),n.length>1&&(n[1]=n[1].replace(/0*$/,""),n[1].length||(n.length=1)),this._insertThousandsSeparators(n.join(this.radix))}_padFractionalZeros(t){if(!t)return t;const n=t.split(this.radix);return n.length<2&&n.push(""),n[1]=n[1].padEnd(this.scale,"0"),n.join(this.radix)}doSkipInvalid(t,n,r){n===void 0&&(n={});const l=this.scale===0&&t!==this.thousandsSeparator&&(t===this.radix||t===Ge.UNMASKED_RADIX||this.mapToRadix.includes(t));return super.doSkipInvalid(t,n,r)&&!l}get unmaskedValue(){return this._removeThousandsSeparators(this._normalizeZeros(this.value)).replace(this.radix,Ge.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(Ge.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)||Ge.EMPTY_VALUES.includes(t)&&Ge.EMPTY_VALUES.includes(this.typedValue))&&!(t===0&&this.value==="")}}Ar=Ge,Ge.UNMASKED_RADIX=".",Ge.EMPTY_VALUES=[...qe.EMPTY_VALUES,0],Ge.DEFAULTS={...qe.DEFAULTS,mask:Number,radix:",",thousandsSeparator:"",mapToRadix:[Ar.UNMASKED_RADIX],min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,scale:2,normalizeZeros:!0,padFractionalZeros:!1,parse:Number,format:o=>o.toLocaleString("en-US",{useGrouping:!1,maximumFractionDigits:20})},be.MaskedNumber=Ge;const On={MASKED:"value",UNMASKED:"unmaskedValue",TYPED:"typedValue"};function mo(o,t,n){t===void 0&&(t=On.MASKED),n===void 0&&(n=On.MASKED);const r=ht(o);return l=>r.runIsolated(a=>(a[t]=l,a[n]))}function Fr(o,t,n,r){return mo(t,n,r)(o)}be.PIPE_TYPE=On,be.createPipe=mo,be.pipe=Fr;class Mr extends Ke{get repeatFrom(){var t;return(t=Array.isArray(this.repeat)?this.repeat[0]:this.repeat===1/0?0:this.repeat)!=null?t:0}get repeatTo(){var t;return(t=Array.isArray(this.repeat)?this.repeat[1]:this.repeat)!=null?t:1/0}constructor(t){super(t)}updateOptions(t){super.updateOptions(t)}_update(t){var n,r,l;const{repeat:a,...s}=Ut(t);this._blockOpts=Object.assign({},this._blockOpts,s);const i=ht(this._blockOpts);this.repeat=(n=(r=a??i.repeat)!=null?r:this.repeat)!=null?n:1/0,super._update({mask:"m".repeat(Math.max(this.repeatTo===1/0&&((l=this._blocks)==null?void 0:l.length)||0,this.repeatFrom)),blocks:{m:i},eager:i.eager,overwrite:i.overwrite,skipInvalid:i.skipInvalid,lazy:i.lazy,placeholderChar:i.placeholderChar,displayChar:i.displayChar})}_allocateBlock(t){if(t<this._blocks.length)return this._blocks[t];if(this.repeatTo===1/0||this._blocks.length<this.repeatTo)return this._blocks.push(ht(this._blockOpts)),this.mask+="m",this._blocks[this._blocks.length-1]}_appendCharRaw(t,n){n===void 0&&(n={});const r=new we;for(let c=(l=(a=this._mapPosToBlock(this.displayValue.length))==null?void 0:a.index)!=null?l:Math.max(this._blocks.length-1,0),d,u;d=(s=this._blocks[c])!=null?s:u=!u&&this._allocateBlock(c);++c){var l,a,s,i;const p=d._appendChar(t,{...n,_beforeTailState:(i=n._beforeTailState)==null||(i=i._blocks)==null?void 0:i[c]});if(p.skip&&u){this._blocks.pop(),this.mask=this.mask.slice(1);break}if(r.aggregate(p),p.consumed)break}return r}_trimEmptyTail(t,n){var r,l;t===void 0&&(t=0);const a=Math.max(((r=this._mapPosToBlock(t))==null?void 0:r.index)||0,this.repeatFrom,0);let s;n!=null&&(s=(l=this._mapPosToBlock(n))==null?void 0:l.index),s==null&&(s=this._blocks.length-1);let i=0;for(let c=s;a<=c&&!this._blocks[c].unmaskedValue;--c,++i);i&&(this._blocks.splice(s-i+1,i),this.mask=this.mask.slice(i))}reset(){super.reset(),this._trimEmptyTail()}remove(t,n){t===void 0&&(t=0),n===void 0&&(n=this.displayValue.length);const r=super.remove(t,n);return this._trimEmptyTail(t,n),r}totalInputPositions(t,n){return t===void 0&&(t=0),n==null&&this.repeatTo===1/0?1/0:super.totalInputPositions(t,n)}get state(){return super.state}set state(t){this._blocks.length=t._blocks.length,this.mask=this.mask.slice(0,this._blocks.length),super.state=t}}be.RepeatBlock=Mr;try{globalThis.IMask=be}catch{}const Pn=Object.freeze(Object.defineProperty({__proto__:null,ChangeDetails:we,ChunksTailDetails:$t,DIRECTION:ue,HTMLContenteditableMaskElement:po,HTMLInputMaskElement:Vr,HTMLMaskElement:Zt,InputMask:Sr,MaskElement:In,Masked:qe,MaskedDate:yt,MaskedDynamic:en,MaskedEnum:tn,MaskedFunction:Nr,MaskedNumber:Ge,MaskedPattern:Ke,MaskedRange:Qt,MaskedRegExp:$r,PIPE_TYPE:On,PatternFixedDefinition:fo,PatternInputDefinition:Jt,RepeatBlock:Mr,createMask:ht,createPipe:mo,default:be,forceDirection:vr,normalizeOpts:Ut,pipe:Fr},Symbol.toStringTag,{value:"Module"})),Tm=async o=>{try{const t=new FormData;return t.append("unique","true"),t.append("file",o),(await(await fetch("/file/upload/uploads?id=&form=&table=",{method:"POST",body:t})).json())?.result}catch(t){console.error(t)}},Lm=async(o,t,n)=>{const r=t.clipboardData?.items;if(r){const l=t.clipboardData?.getData("text/html"),a=t.clipboardData?.getData("text/plain");if(l){const{state:s,dispatch:i}=o,{tr:c}=s,d=n.fromSchema(o.state.schema),u=new DOMParser().parseFromString(l,"text/html").body,p=d.parse(u),y=c.replaceSelectionWith(p);return i(y),t.preventDefault(),!0}if(a){const{state:s,dispatch:i}=o,{tr:c}=s,d=c.insertText(a,s.selection.from,s.selection.to);return i(d),t.preventDefault(),!0}for(let s=0;s<r.length;s++){const i=r[s];if(i.type.startsWith("image/")){const c=i.getAsFile();if(c){const d=await Tm(c),{schema:u}=o.state,p=u.nodes.image.create({src:d?.file_path}),y=o.state.tr.replaceSelectionWith(p);return o.dispatch(y),t.preventDefault(),!0}}}}return!1},Im="https://esm.sh",Ze="3.7.2",Dr="3.7.2",Rm=`?deps=@tiptap/core@${Ze},@tiptap/pm@${Dr}`,Je=o=>`${Im}/${o}${Rm}`,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@${Dr}/model`)},nn="__vs_form_tiptap_loader__",et=o=>import(o),Re=(o,t)=>o?.[t]||o?.default?.[t]||o?.default?.default?.[t]||o?.default||o,Tr={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;"},Om=o=>o.extend({addOptions(){return{...this.parent?.(),levels:[1,2,3,4,5,6]}}}).extend({addAttributes(){return{...this.parent?.(),level:{default:1,renderHTML:t=>{const n=t.level||1;return{class:`heading-level-${n}`,style:Tr[n]||Tr[1]}}}}}}),Pm=o=>o.configure({HTMLAttributes:{style:"min-height: 1rem;"}}),zm=(o,t,n,r,l)=>{const a=t.extend({renderHTML({HTMLAttributes:s}){return["div",{style:"overflow-x: auto;"},["table",s,0]]},parseHTML(){return[{tag:"div.table-wrapper table",priority:100},{tag:"table"}]}});return o.extend({addExtensions(){return[a.configure({HTMLAttributes:{class:"editor-content"},resizable:!0}),n,r,l]}})},jm=o=>o.extend({addAttributes(){return{...this.parent?.(),fontFamily:{default:null,parseHTML:t=>t.style.fontFamily?.replace(/['"]/g,""),renderHTML:t=>t.fontFamily?{style:`font-family: ${t.fontFamily}`}:{}},fontSize:{default:null,parseHTML:t=>t.style.fontSize?.replace(/['"]/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}},color:{default:null,parseHTML:t=>t.style.color?.replace(/['"]/g,""),renderHTML:t=>t.color?{style:`color: ${t.color}`}:{}},backgroundColor:{default:null,parseHTML:t=>t.style.backgroundColor?.replace(/['"]/g,""),renderHTML:t=>!t.backgroundColor||t.backgroundColor==="transparent"?{}:{style:`background-color: ${t.backgroundColor}`}}}},addCommands(){return{setFontFamily:t=>({chain:n})=>n().setMark("textStyle",{fontFamily:t}).run(),unsetFontFamily:()=>({chain:t})=>t().setMark("textStyle",{fontFamily:null}).removeEmptyTextStyle().run(),setFontSize:t=>({chain:n})=>n().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run(),setColor:t=>({chain:n})=>n().setMark("textStyle",{color:t}).run(),unsetColor:()=>({chain:t})=>t().setMark("textStyle",{color:null}).removeEmptyTextStyle().run(),setBackgroundColor:t=>({chain:n})=>n().setMark("textStyle",{backgroundColor:t}).run(),unsetBackgroundColor:()=>({chain:t})=>t().setMark("textStyle",{backgroundColor:null}).removeEmptyTextStyle().run()}}}),Um=o=>o.create({name:"iframe",group:"block",inline:!1,atom:!0,selectable:!0,addAttributes(){return{src:{default:null},width:{default:"100%"},height:{default:"280"},frameborder:{default:"0"},allow:{default:null},allowfullscreen:{default:null},referrerpolicy:{default:null},loading:{default:null},class:{default:null},title:{default:null},style:{default:null}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:t}){return["iframe",t]}});async function Hm(){if(typeof window>"u")return null;const o=window;return o[nn]||(o[nn]=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,n,r,l,a,s,i,c,d,u,p,y,k])=>{const m=Re(t,"Editor"),h=Re(t,"Node"),b=Re(t,"Extension"),_=Re(n,"StarterKit"),x=Re(r,"TextStyle"),v=Re(l,"TableKit"),N=Re(l,"Table"),U=Re(l,"TableRow"),W=Re(l,"TableCell"),L=Re(l,"TableHeader"),B=Re(a,"Highlight"),S=Re(s,"Subscript"),$=Re(i,"Superscript"),V=Re(c,"Link"),M=Re(d,"Image"),O=Re(u,"TextAlign"),E=Re(p,"Heading"),K=Re(y,"Paragraph"),T=Re(k,"DOMParser");if(!m||!h||!_||!x||!v||!N||!U||!W||!L||!B||!S||!$||!V||!M||!O||!E||!K||!T)throw new Error("Failed to resolve one or more Tiptap modules");return{Editor:m,Extension:b,ProseMirrorDOMParser:T,StarterKit:_,ExtendedTextStyle:jm(x),Highlight:B,Subscript:S,Superscript:$,Link:V,Image:M,TextAlign:O,CustomHeading:Om(E),CustomParagraph:Pm(K),CustomTableKit:zm(v,N,U,W,L),Iframe:Um(h)}}).catch(t=>{throw delete o[nn],t})),o[nn]}function qm(o){let t=!1;const n=e.shallowRef(null),r=e.ref(!1),l=e.ref(""),a=async(d,u="")=>{if(!d)return null;r.value=!0,l.value="";try{const p=await Hm();if(!p)return null;const y=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:(k,m)=>Lm(k,m,p.ProseMirrorDOMParser),handleKeyDown:(k,m)=>{if(m.key==="Tab"){const h=k.state,{$anchor:b}=h.selection;let _=!1;for(let x=b.depth;x>0;x--){const v=b.node(x);if(v&&(v.type.name==="bulletList"||v.type.name==="orderedList")){_=!0;break}}return _?!1:(m.preventDefault(),!0)}return!1}}});return n.value=e.markRaw(y),y}catch(p){return l.value="Failed to load rich text editor dependencies.",console.error("Failed to initialize rich text editor",p),null}finally{r.value=!1}},s=e.computed(()=>n.value||null);return e.watch(n,d=>{d&&n.value.on("update",u=>{if(!t){t=!0;const p=u.editor.getHTML();o.modelValue,setTimeout(()=>{t=!1},10)}})}),{editor:n,editorInstance:s,focusEditor:()=>{n.value&&!n.value.isFocused&&n.value.commands.focus()},createEditor:a,destroyEditor:()=>{n.value&&(n.value.destroy(),n.value=null)},isLoading:r,loadError:l}}function Km(o,t,n,{toEditorContent:r,toSourceContent:l}={}){const a=e.ref(!1),s=e.ref(""),i=e.ref(null);return{isHtmlMode:a,htmlContent:s,htmlTextarea:i,toggleHtmlMode:async u=>{if(a.value=u,u)o.value&&(s.value=l?await l(o.value.getHTML(),t):o.value.getHTML()),e.nextTick(()=>{i.value&&i.value.focus?.()});else if(o.value){const p=r?await r(s.value,t):s.value;o.value.commands.setContent(p,!0),e.nextTick(()=>{o.value?.commands?.focus?.()})}},onHtmlInput:u=>{s.value=u,n&&n("update:modelValue",u)}}}function Wm(){const o=e.ref(!1);return{isFullscreen:o,toggleFullscreen:()=>{o.value=!o.value}}}const Nt=o=>o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;"),on=o=>{let t=Nt(o||"");return t=t.replace(/!\[([^\]]*)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,r,l,a)=>{const s=a?` title="${Nt(a)}"`:"";return`<img src="${Nt(l)}" alt="${Nt(r)}"${s}>`}),t=t.replace(/\[([^\]]+)]\(([^)\s]+)(?:\s+"([^"]+)")?\)/g,(n,r,l,a)=>{const s=a?` title="${Nt(a)}"`:"";return`<a href="${Nt(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},rn=o=>/^\s*\d+\.\s+/.test(o),ho=o=>/^\s*[-*+]\s+/.test(o),Lr=o=>/^\s*[-*+]\s+\[[ xX]\]\s+/.test(o),go=o=>/^\s*>\s?/.test(o),yo=o=>/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-{3,}:?\s*\|?\s*$/.test(o),Ir=o=>o.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>on(t.trim())),Gm=(o,t)=>{const n=o[t],r=o[t+1];if(!n||!r||!n.includes("|")||!yo(r))return null;const l=Ir(n),a=[];let s=t+2;for(;s<o.length&&o[s].includes("|")&&o[s].trim()!=="";){const d=Ir(o[s]);a.push(`<tr>${d.map(u=>`<td>${u}</td>`).join("")}</tr>`),s+=1}const i=`<thead><tr>${l.map(d=>`<th>${d}</th>`).join("")}</tr></thead>`,c=a.length?`<tbody>${a.join("")}</tbody>`:"";return{html:`<table>${i}${c}</table>`,nextIndex:s}},Ym=(o,t)=>{const n=rn(o[t]),r=n?"ol":"ul",l=[];let a=t;for(;a<o.length;){const s=o[a];if(s.trim()===""||!(n?rn(s):(ho(s)||Lr(s))&&!rn(s)))break;const c=s.match(/^\s*[-*+]\s+\[([ xX])\]\s+(.*)$/);if(c){const d=c[1].toLowerCase()==="x";l.push(`<li><input type="checkbox" disabled${d?" checked":""}> ${on(c[2])}</li>`)}else{const d=s.replace(/^\s*(?:[-*+]|\d+\.)\s+/,"");l.push(`<li>${on(d)}</li>`)}a+=1}return{html:`<${r}>${l.join("")}</${r}>`,nextIndex:a}},Xm=(o,t)=>{const r=o[t].replace(/^```/,"").trim(),l=[];let a=t+1;for(;a<o.length&&!o[a].startsWith("```");)l.push(o[a]),a+=1;return{html:`<pre><code${r?` class="language-${Nt(r)}"`:""}>${Nt(l.join(`
6
+ `))}</code></pre>`,nextIndex:a<o.length?a+1:a}},Zm=(o,t)=>{const n=[];let r=t;for(;r<o.length;){const l=o[r];if(l.trim()===""||l.startsWith("```")||/^#{1,6}\s+/.test(l)||/^---+$/.test(l.trim())||/^\*\*\*+$/.test(l.trim())||go(l)||rn(l)||ho(l)||r+1<o.length&&l.includes("|")&&yo(o[r+1]))break;n.push(l.trim()),r+=1}return{html:`<p>${on(n.join(" "))}</p>`,nextIndex:r}},Rr=o=>{const n=(o||"").replace(/\r\n/g,`
7
7
  `).split(`
8
- `),r=[];let l=0;for(;l<n.length;){const a=n[l],s=a.trim();if(!s){l+=1;continue}if(a.startsWith("```")){const d=Xm(n,l);r.push(d.html),l=d.nextIndex;continue}const i=a.match(/^(#{1,6})\s+(.*)$/);if(i){const d=i[1].length;r.push(`<h${d}>${rn(i[2])}</h${d}>`),l+=1;continue}if(/^---+$/.test(s)||/^\*\*\*+$/.test(s)){r.push("<hr>"),l+=1;continue}if(a.includes("|")&&l+1<n.length&&go(n[l+1])){const d=Gm(n,l);if(d){r.push(d.html),l=d.nextIndex;continue}}if(ho(a)){const d=[];for(;l<n.length&&ho(n[l]);)d.push(n[l].replace(/^\s*>\s?/,"")),l+=1;r.push(`<blockquote>${Rr(d.join(`
9
- `))}</blockquote>`);continue}if(ln(a)||mo(a)||Lr(a)){const d=Ym(n,l);r.push(d.html),l=d.nextIndex;continue}const c=Zm(n,l);r.push(c.html),l=c.nextIndex}return r.join("")},yo=o=>(o.textContent||"").replace(/\u00a0/g," "),Or=o=>Array.from(o.childNodes).map(t=>bo(t)).join(""),Jm=o=>{const t=Array.from(o.querySelectorAll("tr"));if(!t.length)return"";const n=i=>`| ${Array.from(i.children).map(d=>Or(d).trim()).join(" | ")} |`,r=t[0],l=r?Array.from(r.children).length:0,a=`| ${Array(Math.max(l,1)).fill("---").join(" | ")} |`,s=t.slice(1).map(i=>n(i));return[n(r),a,...s].join(`
10
- `)},Pr=(o,t=!1)=>Array.from(o.children).filter(n=>n.nodeType===Node.ELEMENT_NODE).map((n,r)=>{const l=n,a=l.querySelector('input[type="checkbox"]'),s=Array.from(l.childNodes).filter(i=>!(i instanceof HTMLInputElement)).map(i=>bo(i)).join("").trim();return a?`- [${a.checked?"x":" "}] ${s}`:t?`${r+1}. ${s}`:`- ${s}`}).join(`
11
- `);function bo(o){if(o.nodeType===Node.TEXT_NODE)return yo(o);if(o.nodeType!==Node.ELEMENT_NODE)return"";const t=o,n=t.tagName.toLowerCase(),r=Or(t);switch(n){case"br":return`
8
+ `),r=[];let l=0;for(;l<n.length;){const a=n[l],s=a.trim();if(!s){l+=1;continue}if(a.startsWith("```")){const d=Xm(n,l);r.push(d.html),l=d.nextIndex;continue}const i=a.match(/^(#{1,6})\s+(.*)$/);if(i){const d=i[1].length;r.push(`<h${d}>${on(i[2])}</h${d}>`),l+=1;continue}if(/^---+$/.test(s)||/^\*\*\*+$/.test(s)){r.push("<hr>"),l+=1;continue}if(a.includes("|")&&l+1<n.length&&yo(n[l+1])){const d=Gm(n,l);if(d){r.push(d.html),l=d.nextIndex;continue}}if(go(a)){const d=[];for(;l<n.length&&go(n[l]);)d.push(n[l].replace(/^\s*>\s?/,"")),l+=1;r.push(`<blockquote>${Rr(d.join(`
9
+ `))}</blockquote>`);continue}if(rn(a)||ho(a)||Lr(a)){const d=Ym(n,l);r.push(d.html),l=d.nextIndex;continue}const c=Zm(n,l);r.push(c.html),l=c.nextIndex}return r.join("")},bo=o=>(o.textContent||"").replace(/\u00a0/g," "),Or=o=>Array.from(o.childNodes).map(t=>ko(t)).join(""),Jm=o=>{const t=Array.from(o.querySelectorAll("tr"));if(!t.length)return"";const n=i=>`| ${Array.from(i.children).map(d=>Or(d).trim()).join(" | ")} |`,r=t[0],l=r?Array.from(r.children).length:0,a=`| ${Array(Math.max(l,1)).fill("---").join(" | ")} |`,s=t.slice(1).map(i=>n(i));return[n(r),a,...s].join(`
10
+ `)},Pr=(o,t=!1)=>Array.from(o.children).filter(n=>n.nodeType===Node.ELEMENT_NODE).map((n,r)=>{const l=n,a=l.querySelector('input[type="checkbox"]'),s=Array.from(l.childNodes).filter(i=>!(i instanceof HTMLInputElement)).map(i=>ko(i)).join("").trim();return a?`- [${a.checked?"x":" "}] ${s}`:t?`${r+1}. ${s}`:`- ${s}`}).join(`
11
+ `);function ko(o){if(o.nodeType===Node.TEXT_NODE)return bo(o);if(o.nodeType!==Node.ELEMENT_NODE)return"";const t=o,n=t.tagName.toLowerCase(),r=Or(t);switch(n){case"br":return`
12
12
  `;case"p":return`${r.trim()}
13
13
 
14
- `;case"strong":case"b":return`**${r}**`;case"em":case"i":return`*${r}*`;case"del":case"s":return`~~${r}~~`;case"code":return t.parentElement?.tagName.toLowerCase()==="pre"?r:`\`${r}\``;case"pre":{const l=t.querySelector("code"),i=(l?.className||"").match(/language-([a-z0-9_-]+)/i)?.[1]||"",c=yo(l||t);return`\`\`\`${i}
14
+ `;case"strong":case"b":return`**${r}**`;case"em":case"i":return`*${r}*`;case"del":case"s":return`~~${r}~~`;case"code":return t.parentElement?.tagName.toLowerCase()==="pre"?r:`\`${r}\``;case"pre":{const l=t.querySelector("code"),i=(l?.className||"").match(/language-([a-z0-9_-]+)/i)?.[1]||"",c=bo(l||t);return`\`\`\`${i}
15
15
  ${c}
16
16
  \`\`\`
17
17
 
@@ -29,23 +29,23 @@ ${c}
29
29
 
30
30
  `;case"table":return`${Jm(t)}
31
31
 
32
- `;default:return r}}const zr=o=>{if(!o)return"";if(typeof window>"u"||typeof DOMParser>"u")return o;const n=new DOMParser().parseFromString(o,"text/html");return Array.from(n.body.childNodes).map(r=>bo(r)).join("").replace(/\n{3,}/g,`
32
+ `;default:return r}}const zr=o=>{if(!o)return"";if(typeof window>"u"||typeof DOMParser>"u")return o;const n=new DOMParser().parseFromString(o,"text/html");return Array.from(n.body.childNodes).map(r=>ko(r)).join("").replace(/\n{3,}/g,`
33
33
 
34
- `).trim()},Qm=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),eh=o=>{if(!o)return"";if(typeof window>"u"||typeof DOMParser>"u")return o;const n=new DOMParser().parseFromString(o,"text/html"),r=" ",l=(a,s)=>{if(a.nodeType===Node.TEXT_NODE){const b=(a.textContent||"").replace(/\s+/g," ").trim();return b?[`${r.repeat(s)}${b}`]:[]}if(a.nodeType!==Node.ELEMENT_NODE)return[];const i=a,c=i.tagName.toLowerCase(),d=Array.from(i.attributes).map(b=>`${b.name}="${b.value}"`).join(" "),u=d?`<${c} ${d}>`:`<${c}>`,p=`</${c}>`;if(Qm.has(c))return[`${r.repeat(s)}${u}`];const g=Array.from(i.childNodes).flatMap(b=>l(b,s+1));if(!g.length)return[`${r.repeat(s)}${u}${p}`];if(i.childNodes.length===1&&i.firstChild?.nodeType===Node.TEXT_NODE&&g.length===1){const b=g[0].trim();return[`${r.repeat(s)}${u}${b}${p}`]}return[`${r.repeat(s)}${u}`,...g,`${r.repeat(s)}${p}`]};return Array.from(n.body.childNodes).flatMap(a=>l(a,0)).join(`
35
- `)},ko=async(o,t)=>t!=="md"?o||"":Rr(o||""),th=async(o,t)=>t!=="md"?eh(o||""):zr(o||""),nh=async(o,t)=>t!=="md"?o||"":zr(o||""),oh=o=>String(o).trim().toLowerCase().split("-")[0],rh=()=>typeof window>"u"?"uk":oh(localStorage.getItem("language")||localStorage.getItem("locale")||navigator.language||"uk"),lh=(o,t)=>{const n=t.replace(/^form\.richtext\./,"");return io?.[o]?.form?.richtext?.[n]||io?.uk?.form?.richtext?.[n]||t},jr=o=>o.startsWith("form.richtext.")?o:`form.richtext.${o}`;function zn(){const t=e.getCurrentInstance()?.appContext?.config?.globalProperties,n=t?.$i18n;return{t:l=>{const a=t?.$t,s=t?.$te,i=typeof n?.te=="function"?n.te.bind(n):null;if(typeof a=="function"){const c=jr(l);if((typeof s=="function"?s(c):typeof i=="function"?i(c):null)!==!1){const u=a(c);if(u&&u!==c)return u}}return lh(rh(),jr(l))}}}const ah={components:{Quote:q.Quote},props:{editor:Object},methods:{toggleBlockquote(){this.editor&&this.editor.chain().toggleBlockquote().run()}}};function sh(o,t,n,r,l,a){const s=e.resolveComponent("Quote");return e.openBlock(),e.createElementBlock("button",{title:"Blockquote",onClick:t[0]||(t[0]=(...i)=>a.toggleBlockquote&&a.toggleBlockquote(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":n.editor?.isActive("blockquote")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const ih=ye(ah,[["render",sh]]),ch={components:{List:q.List},props:{editor:Object},methods:{toggleBulletList(){this.editor&&this.editor.chain().focus().toggleBulletList().run()}}};function dh(o,t,n,r,l,a){const s=e.resolveComponent("List");return e.openBlock(),e.createElementBlock("button",{title:"Bullet List",onClick:t[0]||(t[0]=(...i)=>a.toggleBulletList&&a.toggleBulletList(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("bulletList")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const uh=ye(ch,[["render",dh]]),ph={components:{ListOrdered:q.ListOrdered},props:{editor:Object},methods:{toggleOrderedList(){this.editor&&this.editor.chain().focus().toggleOrderedList().run()}}};function fh(o,t,n,r,l,a){const s=e.resolveComponent("ListOrdered");return e.openBlock(),e.createElementBlock("button",{title:"Ordered List",onClick:t[0]||(t[0]=(...i)=>a.toggleOrderedList&&a.toggleOrderedList(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("orderedList")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const mh=ye(ph,[["render",fh]]),hh={components:{CodeXml:q.CodeXml},props:{editor:Object},methods:{toggleCodeBlock(){this.editor&&this.editor.chain().focus().toggleCodeBlock().run()}}};function gh(o,t,n,r,l,a){const s=e.resolveComponent("CodeXml");return e.openBlock(),e.createElementBlock("button",{title:"Code Block",onClick:t[0]||(t[0]=(...i)=>a.toggleCodeBlock&&a.toggleCodeBlock(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("codeBlock")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const yh=ye(hh,[["render",gh]]),bh={components:{Bold:q.Bold},props:{editor:Object},methods:{toggleBold(){this.editor&&this.editor.commands.toggleBold()}}};function kh(o,t,n,r,l,a){const s=e.resolveComponent("Bold");return e.openBlock(),e.createElementBlock("button",{title:"Bold Text",onClick:t[0]||(t[0]=(...i)=>a.toggleBold&&a.toggleBold(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("bold")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Bold",-1))],2)}const xh=ye(bh,[["render",kh]]),wh={components:{Italic:q.Italic},props:{editor:Object},methods:{toggleItalic(){this.editor&&this.editor.chain().toggleItalic().run()}}};function _h(o,t,n,r,l,a){const s=e.resolveComponent("Italic");return e.openBlock(),e.createElementBlock("button",{title:"Italic Text",onClick:t[0]||(t[0]=(...i)=>a.toggleItalic&&a.toggleItalic(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("italic")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Italic",-1))],2)}const Ch=ye(wh,[["render",_h]]),vh={__name:"vs-editor-underline",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().toggleUnderline().run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Underline",onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.isActive("underline")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Underline),{class:"h-4 w-4"})],2))}},Eh={__name:"vs-editor-strike",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().toggleStrike().run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Strikethrough",onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.isActive("strike")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Strikethrough),{class:"h-4 w-4"})],2))}},Bh={components:{X:q.X},props:{visible:{type:Boolean,default:()=>!1},modelValue:{type:Boolean,default:()=>!1},title:{type:String,default:()=>""},size:{type:String,default:()=>""},closeClickBack:{type:Boolean,default:()=>!1}},emits:["update:visible","update:modelValue","onClose","confirm","cancel"],inheritAttrs:!1,name:"vs-dialog",mounted(){window.addEventListener("keydown",this.checkKey)},unmounted(){window.removeEventListener("keydown",this.checkKey)},computed:{hasSlot(){return!!this.$slots?.footer},checkSize(){return this.size==="small"?"md:w-5/12 w-9/12":this.size==="medium"?"md:w-6/12 w-9/12":"lg:w-7/12 w-11/12"}},methods:{checkKey({key:o}){o==="Escape"&&this.handleClose()},handleClose(){this.$emit("update:visible",!1),this.$emit("update:modelValue",!1),this.$emit("onClose")},handleConfirm(){this.$emit("confirm"),this.handleClose()},handleCancel(){this.$emit("cancel"),this.handleClose()},closeByClickBack(o,t){t&&o.target.classList.contains("vs-dialog-overlay")&&this.handleClose()}}},Vh={key:0,class:"vsTailwind ui-dialog__wrapper"},Sh={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},$h={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Nh={class:"ui-dialog__content p-4"},Ah={key:0,class:"flex justify-end gap-x-2"};function Mh(o,t,n,r,l,a){const s=e.resolveComponent("X");return e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.visible||n.modelValue?(e.openBlock(),e.createElementBlock("div",Vh,[e.createElementVNode("div",{onMousedown:t[1]||(t[1]=i=>a.closeByClickBack(i,n.closeClickBack)),class:"vs-dialog-overlay vs-dialog w-full h-full fixed top-0 start-0 z-[100001] bg-black bg-opacity-50"},[e.createVNode(e.Transition,{name:"content",appear:""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["ui-dialog__modal 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",[a.checkSize]])},[e.createElementVNode("div",Sh,[e.createElementVNode("h3",$h,e.toDisplayString(n.title),1),e.createElementVNode("button",{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",onClick:t[0]||(t[0]=(...i)=>a.handleClose&&a.handleClose(...i))},[t[2]||(t[2]=e.createElementVNode("span",{class:"sr-only"},"Close",-1)),e.createVNode(s,{class:"h-4 w-4 flex-shrink-0"})])]),e.createElementVNode("div",Nh,[e.renderSlot(o.$slots,"default",{},void 0,!0)]),a.hasSlot?(e.openBlock(),e.createElementBlock("div",Ah,[e.renderSlot(o.$slots,"footer",{handleClose:a.handleClose,handleConfirm:a.handleConfirm,handleCancel:a.handleCancel},void 0,!0)])):e.createCommentVNode("",!0)],2)]),_:3})],32)])):e.createCommentVNode("",!0)])}const Ur=ye(Bh,[["render",Mh],["__scopeId","data-v-56ad9010"]]),Fh=e.defineComponent({components:{IconClose:q.X,IconSearch:q.Search,IconEmail:q.Mail},inheritAttrs:!1,props:{icon:{type:String,default:()=>""},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},modelValue:{type:String,default:()=>""},placeholder:{type:String,default:()=>""},iconPosition:{type:String,default:()=>"right"},type:{type:String,default:()=>"text"},style:{type:Object,default:()=>null},size:{type:String,default:()=>"md"},attrs:{type:Object,default:()=>{}}},emits:["onInput","update:modelValue","blur","focus"],computed:{checkSize(){return(this.style?.size||this.size)==="xs"?"h-[32px] text-sm":(this.style?.size||this.size)==="md"?"h-[38px] text-sm":(this.style?.size||this.size)==="lg"?"h-[46px] text-[20px]":"h-[38px] text-sm"},value:{get(){return this.modelValue},set(o){this.$emit("update:modelValue",o.trim())}},clearIconStyle(){return[{"right-8":this.icon&&this.iconPosition==="right","right-3":!this.icon||this.iconPosition!=="right","pointer-events-none":this.disabled}]},iconStylePosition(){return[{"left-3":this.icon&&this.iconPosition==="left","right-3":this.icon&&this.iconPosition==="right"}]},inputStyle(){return[{"!pr-8":this.clearable&&!this.icon,"!pr-7":this.clearable,"!pr-16":this.clearable&&this.icon&&this.iconPosition==="right","!pl-8":this.icon&&this.iconPosition==="left","!pr-[50px]":this.clearable&&this.value&&this.icon&&this.iconPosition==="right","!cursor-not-allowed bg-slate-100":this.disabled,"bg-white":!this.disabled}]}},methods:{handleInput(){this.$emit("onInput",this.modelValue)},handleBlur(){this.$emit("blur")},handleFocus(){this.$emit("focus")},clearInput(){this.$emit("update:modelValue",""),this.$emit("onInput","")},async inputFocus(){await this.$refs.vsText?.focus()}}}),Dh={class:"vs-form-text relative bg-white rounded-lg"},Th={key:2,class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},Lh=["disabled","type","placeholder"];function Ih(o,t,n,r,l,a){const s=e.resolveComponent("IconClose"),i=e.resolveComponent("IconSearch"),c=e.resolveComponent("IconEmail");return e.openBlock(),e.createElementBlock("div",Dh,[o.clearable&&o.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:t[0]||(t[0]=(...d)=>o.clearInput&&o.clearInput(...d))},[e.createVNode(s,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):e.createCommentVNode("",!0),o.icon&&o.icon==="search"?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute bottom-2/4 translate-y-2/4 cursor-pointer",o.iconStylePosition])},[e.createVNode(i,{class:"h-4 w-4 stroke-gray-500 transition-all"})],2)):o.icon&&o.icon==="email"?(e.openBlock(),e.createElementBlock("div",Th,[e.createVNode(c,{class:"h-4 w-4 stroke-gray-500 transition-all"})])):(e.openBlock(),e.createElementBlock("i",{key:3,class:e.normalizeClass(["absolute bottom-2/4 translate-y-2/4 text-gray-500 cursor-pointer",["ti "+o.icon,o.iconStylePosition]])},null,2)),o.clearable&&o.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:t[1]||(t[1]=(...d)=>o.clearInput&&o.clearInput(...d))},[e.createVNode(s,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({ref:"vsText",disabled:o.disabled,type:o.type,onInput:t[2]||(t[2]=(...d)=>o.handleInput&&o.handleInput(...d)),placeholder:o.placeholder,"onUpdate:modelValue":t[3]||(t[3]=d=>o.value=d)},o.style?.attrs||o.attrs||{},{onFocus:t[4]||(t[4]=(...d)=>o.handleFocus&&o.handleFocus(...d)),onBlur:t[5]||(t[5]=(...d)=>o.handleBlur&&o.handleBlur(...d)),class:[[o.inputStyle,o.checkSize],"py-2 px-3 block w-full border border-solid placeholder:text-nowrap border-stone-200 rounded-lg text-sm 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,16,Lh),[[e.vModelDynamic,o.value]])])}const Hr=ye(Fh,[["render",Ih],["__scopeId","data-v-eb21a54f"]]),Rh=["title"],Oh={class:"flex flex-col gap-3 p-[20px]"},Ph={class:"relative flex items-center gap-2"},zh={class:"flex-1"},jh={key:0,class:"flex items-center gap-2 flex-shrink-0"},Uh=["title"],Hh=["title"],qh={class:"flex items-center gap-2"},Kh={for:"openInNewTab",class:"text-sm text-gray-700 cursor-pointer"},Wh={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Gh=Object.assign({inheritAttrs:!1},{__name:"vs-editor-link",props:{editor:Object},setup(o){const{t}=zn(),n=o,r=e.ref(!1),l=e.ref(""),a=e.ref(!1),s=e.ref(!1),i=()=>{if(!n.editor)return;n.editor.chain().focus().extendMarkRange("link").run();const g=n.editor.getAttributes("link");g.href?(a.value=!0,l.value=g.href,s.value=g.target==="_blank"):(a.value=!1,l.value="",s.value=!1),r.value=!0},c=()=>{r.value=!1,l.value="",a.value=!1,s.value=!1},d=()=>{if(!n.editor||!l.value.trim())return;let g=l.value.trim();g.match(/^https?:\/\//i)||(g="https://"+g),n.editor.chain().focus().setLink({href:g,target:s.value?"_blank":null}).run(),c()},u=()=>{n.editor&&(n.editor.chain().focus().unsetLink().run(),c())},p=()=>{if(!l.value)return;let g=l.value.trim();g.match(/^https?:\/\//i)||(g="https://"+g),window.open(g,"_blank","noopener,noreferrer")};return(g,b)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{title:e.unref(t)("form.richtext.link")||"Посилання",onClick:i,class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":o.editor?.isActive("link")}])},[e.createVNode(e.unref(q.Link2),{class:"h-4 w-4"})],10,Rh),e.createVNode(Ur,{title:a.value?e.unref(t)("form.richtext.editLink")||"Редагувати посилання":e.unref(t)("form.richtext.linkTitle")||"Додати посилання",visible:r.value,"onUpdate:visible":b[2]||(b[2]=m=>r.value=m),size:"small"},{footer:e.withCtx(()=>[e.createElementVNode("div",Wh,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:c,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"},e.toDisplayString(e.unref(t)("form.richtext.cancel")||"Скасувати"),1),e.createElementVNode("button",{onClick:d,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"},e.toDisplayString(a.value?e.unref(t)("form.richtext.update")||"Оновити":e.unref(t)("form.richtext.create")||"Створити"),1)])]),default:e.withCtx(()=>[e.createElementVNode("div",Oh,[e.createElementVNode("div",Ph,[e.createElementVNode("div",zh,[e.createVNode(Hr,{modelValue:l.value,"onUpdate:modelValue":b[0]||(b[0]=m=>l.value=m),placeholder:e.unref(t)("form.richtext.linkUrl")||"Введіть URL",class:"w-full"},null,8,["modelValue","placeholder"])]),a.value?(e.openBlock(),e.createElementBlock("div",jh,[e.createElementVNode("button",{onClick:p,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none transition-colors",title:e.unref(t)("form.richtext.openLink")||"Відкрити посилання"},[e.createVNode(e.unref(q.ExternalLink),{class:"h-4 w-4"})],8,Uh),e.createElementVNode("button",{onClick:u,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-red-600 hover:bg-red-50 focus:outline-none transition-colors",title:e.unref(t)("form.richtext.removeLink")||"Видалити посилання"},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Hh)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",qh,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"openInNewTab","onUpdate:modelValue":b[1]||(b[1]=m=>s.value=m),class:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"},null,512),[[e.vModelCheckbox,s.value]]),e.createElementVNode("label",Kh,e.toDisplayString(e.unref(t)("form.richtext.openInNewTab")||"Відкривати в новій вкладці"),1)])])]),_:1},8,["title","visible"])],64))}}),an=async(o,t,n,r=10)=>{if(!t||!n)return;await e.nextTick();const l=await n?.getBoundingClientRect(),a=await t?.getBoundingClientRect();if(!a||!l)return;const s=await parseInt(t?.getBoundingClientRect()?.height),i=await parseInt(t?.getBoundingClientRect()?.width),c=await parseInt(n?.getBoundingClientRect()?.height),d=await parseInt(n?.getBoundingClientRect()?.width),u=await window.innerHeight,p=await window.innerWidth;let g=0,b=0;const m=a.bottom+r+c;switch(o){case"top":a.top-l.height-r<0?g=a.top-l.height+r+c+s:g=a.top-l.height-r,p>d+a.right+30?b=a.left-l.width/2+a.width/2:b=p-30-d;break;case"bottom":u>m?g=a.bottom+r:g=a.bottom-r-c-s,b=a.left-l.width/2+a.width/2;break;case"left":g=a.top-l.height/2+a.height/2,a.left-l.width-r>0?b=a.left-l.width-r:b=10;break;case"right":g=a.top-l.height/2+a.height/2,p-i>d?b=a.right+r:b=p-30-d;break;case"top-right":a.top-l.height-r<0?g=a.top-l.height+r+c+s:g=a.top-l.height-r,p-i>d?b=a.right+r:b=p-30-d;break;case"top-left":a.top-l.height-r<0?g=a.top-l.height+r+c+s:g=a.top-l.height-r,a.left-l.width-r>0?b=a.left-l.width-r:b=10;break;case"top-start":a.top-l.height-r<0?g=a.top-l.height+r+c+s:g=a.top-l.height-r,a.left>0?b=a.left:b=10;break;case"bottom-right":u>m?g=a.bottom+r:g=a.bottom-r-c-s,p-i>d?b=a.left:b=p-30-d;break;case"bottom-left":u>m?g=a.bottom+r:g=a.bottom-r-c-s,a.left>0?b=a.right-d:b=10;break;case"bottom-start":u>m?g=a.bottom+r:g=a.bottom-r-c-s,a.left>0?b=a.left:b=10;break}g+c>u?g=u-c-r:g<0&&(g=r),b+d>p?b=p-d-r:b<0&&(b=r),n instanceof HTMLElement&&(n.style.top=`${g}px`,n.style.left=`${b}px`,n.style.position="fixed")},Yh={class:"text-center"},Xh={class:"py-2 px-4 w-full text-sm text-stone-800 bg-white shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-lg focus:outline-none focus:bg-stone-100 dark:bg-neutral-900 dark:text-neutral-200 dark:focus:bg-neutral-800 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full"},Mt=Object.assign({inheritAttrs:!1},{__name:"vs-popover",props:{isOpen:{type:Boolean,default:()=>!1},placement:{type:String,default:"top"},gap:{type:Number,default:8},width:{type:[String,Number],default:""},disabled:{type:Boolean,default:!1},trigger:{type:String,default:"click"},teleport:{type:String,default:"body"}},emits:["isvisible"],setup(o,{expose:t,emit:n}){const r=o,l=n,a=e.ref(!1),s=e.ref([]),i=e.ref(null),c=e.ref(null),d=e.ref(null);e.watch(a,C=>{C?(u(),window.addEventListener("resize",()=>an(r.placement,c.value,d.value)),an(r.placement,c.value,d.value)):window.removeEventListener("resize",()=>an(r.placement,c.value,d.value)),l("isvisible",C)}),e.onMounted(()=>{window.addEventListener("click",y),window.addEventListener("popstate",w),window.addEventListener("scroll",x,!0),u()}),e.onBeforeUnmount(()=>{window.removeEventListener("click",y),window.removeEventListener("popstate",w),p()});const u=()=>{let C=i.value;for(;C&&C!==document.body;)(C.scrollHeight>C.clientHeight||C.scrollWidth>C.clientWidth)&&(C.addEventListener("scroll",h),s.value.push(C)),C=C.parentElement;document.body&&(document.body.addEventListener("scroll",h),s.value.push(document.body))},p=()=>{s.value.forEach(C=>{C.removeEventListener("scroll",h)}),s.value=[]},g=()=>{a.value=!0,an(r.placement,c.value,d.value)},b=()=>{a.value=!1},m=async()=>{await an(r.placement,c.value,d.value),a.value=!a.value},h=()=>{a.value=!1},y=C=>{if(!C){a.value=!1;return}c.value?.contains(C.target)||d.value?.contains(C.target)||(a.value=!1)},w=()=>{a.value&&(a.value=!1)},x=C=>{a.value&&d.value&&!d.value.contains(C.target)&&(a.value=!1)};return t({togglePopover:m}),(C,S)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"popover",ref:i,class:"vs-popover inline-block"},[e.createElementVNode("div",Yh,[o.trigger==="click"?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"popoverRef",ref:c,onClick:m,class:e.normalizeClass({"pointer-events-none":o.disabled})},[e.renderSlot(C.$slots,"reference",{},()=>[S[0]||(S[0]=e.createElementVNode("button",null,"Click me!",-1))])],2)):e.createCommentVNode("",!0),o.trigger==="hover"?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"popoverRef",ref:c,onMouseover:g,onMouseleave:b,class:e.normalizeClass({"pointer-events-none":o.disabled})},[e.renderSlot(C.$slots,"reference",{},()=>[S[1]||(S[1]=e.createElementVNode("button",null,"Click me!",-1))])],34)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.Teleport,{to:o.teleport},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["vsTailwind vs-popover__content",o.placement]),ref_key:"contentPop",ref:d,style:e.normalizeStyle({width:o.width?o.width+"px":"fit-content",zIndex:100001})},[e.createElementVNode("div",Xh,[e.renderSlot(C.$slots,"default",{},()=>[S[2]||(S[2]=e.createElementVNode("span",null,"Popover content",-1))])])],6),[[e.vShow,a.value]])]),_:3})],8,["to"]))])],512))}}),Zh={class:"flex flex-col gap-[2px] p-[2px]"},Jh=["onClick"],Qh={__name:"vs-editor-table",props:{editor:Object},setup(o){const{t}=zn(),n=o,r=e.ref(!1),l=e.ref("popover"),a=()=>{n.editor&&(n.editor.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),l.value.togglePopover())},s=()=>{n.editor&&(n.editor.chain().focus().addColumnAfter().run(),l.value.togglePopover())},i=()=>{n.editor&&(n.editor.chain().focus().addRowAfter().run(),l.value.togglePopover())},c=()=>{n.editor&&(n.editor.chain().focus().deleteColumn().run(),l.value.togglePopover())},d=()=>{n.editor&&(n.editor.chain().focus().deleteRow().run(),l.value.togglePopover())},u=()=>{n.editor&&(n.editor.chain().focus().deleteTable().run(),l.value.togglePopover())},p=()=>{n.editor&&(n.editor.chain().focus().mergeCells().run(),l.value.togglePopover())},g=()=>{n.editor&&(n.editor.chain().focus().splitCell().run(),l.value.togglePopover())},b=e.computed(()=>[{text:t("form.richtext.createTable"),function:a},{text:t("form.richtext.addColumn"),function:s},{text:t("form.richtext.addRow"),function:i},{text:t("form.richtext.deleteColumn"),function:c},{text:t("form.richtext.deleteRow"),function:d},{text:t("form.richtext.deleteTable"),function:u},{text:t("form.richtext.mergeCells"),function:p},{text:t("form.richtext.splitCells"),function:g}]);return(m,h)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:l,placement:"bottom",onIsvisible:h[0]||(h[0]=y=>r.value=y)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Table",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[r.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Table2),{class:"h-4 w-4"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",Zh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,(y,w)=>(e.openBlock(),e.createElementBlock("button",{key:w,onClick:y?.function,class:"px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded"},e.toDisplayString(y.text),9,Jh))),128))])]),_:1},512))}},eg={class:"flex gap-[4px] p-1"},tg=["title","onClick"],ng={__name:"vs-editor-align",props:{editor:Object},setup(o){const t=o,n={left:q.AlignLeft,center:q.AlignCenter,right:q.AlignRight,justify:q.AlignJustify},r=e.ref(!1),l=e.ref("popover"),a=e.ref("left"),s=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"left"})||t.editor.isActive("heading",{textAlign:"left"}):!1),i=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"right"})||t.editor.isActive("heading",{textAlign:"right"}):!1),c=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"center"})||t.editor.isActive("heading",{textAlign:"center"}):!1),d=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"justify"})||t.editor.isActive("heading",{textAlign:"justify"}):!1),u=e.computed(()=>s.value||i.value||c.value||d.value),p=()=>{i.value?a.value="right":c.value?a.value="center":d.value?a.value="justify":a.value="left"};e.watch([s,i,c,d],()=>{p()},{immediate:!0}),e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",p),t.editor.on("update",p))}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",p),t.editor.off("update",p))});const g=m=>{t.editor&&(t.editor.chain().focus().setTextAlign(m).run(),a.value=m)},b=e.ref([{id:"left",isActive:s},{id:"center",isActive:c},{id:"right",isActive:i},{id:"justify",isActive:d}]);return(m,h)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:l,placement:"bottom",onIsvisible:h[0]||(h[0]=y=>r.value=y)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Text Align",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[u.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[a.value]),{height:"16",width:"16"}))],2)]),default:e.withCtx(()=>[e.createElementVNode("div",eg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.value,y=>(e.openBlock(),e.createElementBlock("button",{title:"Text align "+y?.id,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":y?.isActive}]),key:y?.id,onClick:w=>g(y?.id)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[y?.id]),{height:"16",width:"16"}))],10,tg))),128))])]),_:1},512))}},og={class:"flex flex-col gap-[2px] p-[2px]"},rg=["onClick"],lg={__name:"vs-editor-type-tag",props:{editor:Object},setup(o){const{t}=zn(),n=o,r=e.ref(!1),l=e.ref("popover"),a=()=>{n.editor&&(n.editor?.chain().focus().setParagraph().run(),l.value.togglePopover())},s=c=>{n.editor&&(n.editor?.chain().focus().toggleHeading({level:c}).run(),l.value.togglePopover())},i=e.computed(()=>[{text:t("form.richtext.heading1"),id:1,style:"font-[700] text-[30px]"},{text:t("form.richtext.heading2"),id:2,style:"font-[700] text-[26px]"},{text:t("form.richtext.heading3"),id:3,style:"font-[700] text-[22px]"},{text:t("form.richtext.heading4"),id:4,style:"font-[700] text-[18px]"},{text:t("form.richtext.heading5"),id:5,style:"font-[500] text-[16px]"},{text:t("form.richtext.heading6"),id:6,style:"font-[400] text-[14px]"}]);return(c,d)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:l,placement:"bottom",onIsvisible:d[0]||(d[0]=u=>r.value=u)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Type Tag",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[r.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Type),{class:"h-4 w-4"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",og,[e.createElementVNode("button",{onClick:a,class:e.normalizeClass(["px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded",[o.editor?.isActive("paragraph")?"bg-gray-100":""]])},e.toDisplayString(e.unref(t)("form.richtext.paragraph")),3),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(u,p)=>(e.openBlock(),e.createElementBlock("button",{key:p,onClick:g=>s(u?.id),class:e.normalizeClass(["px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded leading-[100%]",[u?.style,o.editor?.isActive("heading",{level:u?.id})?"bg-gray-100":""]])},e.toDisplayString(e.unref(t)(`form.richtext.heading${u?.id}`)),11,rg))),128))])]),_:1},512))}},ag={components:{VsText:Hr},inheritAttrs:!1,events:["update:modelValue"],props:{modelValue:{type:String},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},isTextInputShown:{type:Boolean,default:()=>!0}},computed:{value:{get(){return this.modelValue??""},set(o){this.$emit("update:modelValue",o)}}}},sg={class:"flex items-center w-full max-w-[182px]"},ig=["disabled"];function cg(o,t,n,r,l,a){const s=e.resolveComponent("vs-text");return e.openBlock(),e.createElementBlock("div",sg,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=i=>a.value=i),type:"color",class:e.normalizeClass(["w-[38px] h-[38px] min-h-[38px] min-w-[38px] py-[2px] px-[3px] -ml-1 dark:bg-neutral-800 border dark:border-neutral-700 border-stone-200 rounded-lg",n.disabled?"cursor-not-allowed":"cursor-pointer"]),disabled:n.disabled},null,10,ig),[[e.vModelText,a.value]]),n.isTextInputShown?(e.openBlock(),e.createBlock(s,{key:0,modelValue:a.value,"onUpdate:modelValue":t[1]||(t[1]=i=>a.value=i),class:"ml-2 w-full",disabled:n.disabled,clearable:n.clearable},null,8,["modelValue","disabled","clearable"])):e.createCommentVNode("",!0)])}const qr=ye(ag,[["render",cg]]),dg={class:"flex gap-[4px] mb-[8px]"},ug={class:"grid grid-rows-3 grid-cols-7"},pg={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},fg=["onClick","title"],mg={__name:"vs-editor-color",props:{editor:Object},setup(o){const t=o,n=e.ref(null),r=e.ref("#000000"),l=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").color||"#000000"),a=e.computed(()=>l.value!=="#000000"),s=()=>{t.editor&&(r.value=l.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const i=e.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),c=p=>{t.editor&&(t.editor.chain().focus().setColor(p).run(),r.value=p,n.value&&n.value.togglePopover())},d=()=>{c(r.value)},u=p=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple","#FFFFFF":"White","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[p]||p;return(p,g)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Text Color",class:e.normalizeClass(["flex flex-col h-[30px] min-w-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":a.value}])},[g[1]||(g[1]=e.createElementVNode("span",{class:"leading-none"},"A",-1)),e.createElementVNode("span",{class:"block h-1 w-5",style:e.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("div",dg,[e.createVNode(qr,{modelValue:r.value,"onUpdate:modelValue":g[0]||(g[0]=b=>r.value=b)},null,8,["modelValue"]),e.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[e.createVNode(e.unref(q.Check),{class:"h-4 w-4 text-white"})])]),e.createElementVNode("div",ug,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,b=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[e.createElementVNode("div",pg,[e.createElementVNode("button",{class:"flex items-center justify-center w-full h-full",style:e.normalizeStyle({backgroundColor:b}),onClick:m=>c(b),title:u(b)},[r.value===b?(e.openBlock(),e.createBlock(e.unref(q.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],12,fg)])]))),128))])])]),_:1},512))}},hg={class:"flex gap-[4px] mb-[8px]"},gg={class:"grid grid-rows-3 grid-cols-7"},yg={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},bg=["onClick","title"],kg=["onClick","title"],xg={__name:"vs-editor-background-color",props:{editor:Object},setup(o){const t=o,n=e.ref(null),r=e.ref("transparent"),l=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").backgroundColor||"transparent"),a=e.computed(()=>l.value!=="transparent"&&l.value!==""),s=()=>{t.editor&&(r.value=l.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const i=e.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),c=p=>{t.editor&&(t.editor.chain().focus().setBackgroundColor(p).run(),r.value=p,n.value&&n.value.togglePopover())},d=()=>{c(r.value)},u=p=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple",transparent:"Transparent","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[p]||p;return(p,g)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Background Color",class:e.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":a.value}])},[e.createVNode(e.unref(q.PaintBucket),{class:"h-4 w-4"}),e.createElementVNode("span",{class:"block h-1 w-5",style:e.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("div",hg,[e.createVNode(qr,{modelValue:r.value,"onUpdate:modelValue":g[0]||(g[0]=b=>r.value=b)},null,8,["modelValue"]),e.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[e.createVNode(e.unref(q.Check),{class:"h-4 w-4 text-white"})])]),e.createElementVNode("div",gg,[e.createElementVNode("button",{onClick:g[1]||(g[1]=b=>c("transparent")),class:"col-span-7 flex items-center justify-center gap-2 bg-gray-100 rounded-md py-1 mb-2 hover:bg-gray-200"},[e.createVNode(e.unref(q.Eraser),{class:"h-4 w-4"}),g[2]||(g[2]=e.createElementVNode("p",null,"no color",-1))]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,b=>(e.openBlock(),e.createElementBlock("div",{key:b,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[e.createElementVNode("div",yg,[b!=="transparent"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"flex items-center justify-center w-full h-full",style:e.normalizeStyle({backgroundColor:b}),onClick:m=>c(b),title:u(b)},[r.value===b?(e.openBlock(),e.createBlock(e.unref(q.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],12,bg)):e.createCommentVNode("",!0),b==="transparent"?(e.openBlock(),e.createElementBlock("button",{key:1,class:"flex items-center justify-center w-full h-full",onClick:m=>c(b),title:u(b)},[r.value===b?(e.openBlock(),e.createBlock(e.unref(q.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],8,kg)):e.createCommentVNode("",!0)])]))),128))])])]),_:1},512))}},wg={__name:"vs-editor-highlight",props:{editor:Object},setup(o){const t=o,n=e.computed(()=>t.editor?.isActive("highlight")),r=()=>{t.editor&&t.editor.chain().focus().toggleHighlight().run()};return(l,a)=>(e.openBlock(),e.createElementBlock("button",{title:"Highlight",onClick:r,class:e.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-200":n.value}])},[e.createVNode(e.unref(q.Highlighter),{class:"h-4 w-4"})],2))}},_g={class:"truncate"},Cg={class:"w-[200px]"},vg={class:"max-h-[200px] overflow-y-auto"},Eg=["onClick"],Bg={__name:"vs-editor-font-family",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref(!1),l=e.ref([{label:"Arial",value:"Arial, sans-serif"},{label:"Helvetica",value:"Helvetica, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Courier New",value:"Courier New, monospace"},{label:"Comic Sans MS",value:"Comic Sans MS, cursive"},{label:"Impact",value:"Impact, sans-serif"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Palatino",value:"Palatino, serif"}]),a=e.computed(()=>{if(!t.editor)return"Arial, sans-serif";for(const d of l.value)if(t.editor.isActive("textStyle",{fontFamily:d.value}))return d.value;return"Arial, sans-serif"}),s=e.computed(()=>l.value.find(u=>u.value===a.value)?.label||"Arial"),i=d=>t.editor?t.editor.isActive("textStyle",{fontFamily:d}):!1,c=d=>{t.editor&&(t.editor.chain().focus().setFontFamily(d).run(),n.value&&n.value.togglePopover())};return(d,u)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:n,placement:"bottom",onIsvisible:u[0]||(u[0]=p=>r.value=p)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Font Family",class:e.normalizeClass(["h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm",[r.value?"bg-gray-100 text-gray-900":"text-gray-700"]]),style:e.normalizeStyle({fontFamily:a.value})},[e.createElementVNode("span",_g,e.toDisplayString(s.value),1),e.createVNode(e.unref(q.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})],6)]),default:e.withCtx(()=>[e.createElementVNode("div",Cg,[e.createElementVNode("ul",vg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,p=>(e.openBlock(),e.createElementBlock("li",{key:p.value,class:e.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",{"bg-gray-100":i(p.value)}]),style:e.normalizeStyle({fontFamily:p.value}),onClick:g=>c(p.value)},e.toDisplayString(p.label),15,Eg))),128))])])]),_:1},512))}},Vg={class:"w-[120px]"},Sg={class:"max-h-[200px] overflow-y-auto"},$g=["onClick"],Ng={__name:"vs-editor-font-size",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref("14px"),l=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").fontSize||"14px"),a=e.computed(()=>l.value!=="14px"),s=()=>{t.editor&&(r.value=l.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const i=e.ref([{label:"8px",value:"8px"},{label:"9px",value:"9px"},{label:"10px",value:"10px"},{label:"11px",value:"11px"},{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"20px",value:"20px"},{label:"24px",value:"24px"},{label:"28px",value:"28px"},{label:"32px",value:"32px"},{label:"36px",value:"36px"},{label:"48px",value:"48px"},{label:"72px",value:"72px"}]),c=d=>{t.editor&&(t.editor.chain().focus().setFontSize(d).run(),r.value=d,n.value&&n.value.togglePopover())};return(d,u)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Font Size",class:e.normalizeClass(["h-[30px] px-2 min-w-[30px] rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700 space-x-1",{"bg-gray-100 text-gray-900":a.value}])},[e.createVNode(e.unref(q.ALargeSmall),{class:"h-4 w-4"}),e.createVNode(e.unref(q.ChevronDown),{class:"h-3 w-3 text-gray-400"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",Vg,[e.createElementVNode("ul",Sg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,p=>(e.openBlock(),e.createElementBlock("li",{key:p.value,class:"px-3 py-2 hover:bg-gray-100 cursor-pointer",onClick:g=>c(p.value)},e.toDisplayString(p.label),9,$g))),128))])])]),_:1},512))}},Ag={components:{Superscript:q.Superscript},props:{editor:Object},methods:{toggleSuperscript(){this.editor&&this.editor.commands.toggleSuperscript()}}};function Mg(o,t,n,r,l,a){const s=e.resolveComponent("Superscript");return e.openBlock(),e.createElementBlock("button",{title:"Superscript",onClick:t[0]||(t[0]=(...i)=>a.toggleSuperscript&&a.toggleSuperscript(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("superscript")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Superscript",-1))],2)}const Fg=ye(Ag,[["render",Mg]]),Dg={components:{Subscript:q.Subscript},props:{editor:Object},methods:{toggleSubscript(){this.editor&&this.editor.commands.toggleSubscript()}}};function Tg(o,t,n,r,l,a){const s=e.resolveComponent("Subscript");return e.openBlock(),e.createElementBlock("button",{title:"Subscript",onClick:t[0]||(t[0]=(...i)=>a.toggleSubscript&&a.toggleSubscript(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("subscript")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Subscript",-1))],2)}const Lg=ye(Dg,[["render",Tg]]),Ig={title:"Heading",class:"h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700"},Rg={class:"truncate"},Og={class:"max-h-[200px] overflow-y-auto"},Pg=["onClick"],zg=ye({__name:"vs-editor-heading",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref([{label:"Heading 1",value:1},{label:"Heading 2",value:2},{label:"Heading 3",value:3},{label:"Heading 4",value:4},{label:"Heading 5",value:5},{label:"Heading 6",value:6}]),l=e.computed(()=>{if(!t.editor)return"Paragraph";for(let c=1;c<=6;c++)if(t.editor.isActive("heading",{level:c}))return`H ${c}`;return"P"}),a=c=>({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;"})[c]||"",s=c=>{t.editor&&(t.editor.chain().focus().setHeading({level:c}).run(),n.value&&n.value.togglePopover())},i=()=>{t.editor&&(t.editor.chain().focus().setParagraph().run(),n.value&&n.value.togglePopover())};return(c,d)=>(e.openBlock(),e.createBlock(Mt,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",Ig,[e.createElementVNode("span",Rg,e.toDisplayString(l.value),1),e.createVNode(e.unref(q.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("ul",Og,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,u=>(e.openBlock(),e.createElementBlock("li",{key:u.value,class:e.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",`heading-level-${u.value}`]),style:e.normalizeStyle(a(u.value)),onClick:p=>s(u.value)},e.toDisplayString(u.label),15,Pg))),128)),e.createElementVNode("li",{class:"px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm border-t border-gray-200 mt-1 pt-2",onClick:i}," Paragraph ")])])]),_:1},512))}},[["__scopeId","data-v-96f02f2a"]]),jg={components:{RemoveFormatting:q.RemoveFormatting},props:{editor:Object},methods:{clearFormatting(){this.editor&&this.editor.commands.unsetAllMarks()}}};function Ug(o,t,n,r,l,a){const s=e.resolveComponent("RemoveFormatting");return e.openBlock(),e.createElementBlock("button",{title:"Clear Formatting",onClick:t[0]||(t[0]=(...i)=>a.clearFormatting&&a.clearFormatting(...i)),class:"h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100"},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Clear Formatting",-1))])}const Hg=ye(jg,[["render",Ug]]),qg={class:"relative"},Kg={key:0,class:"mt-4"},Wg=["src","alt","title"],Gg={key:0,class:"text-sm text-red-500"},Yg={key:1,class:"mt-4"},Xg={class:"text-sm text-gray-600 mb-2"},Zg={class:"flex flex-wrap gap-2"},Jg=["src","alt","onError"],Qg=["onClick"],e0={class:"flex justify-end gap-x-2 p-[20px]"},t0=Object.assign({inheritAttrs:!1},{__name:"vs-editor-image",props:{editor:{type:Object,required:!0}},setup(o){const t=o,n=e.ref(!1),r=e.ref(!1),l=e.ref({}),a=e.ref(!1),s=e.ref([]),i=e.ref(null),c=e.ref({src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}),d=e.computed(()=>{if(Array.isArray(c.value.file)){const E=c.value.file.filter(V=>V instanceof File),$=c.value.file.filter(V=>typeof V=="string"&&V.trim()!=="");return E.length+$.length>1}return c.value.file instanceof FileList?c.value.file.length>1:!1}),u=e.computed(()=>Array.isArray(c.value.file)?c.value.file.filter(E=>E instanceof File).length===1:c.value.file instanceof FileList?c.value.file.length===1:c.value.file instanceof File),p=e.computed(()=>{if(d.value)return"";if(c.value.src)return c.value.src;if(u.value){let E=null;if(Array.isArray(c.value.file)||c.value.file instanceof FileList?E=c.value.file[0]:c.value.file instanceof File&&(E=c.value.file),E instanceof File){const $=s.value.find(N=>N.file===E);return $?$.preview:""}else if(typeof E=="string")return E}return""}),g=e.computed(()=>[{name:"src",label:"URL зображення",type:"text",required:!1,placeholder:"https://example.com/image.png"},{name:"file",label:"Файл (можна вибрати кілька)",type:"file",multiple:!0,required:!1,placeholder:"Шлях до файлу зображення",accept:"image/*"},{name:"width",label:"Ширина",type:"number",required:!1,placeholder:"Ширина зображення",clearable:!0,min:0},{name:"height",label:"Висота",type:"number",required:!1,placeholder:"Висота зображення",clearable:!0,min:0},{name:"alt",label:"Альтернативний текст",type:"text",required:!1,placeholder:"Опис зображення"},{name:"title",label:"Заголовок (необов'язково)",type:"text",required:!1,placeholder:"Заголовок зображення"},{name:"link",label:"Посилання",type:"text",required:!1,placeholder:"https://example.com"},{name:"openInNewTab",label:"Відкривати у новій вкладці?",type:"switcher",required:!1}]),b=()=>{if(!t.editor)return;if(t.editor.isActive("image")){const{state:$}=t.editor,{selection:N}=$,{$from:V}=N;let M=null,O=null;if(V.parent.type.name==="image")M=V.before(V.depth),O=V.parent;else for(let oe=V.depth;oe>0;oe--){const be=V.node(oe),pe=V.before(oe);be.type.name==="paragraph"&&be.forEach((ee,ae)=>{if(ee.type.name==="image"){const me=pe+ae+1;(M===null||Math.abs(me-N.$from.pos)<Math.abs(M-N.$from.pos))&&(M=me,O=ee)}})}if(M!==null&&O){try{t.editor.chain().focus().setNodeSelection(M).run()}catch{t.editor.chain().focus().setTextSelection(M).run()}i.value=M}else{t.editor.chain().focus().selectParentNode().run();const{state:oe}=t.editor;i.value=oe.selection.$from.pos}const B=O?O.attrs:t.editor.getAttributes("image");a.value=!0;let K="",I=!1;const G=t.editor.getAttributes("link");G&&G.href&&(K=G.href,I=G.target==="_blank");const L=B.src||"",Z=L?[L]:[];c.value={src:L,file:Z,alt:B.alt||"",title:B.title||"",width:B.width||"",height:B.height||"",link:K,openInNewTab:I}}else a.value=!1,c.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1};r.value=!1,n.value=!0},m=()=>{n.value=!1,r.value=!1,a.value=!1,s.value=[],i.value=null,c.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}},h=async E=>{if(!E||E.length===0)return;const $=[];for(const N of E)if(N&&N.type&&N.type.startsWith("image/")&&!s.value.some(M=>M.file===N)){const M=new Promise((O,B)=>{const K=new FileReader;K.onload=I=>{s.value.push({file:N,preview:I.target.result,error:!1}),O()},K.onerror=B,K.readAsDataURL(N)});$.push(M)}await Promise.all($)},y=E=>{s.value.splice(E,1),Array.isArray(c.value.file)&&c.value.file.splice(E,1)},w=()=>{const E=c.value.width!==null&&c.value.width!==void 0&&c.value.width!==""&&String(c.value.width).trim()!==""?String(c.value.width).trim():"",$=c.value.height!==null&&c.value.height!==void 0&&c.value.height!==""&&String(c.value.height).trim()!==""?String(c.value.height).trim():"",N={};return E&&$?(N.width=E,N.height=$,N.style=`width: ${E}px; height: ${$}px; object-fit: fill;`):E?(N.width=E,N.height=void 0):$?(N.height=$,N.width=void 0):(N.width=void 0,N.height=void 0),N},x=(E,$=null,N=50)=>{const V=()=>{const{view:B}=E;if(!B||!B.dom)return;B.dom.querySelectorAll("img.editor-image[width][height]").forEach(G=>{if(G instanceof HTMLImageElement){const L=G.getAttribute("width"),Z=G.getAttribute("height");L&&Z&&L!=="auto"&&Z!=="auto"&&L!==""&&Z!==""&&!isNaN(Number(L))&&!isNaN(Number(Z))&&(G.style.cssText=`
36
- width: ${L}px !important;
37
- height: ${Z}px !important;
34
+ `).trim()},Qm=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),eh=o=>{if(!o)return"";if(typeof window>"u"||typeof DOMParser>"u")return o;const n=new DOMParser().parseFromString(o,"text/html"),r=" ",l=(a,s)=>{if(a.nodeType===Node.TEXT_NODE){const k=(a.textContent||"").replace(/\s+/g," ").trim();return k?[`${r.repeat(s)}${k}`]:[]}if(a.nodeType!==Node.ELEMENT_NODE)return[];const i=a,c=i.tagName.toLowerCase(),d=Array.from(i.attributes).map(k=>`${k.name}="${k.value}"`).join(" "),u=d?`<${c} ${d}>`:`<${c}>`,p=`</${c}>`;if(Qm.has(c))return[`${r.repeat(s)}${u}`];const y=Array.from(i.childNodes).flatMap(k=>l(k,s+1));if(!y.length)return[`${r.repeat(s)}${u}${p}`];if(i.childNodes.length===1&&i.firstChild?.nodeType===Node.TEXT_NODE&&y.length===1){const k=y[0].trim();return[`${r.repeat(s)}${u}${k}${p}`]}return[`${r.repeat(s)}${u}`,...y,`${r.repeat(s)}${p}`]};return Array.from(n.body.childNodes).flatMap(a=>l(a,0)).join(`
35
+ `)},xo=async(o,t)=>t!=="md"?o||"":Rr(o||""),th=async(o,t)=>t!=="md"?eh(o||""):zr(o||""),nh=async(o,t)=>t!=="md"?o||"":zr(o||""),oh=o=>String(o).trim().toLowerCase().split("-")[0],rh=()=>typeof window>"u"?"uk":oh(localStorage.getItem("language")||localStorage.getItem("locale")||navigator.language||"uk"),lh=(o,t)=>{const n=t.replace(/^form\.richtext\./,"");return co?.[o]?.form?.richtext?.[n]||co?.uk?.form?.richtext?.[n]||t},jr=o=>o.startsWith("form.richtext.")?o:`form.richtext.${o}`;function zn(){const t=e.getCurrentInstance()?.appContext?.config?.globalProperties,n=t?.$i18n;return{t:l=>{const a=t?.$t,s=t?.$te,i=typeof n?.te=="function"?n.te.bind(n):null;if(typeof a=="function"){const c=jr(l);if((typeof s=="function"?s(c):typeof i=="function"?i(c):null)!==!1){const u=a(c);if(u&&u!==c)return u}}return lh(rh(),jr(l))}}}const ah={components:{Quote:q.Quote},props:{editor:Object},methods:{toggleBlockquote(){this.editor&&this.editor.chain().toggleBlockquote().run()}}};function sh(o,t,n,r,l,a){const s=e.resolveComponent("Quote");return e.openBlock(),e.createElementBlock("button",{title:"Blockquote",onClick:t[0]||(t[0]=(...i)=>a.toggleBlockquote&&a.toggleBlockquote(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":n.editor?.isActive("blockquote")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const ih=xe(ah,[["render",sh]]),ch={components:{List:q.List},props:{editor:Object},methods:{toggleBulletList(){this.editor&&this.editor.chain().focus().toggleBulletList().run()}}};function dh(o,t,n,r,l,a){const s=e.resolveComponent("List");return e.openBlock(),e.createElementBlock("button",{title:"Bullet List",onClick:t[0]||(t[0]=(...i)=>a.toggleBulletList&&a.toggleBulletList(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("bulletList")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const uh=xe(ch,[["render",dh]]),ph={components:{ListOrdered:q.ListOrdered},props:{editor:Object},methods:{toggleOrderedList(){this.editor&&this.editor.chain().focus().toggleOrderedList().run()}}};function fh(o,t,n,r,l,a){const s=e.resolveComponent("ListOrdered");return e.openBlock(),e.createElementBlock("button",{title:"Ordered List",onClick:t[0]||(t[0]=(...i)=>a.toggleOrderedList&&a.toggleOrderedList(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("orderedList")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const mh=xe(ph,[["render",fh]]),hh={components:{CodeXml:q.CodeXml},props:{editor:Object},methods:{toggleCodeBlock(){this.editor&&this.editor.chain().focus().toggleCodeBlock().run()}}};function gh(o,t,n,r,l,a){const s=e.resolveComponent("CodeXml");return e.openBlock(),e.createElementBlock("button",{title:"Code Block",onClick:t[0]||(t[0]=(...i)=>a.toggleCodeBlock&&a.toggleCodeBlock(...i)),class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("codeBlock")}])},[e.createVNode(s,{class:"h-4 w-4"})],2)}const yh=xe(hh,[["render",gh]]),bh={components:{Bold:q.Bold},props:{editor:Object},methods:{toggleBold(){this.editor&&this.editor.commands.toggleBold()}}};function kh(o,t,n,r,l,a){const s=e.resolveComponent("Bold");return e.openBlock(),e.createElementBlock("button",{title:"Bold Text",onClick:t[0]||(t[0]=(...i)=>a.toggleBold&&a.toggleBold(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("bold")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Bold",-1))],2)}const xh=xe(bh,[["render",kh]]),wh={components:{Italic:q.Italic},props:{editor:Object},methods:{toggleItalic(){this.editor&&this.editor.chain().toggleItalic().run()}}};function _h(o,t,n,r,l,a){const s=e.resolveComponent("Italic");return e.openBlock(),e.createElementBlock("button",{title:"Italic Text",onClick:t[0]||(t[0]=(...i)=>a.toggleItalic&&a.toggleItalic(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("italic")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Italic",-1))],2)}const Ch=xe(wh,[["render",_h]]),vh={__name:"vs-editor-underline",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().toggleUnderline().run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Underline",onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.isActive("underline")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Underline),{class:"h-4 w-4"})],2))}},Eh={__name:"vs-editor-strike",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().toggleStrike().run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Strikethrough",onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.isActive("strike")?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Strikethrough),{class:"h-4 w-4"})],2))}},Bh={components:{X:q.X},props:{visible:{type:Boolean,default:()=>!1},modelValue:{type:Boolean,default:()=>!1},title:{type:String,default:()=>""},size:{type:String,default:()=>""},closeClickBack:{type:Boolean,default:()=>!1}},emits:["update:visible","update:modelValue","onClose","confirm","cancel"],inheritAttrs:!1,name:"vs-dialog",mounted(){window.addEventListener("keydown",this.checkKey)},unmounted(){window.removeEventListener("keydown",this.checkKey)},computed:{hasSlot(){return!!this.$slots?.footer},checkSize(){return this.size==="small"?"md:w-5/12 w-9/12":this.size==="medium"?"md:w-6/12 w-9/12":"lg:w-7/12 w-11/12"}},methods:{checkKey({key:o}){o==="Escape"&&this.handleClose()},handleClose(){this.$emit("update:visible",!1),this.$emit("update:modelValue",!1),this.$emit("onClose")},handleConfirm(){this.$emit("confirm"),this.handleClose()},handleCancel(){this.$emit("cancel"),this.handleClose()},closeByClickBack(o,t){t&&o.target.classList.contains("vs-dialog-overlay")&&this.handleClose()}}},Vh={key:0,class:"vsTailwind ui-dialog__wrapper"},Sh={class:"py-2.5 px-4 flex justify-between items-center border-0 border-b border-solid border-gray-200 dark:border-b-[#454545]"},$h={class:"font-medium text-gray-800 dark:text-[#ffffff]"},Nh={class:"ui-dialog__content p-4"},Ah={key:0,class:"flex justify-end gap-x-2"};function Fh(o,t,n,r,l,a){const s=e.resolveComponent("X");return e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[n.visible||n.modelValue?(e.openBlock(),e.createElementBlock("div",Vh,[e.createElementVNode("div",{onMousedown:t[1]||(t[1]=i=>a.closeByClickBack(i,n.closeClickBack)),class:"vs-dialog-overlay vs-dialog w-full h-full fixed top-0 start-0 z-[100001] bg-black bg-opacity-50"},[e.createVNode(e.Transition,{name:"content",appear:""},{default:e.withCtx(()=>[e.createElementVNode("div",{class:e.normalizeClass(["ui-dialog__modal 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",[a.checkSize]])},[e.createElementVNode("div",Sh,[e.createElementVNode("h3",$h,e.toDisplayString(n.title),1),e.createElementVNode("button",{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",onClick:t[0]||(t[0]=(...i)=>a.handleClose&&a.handleClose(...i))},[t[2]||(t[2]=e.createElementVNode("span",{class:"sr-only"},"Close",-1)),e.createVNode(s,{class:"h-4 w-4 flex-shrink-0"})])]),e.createElementVNode("div",Nh,[e.renderSlot(o.$slots,"default",{},void 0,!0)]),a.hasSlot?(e.openBlock(),e.createElementBlock("div",Ah,[e.renderSlot(o.$slots,"footer",{handleClose:a.handleClose,handleConfirm:a.handleConfirm,handleCancel:a.handleCancel},void 0,!0)])):e.createCommentVNode("",!0)],2)]),_:3})],32)])):e.createCommentVNode("",!0)])}const Ur=xe(Bh,[["render",Fh],["__scopeId","data-v-56ad9010"]]),Mh=e.defineComponent({components:{IconClose:q.X,IconSearch:q.Search,IconEmail:q.Mail},inheritAttrs:!1,props:{icon:{type:String,default:()=>""},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},modelValue:{type:String,default:()=>""},placeholder:{type:String,default:()=>""},iconPosition:{type:String,default:()=>"right"},type:{type:String,default:()=>"text"},style:{type:Object,default:()=>null},size:{type:String,default:()=>"md"},attrs:{type:Object,default:()=>{}}},emits:["onInput","update:modelValue","blur","focus"],computed:{checkSize(){return(this.style?.size||this.size)==="xs"?"h-[32px] text-sm":(this.style?.size||this.size)==="md"?"h-[38px] text-sm":(this.style?.size||this.size)==="lg"?"h-[46px] text-[20px]":"h-[38px] text-sm"},value:{get(){return this.modelValue},set(o){this.$emit("update:modelValue",o.trim())}},clearIconStyle(){return[{"right-8":this.icon&&this.iconPosition==="right","right-3":!this.icon||this.iconPosition!=="right","pointer-events-none":this.disabled}]},iconStylePosition(){return[{"left-3":this.icon&&this.iconPosition==="left","right-3":this.icon&&this.iconPosition==="right"}]},inputStyle(){return[{"!pr-8":this.clearable&&!this.icon,"!pr-7":this.clearable,"!pr-16":this.clearable&&this.icon&&this.iconPosition==="right","!pl-8":this.icon&&this.iconPosition==="left","!pr-[50px]":this.clearable&&this.value&&this.icon&&this.iconPosition==="right","!cursor-not-allowed bg-slate-100":this.disabled,"bg-white":!this.disabled}]}},methods:{handleInput(){this.$emit("onInput",this.modelValue)},handleBlur(){this.$emit("blur")},handleFocus(){this.$emit("focus")},clearInput(){this.$emit("update:modelValue",""),this.$emit("onInput","")},async inputFocus(){await this.$refs.vsText?.focus()}}}),Dh={class:"vs-form-text relative bg-white rounded-lg"},Th={key:2,class:"absolute bottom-2/4 translate-y-2/4 left-[10px] cursor-pointer"},Lh=["disabled","type","placeholder"];function Ih(o,t,n,r,l,a){const s=e.resolveComponent("IconClose"),i=e.resolveComponent("IconSearch"),c=e.resolveComponent("IconEmail");return e.openBlock(),e.createElementBlock("div",Dh,[o.clearable&&o.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:t[0]||(t[0]=(...d)=>o.clearInput&&o.clearInput(...d))},[e.createVNode(s,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):e.createCommentVNode("",!0),o.icon&&o.icon==="search"?(e.openBlock(),e.createElementBlock("div",{key:1,class:e.normalizeClass(["absolute bottom-2/4 translate-y-2/4 cursor-pointer",o.iconStylePosition])},[e.createVNode(i,{class:"h-4 w-4 stroke-gray-500 transition-all"})],2)):o.icon&&o.icon==="email"?(e.openBlock(),e.createElementBlock("div",Th,[e.createVNode(c,{class:"h-4 w-4 stroke-gray-500 transition-all"})])):(e.openBlock(),e.createElementBlock("i",{key:3,class:e.normalizeClass(["absolute bottom-2/4 translate-y-2/4 text-gray-500 cursor-pointer",["ti "+o.icon,o.iconStylePosition]])},null,2)),o.clearable&&o.value?(e.openBlock(),e.createElementBlock("div",{key:4,class:"absolute bottom-2/4 translate-y-2/4 right-3 cursor-pointer",onClick:t[1]||(t[1]=(...d)=>o.clearInput&&o.clearInput(...d))},[e.createVNode(s,{class:"h-4 w-4 stroke-gray-500 transition-all hover:stroke-red-500"})])):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("input",e.mergeProps({ref:"vsText",disabled:o.disabled,type:o.type,onInput:t[2]||(t[2]=(...d)=>o.handleInput&&o.handleInput(...d)),placeholder:o.placeholder,"onUpdate:modelValue":t[3]||(t[3]=d=>o.value=d)},o.style?.attrs||o.attrs||{},{onFocus:t[4]||(t[4]=(...d)=>o.handleFocus&&o.handleFocus(...d)),onBlur:t[5]||(t[5]=(...d)=>o.handleBlur&&o.handleBlur(...d)),class:[[o.inputStyle,o.checkSize],"py-2 px-3 block w-full border border-solid placeholder:text-nowrap border-stone-200 rounded-lg text-sm 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,16,Lh),[[e.vModelDynamic,o.value]])])}const Hr=xe(Mh,[["render",Ih],["__scopeId","data-v-eb21a54f"]]),Rh=["title"],Oh={class:"flex flex-col gap-3 p-[20px]"},Ph={class:"relative flex items-center gap-2"},zh={class:"flex-1"},jh={key:0,class:"flex items-center gap-2 flex-shrink-0"},Uh=["title"],Hh=["title"],qh={class:"flex items-center gap-2"},Kh={for:"openInNewTab",class:"text-sm text-gray-700 cursor-pointer"},Wh={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"},Gh=Object.assign({inheritAttrs:!1},{__name:"vs-editor-link",props:{editor:Object},setup(o){const{t}=zn(),n=o,r=e.ref(!1),l=e.ref(""),a=e.ref(!1),s=e.ref(!1),i=()=>{if(!n.editor)return;n.editor.chain().focus().extendMarkRange("link").run();const y=n.editor.getAttributes("link");y.href?(a.value=!0,l.value=y.href,s.value=y.target==="_blank"):(a.value=!1,l.value="",s.value=!1),r.value=!0},c=()=>{r.value=!1,l.value="",a.value=!1,s.value=!1},d=()=>{if(!n.editor||!l.value.trim())return;let y=l.value.trim();y.match(/^https?:\/\//i)||(y="https://"+y),n.editor.chain().focus().setLink({href:y,target:s.value?"_blank":null}).run(),c()},u=()=>{n.editor&&(n.editor.chain().focus().unsetLink().run(),c())},p=()=>{if(!l.value)return;let y=l.value.trim();y.match(/^https?:\/\//i)||(y="https://"+y),window.open(y,"_blank","noopener,noreferrer")};return(y,k)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("button",{title:e.unref(t)("form.richtext.link")||"Посилання",onClick:i,class:e.normalizeClass(["text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none",{"bg-gray-100 text-gray-900":o.editor?.isActive("link")}])},[e.createVNode(e.unref(q.Link2),{class:"h-4 w-4"})],10,Rh),e.createVNode(Ur,{title:a.value?e.unref(t)("form.richtext.editLink")||"Редагувати посилання":e.unref(t)("form.richtext.linkTitle")||"Додати посилання",visible:r.value,"onUpdate:visible":k[2]||(k[2]=m=>r.value=m),size:"small"},{footer:e.withCtx(()=>[e.createElementVNode("div",Wh,[e.createElementVNode("button",{style:{border:"1px solid #000"},onClick:c,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border-gray-200 rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"},e.toDisplayString(e.unref(t)("form.richtext.cancel")||"Скасувати"),1),e.createElementVNode("button",{onClick:d,class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"},e.toDisplayString(a.value?e.unref(t)("form.richtext.update")||"Оновити":e.unref(t)("form.richtext.create")||"Створити"),1)])]),default:e.withCtx(()=>[e.createElementVNode("div",Oh,[e.createElementVNode("div",Ph,[e.createElementVNode("div",zh,[e.createVNode(Hr,{modelValue:l.value,"onUpdate:modelValue":k[0]||(k[0]=m=>l.value=m),placeholder:e.unref(t)("form.richtext.linkUrl")||"Введіть URL",class:"w-full"},null,8,["modelValue","placeholder"])]),a.value?(e.openBlock(),e.createElementBlock("div",jh,[e.createElementVNode("button",{onClick:p,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none transition-colors",title:e.unref(t)("form.richtext.openLink")||"Відкрити посилання"},[e.createVNode(e.unref(q.ExternalLink),{class:"h-4 w-4"})],8,Uh),e.createElementVNode("button",{onClick:u,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-red-600 hover:bg-red-50 focus:outline-none transition-colors",title:e.unref(t)("form.richtext.removeLink")||"Видалити посилання"},[e.createVNode(e.unref(q.Trash2),{class:"h-4 w-4"})],8,Hh)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",qh,[e.withDirectives(e.createElementVNode("input",{type:"checkbox",id:"openInNewTab","onUpdate:modelValue":k[1]||(k[1]=m=>s.value=m),class:"w-4 h-4 text-blue-600 bg-gray-100 border-gray-300 rounded focus:ring-blue-500"},null,512),[[e.vModelCheckbox,s.value]]),e.createElementVNode("label",Kh,e.toDisplayString(e.unref(t)("form.richtext.openInNewTab")||"Відкривати в новій вкладці"),1)])])]),_:1},8,["title","visible"])],64))}}),ln=async(o,t,n,r=10)=>{if(!t||!n)return;await e.nextTick();const l=await n?.getBoundingClientRect(),a=await t?.getBoundingClientRect();if(!a||!l)return;const s=await parseInt(t?.getBoundingClientRect()?.height),i=await parseInt(t?.getBoundingClientRect()?.width),c=await parseInt(n?.getBoundingClientRect()?.height),d=await parseInt(n?.getBoundingClientRect()?.width),u=await window.innerHeight,p=await window.innerWidth;let y=0,k=0;const m=a.bottom+r+c;switch(o){case"top":a.top-l.height-r<0?y=a.top-l.height+r+c+s:y=a.top-l.height-r,p>d+a.right+30?k=a.left-l.width/2+a.width/2:k=p-30-d;break;case"bottom":u>m?y=a.bottom+r:y=a.bottom-r-c-s,k=a.left-l.width/2+a.width/2;break;case"left":y=a.top-l.height/2+a.height/2,a.left-l.width-r>0?k=a.left-l.width-r:k=10;break;case"right":y=a.top-l.height/2+a.height/2,p-i>d?k=a.right+r:k=p-30-d;break;case"top-right":a.top-l.height-r<0?y=a.top-l.height+r+c+s:y=a.top-l.height-r,p-i>d?k=a.right+r:k=p-30-d;break;case"top-left":a.top-l.height-r<0?y=a.top-l.height+r+c+s:y=a.top-l.height-r,a.left-l.width-r>0?k=a.left-l.width-r:k=10;break;case"top-start":a.top-l.height-r<0?y=a.top-l.height+r+c+s:y=a.top-l.height-r,a.left>0?k=a.left:k=10;break;case"bottom-right":u>m?y=a.bottom+r:y=a.bottom-r-c-s,p-i>d?k=a.left:k=p-30-d;break;case"bottom-left":u>m?y=a.bottom+r:y=a.bottom-r-c-s,a.left>0?k=a.right-d:k=10;break;case"bottom-start":u>m?y=a.bottom+r:y=a.bottom-r-c-s,a.left>0?k=a.left:k=10;break}y+c>u?y=u-c-r:y<0&&(y=r),k+d>p?k=p-d-r:k<0&&(k=r),n instanceof HTMLElement&&(n.style.top=`${y}px`,n.style.left=`${k}px`,n.style.position="fixed")},Yh={class:"text-center"},Xh={class:"py-2 px-4 w-full text-sm text-stone-800 bg-white shadow-[0_10px_40px_10px_rgba(0,0,0,0.08)] rounded-lg focus:outline-none focus:bg-stone-100 dark:bg-neutral-900 dark:text-neutral-200 dark:focus:bg-neutral-800 after:h-4 after:absolute after:-bottom-4 after:start-0 after:w-full before:h-4 before:absolute before:-top-4 before:start-0 before:w-full"},At=Object.assign({inheritAttrs:!1},{__name:"vs-popover",props:{isOpen:{type:Boolean,default:()=>!1},placement:{type:String,default:"top"},gap:{type:Number,default:8},width:{type:[String,Number],default:""},disabled:{type:Boolean,default:!1},trigger:{type:String,default:"click"},teleport:{type:String,default:"body"}},emits:["isvisible"],setup(o,{expose:t,emit:n}){const r=o,l=n,a=e.ref(!1),s=e.ref([]),i=e.ref(null),c=e.ref(null),d=e.ref(null);e.watch(a,v=>{v?(u(),window.addEventListener("resize",()=>ln(r.placement,c.value,d.value)),ln(r.placement,c.value,d.value)):window.removeEventListener("resize",()=>ln(r.placement,c.value,d.value)),l("isvisible",v)}),e.onMounted(()=>{window.addEventListener("click",b),window.addEventListener("popstate",_),window.addEventListener("scroll",x,!0),u()}),e.onBeforeUnmount(()=>{window.removeEventListener("click",b),window.removeEventListener("popstate",_),p()});const u=()=>{let v=i.value;for(;v&&v!==document.body;)(v.scrollHeight>v.clientHeight||v.scrollWidth>v.clientWidth)&&(v.addEventListener("scroll",h),s.value.push(v)),v=v.parentElement;document.body&&(document.body.addEventListener("scroll",h),s.value.push(document.body))},p=()=>{s.value.forEach(v=>{v.removeEventListener("scroll",h)}),s.value=[]},y=()=>{a.value=!0,ln(r.placement,c.value,d.value)},k=()=>{a.value=!1},m=async()=>{await ln(r.placement,c.value,d.value),a.value=!a.value},h=()=>{a.value=!1},b=v=>{if(!v){a.value=!1;return}c.value?.contains(v.target)||d.value?.contains(v.target)||(a.value=!1)},_=()=>{a.value&&(a.value=!1)},x=v=>{a.value&&d.value&&!d.value.contains(v.target)&&(a.value=!1)};return t({togglePopover:m}),(v,N)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"popover",ref:i,class:"vs-popover inline-block"},[e.createElementVNode("div",Yh,[o.trigger==="click"?(e.openBlock(),e.createElementBlock("div",{key:0,ref_key:"popoverRef",ref:c,onClick:m,class:e.normalizeClass({"pointer-events-none":o.disabled})},[e.renderSlot(v.$slots,"reference",{},()=>[N[0]||(N[0]=e.createElementVNode("button",null,"Click me!",-1))])],2)):e.createCommentVNode("",!0),o.trigger==="hover"?(e.openBlock(),e.createElementBlock("div",{key:1,ref_key:"popoverRef",ref:c,onMouseover:y,onMouseleave:k,class:e.normalizeClass({"pointer-events-none":o.disabled})},[e.renderSlot(v.$slots,"reference",{},()=>[N[1]||(N[1]=e.createElementVNode("button",null,"Click me!",-1))])],34)):e.createCommentVNode("",!0),(e.openBlock(),e.createBlock(e.Teleport,{to:o.teleport},[e.createVNode(e.Transition,{name:"fade"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["vsTailwind vs-popover__content",o.placement]),ref_key:"contentPop",ref:d,style:e.normalizeStyle({width:o.width?o.width+"px":"fit-content",zIndex:100001})},[e.createElementVNode("div",Xh,[e.renderSlot(v.$slots,"default",{},()=>[N[2]||(N[2]=e.createElementVNode("span",null,"Popover content",-1))])])],6),[[e.vShow,a.value]])]),_:3})],8,["to"]))])],512))}}),Zh={class:"flex flex-col gap-[2px] p-[2px]"},Jh=["onClick"],Qh={__name:"vs-editor-table",props:{editor:Object},setup(o){const{t}=zn(),n=o,r=e.ref(!1),l=e.ref("popover"),a=()=>{n.editor&&(n.editor.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run(),l.value.togglePopover())},s=()=>{n.editor&&(n.editor.chain().focus().addColumnAfter().run(),l.value.togglePopover())},i=()=>{n.editor&&(n.editor.chain().focus().addRowAfter().run(),l.value.togglePopover())},c=()=>{n.editor&&(n.editor.chain().focus().deleteColumn().run(),l.value.togglePopover())},d=()=>{n.editor&&(n.editor.chain().focus().deleteRow().run(),l.value.togglePopover())},u=()=>{n.editor&&(n.editor.chain().focus().deleteTable().run(),l.value.togglePopover())},p=()=>{n.editor&&(n.editor.chain().focus().mergeCells().run(),l.value.togglePopover())},y=()=>{n.editor&&(n.editor.chain().focus().splitCell().run(),l.value.togglePopover())},k=e.computed(()=>[{text:t("form.richtext.createTable"),function:a},{text:t("form.richtext.addColumn"),function:s},{text:t("form.richtext.addRow"),function:i},{text:t("form.richtext.deleteColumn"),function:c},{text:t("form.richtext.deleteRow"),function:d},{text:t("form.richtext.deleteTable"),function:u},{text:t("form.richtext.mergeCells"),function:p},{text:t("form.richtext.splitCells"),function:y}]);return(m,h)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:l,placement:"bottom",onIsvisible:h[0]||(h[0]=b=>r.value=b)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Table",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[r.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Table2),{class:"h-4 w-4"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",Zh,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,(b,_)=>(e.openBlock(),e.createElementBlock("button",{key:_,onClick:b?.function,class:"px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded"},e.toDisplayString(b.text),9,Jh))),128))])]),_:1},512))}},eg={class:"flex gap-[4px] p-1"},tg=["title","onClick"],ng={__name:"vs-editor-align",props:{editor:Object},setup(o){const t=o,n={left:q.AlignLeft,center:q.AlignCenter,right:q.AlignRight,justify:q.AlignJustify},r=e.ref(!1),l=e.ref("popover"),a=e.ref("left"),s=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"left"})||t.editor.isActive("heading",{textAlign:"left"}):!1),i=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"right"})||t.editor.isActive("heading",{textAlign:"right"}):!1),c=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"center"})||t.editor.isActive("heading",{textAlign:"center"}):!1),d=e.computed(()=>t.editor?t.editor.isActive("paragraph",{textAlign:"justify"})||t.editor.isActive("heading",{textAlign:"justify"}):!1),u=e.computed(()=>s.value||i.value||c.value||d.value),p=()=>{i.value?a.value="right":c.value?a.value="center":d.value?a.value="justify":a.value="left"};e.watch([s,i,c,d],()=>{p()},{immediate:!0}),e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",p),t.editor.on("update",p))}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",p),t.editor.off("update",p))});const y=m=>{t.editor&&(t.editor.chain().focus().setTextAlign(m).run(),a.value=m)},k=e.ref([{id:"left",isActive:s},{id:"center",isActive:c},{id:"right",isActive:i},{id:"justify",isActive:d}]);return(m,h)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:l,placement:"bottom",onIsvisible:h[0]||(h[0]=b=>r.value=b)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Text Align",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[u.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[a.value]),{height:"16",width:"16"}))],2)]),default:e.withCtx(()=>[e.createElementVNode("div",eg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(k.value,b=>(e.openBlock(),e.createElementBlock("button",{title:"Text align "+b?.id,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":b?.isActive}]),key:b?.id,onClick:_=>y(b?.id)},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(n[b?.id]),{height:"16",width:"16"}))],10,tg))),128))])]),_:1},512))}},og={class:"flex flex-col gap-[2px] p-[2px]"},rg=["onClick"],lg={__name:"vs-editor-type-tag",props:{editor:Object},setup(o){const{t}=zn(),n=o,r=e.ref(!1),l=e.ref("popover"),a=()=>{n.editor&&(n.editor?.chain().focus().setParagraph().run(),l.value.togglePopover())},s=c=>{n.editor&&(n.editor?.chain().focus().toggleHeading({level:c}).run(),l.value.togglePopover())},i=e.computed(()=>[{text:t("form.richtext.heading1"),id:1,style:"font-[700] text-[30px]"},{text:t("form.richtext.heading2"),id:2,style:"font-[700] text-[26px]"},{text:t("form.richtext.heading3"),id:3,style:"font-[700] text-[22px]"},{text:t("form.richtext.heading4"),id:4,style:"font-[700] text-[18px]"},{text:t("form.richtext.heading5"),id:5,style:"font-[500] text-[16px]"},{text:t("form.richtext.heading6"),id:6,style:"font-[400] text-[14px]"}]);return(c,d)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:l,placement:"bottom",onIsvisible:d[0]||(d[0]=u=>r.value=u)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Type Tag",class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100",[r.value?"bg-gray-100 text-gray-900":"text-gray-500"]])},[e.createVNode(e.unref(q.Type),{class:"h-4 w-4"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",og,[e.createElementVNode("button",{onClick:a,class:e.normalizeClass(["px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded",[o.editor?.isActive("paragraph")?"bg-gray-100":""]])},e.toDisplayString(e.unref(t)("form.richtext.paragraph")),3),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,(u,p)=>(e.openBlock(),e.createElementBlock("button",{key:p,onClick:y=>s(u?.id),class:e.normalizeClass(["px-2 py-1 text-gray-500 text-start hover:text-gray-900 hover:bg-gray-100 rounded leading-[100%]",[u?.style,o.editor?.isActive("heading",{level:u?.id})?"bg-gray-100":""]])},e.toDisplayString(e.unref(t)(`form.richtext.heading${u?.id}`)),11,rg))),128))])]),_:1},512))}},ag={components:{VsText:Hr},inheritAttrs:!1,events:["update:modelValue"],props:{modelValue:{type:String},disabled:{type:Boolean,default:()=>!1},clearable:{type:Boolean,default:()=>!1},isTextInputShown:{type:Boolean,default:()=>!0}},computed:{value:{get(){return this.modelValue??""},set(o){this.$emit("update:modelValue",o)}}}},sg={class:"flex items-center w-full max-w-[182px]"},ig=["disabled"];function cg(o,t,n,r,l,a){const s=e.resolveComponent("vs-text");return e.openBlock(),e.createElementBlock("div",sg,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":t[0]||(t[0]=i=>a.value=i),type:"color",class:e.normalizeClass(["w-[38px] h-[38px] min-h-[38px] min-w-[38px] py-[2px] px-[3px] -ml-1 dark:bg-neutral-800 border dark:border-neutral-700 border-stone-200 rounded-lg",n.disabled?"cursor-not-allowed":"cursor-pointer"]),disabled:n.disabled},null,10,ig),[[e.vModelText,a.value]]),n.isTextInputShown?(e.openBlock(),e.createBlock(s,{key:0,modelValue:a.value,"onUpdate:modelValue":t[1]||(t[1]=i=>a.value=i),class:"ml-2 w-full",disabled:n.disabled,clearable:n.clearable},null,8,["modelValue","disabled","clearable"])):e.createCommentVNode("",!0)])}const qr=xe(ag,[["render",cg]]),dg={class:"flex gap-[4px] mb-[8px]"},ug={class:"grid grid-rows-3 grid-cols-7"},pg={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},fg=["onClick","title"],mg={__name:"vs-editor-color",props:{editor:Object},setup(o){const t=o,n=e.ref(null),r=e.ref("#000000"),l=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").color||"#000000"),a=e.computed(()=>l.value!=="#000000"),s=()=>{t.editor&&(r.value=l.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const i=e.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),c=p=>{t.editor&&(t.editor.chain().focus().setColor(p).run(),r.value=p,n.value&&n.value.togglePopover())},d=()=>{c(r.value)},u=p=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple","#FFFFFF":"White","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[p]||p;return(p,y)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Text Color",class:e.normalizeClass(["flex flex-col h-[30px] min-w-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":a.value}])},[y[1]||(y[1]=e.createElementVNode("span",{class:"leading-none"},"A",-1)),e.createElementVNode("span",{class:"block h-1 w-5",style:e.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("div",dg,[e.createVNode(qr,{modelValue:r.value,"onUpdate:modelValue":y[0]||(y[0]=k=>r.value=k)},null,8,["modelValue"]),e.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[e.createVNode(e.unref(q.Check),{class:"h-4 w-4 text-white"})])]),e.createElementVNode("div",ug,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,k=>(e.openBlock(),e.createElementBlock("div",{key:k,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[e.createElementVNode("div",pg,[e.createElementVNode("button",{class:"flex items-center justify-center w-full h-full",style:e.normalizeStyle({backgroundColor:k}),onClick:m=>c(k),title:u(k)},[r.value===k?(e.openBlock(),e.createBlock(e.unref(q.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],12,fg)])]))),128))])])]),_:1},512))}},hg={class:"flex gap-[4px] mb-[8px]"},gg={class:"grid grid-rows-3 grid-cols-7"},yg={class:"w-full h-full rounded border border-gray-300 overflow-hidden"},bg=["onClick","title"],kg=["onClick","title"],xg={__name:"vs-editor-background-color",props:{editor:Object},setup(o){const t=o,n=e.ref(null),r=e.ref("transparent"),l=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").backgroundColor||"transparent"),a=e.computed(()=>l.value!=="transparent"&&l.value!==""),s=()=>{t.editor&&(r.value=l.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const i=e.ref(["#172B4D","#0747A6","#008DA6","#006644","#FF991F","#BF2600","#403294","#97A0AF","#4C9AFF","#00B8D9","#36B37E","#FFC400","#FF5630","#6554C0","#FFFFFF","#B3D4FF","#B3F5FF","#ABF5D1","#FFF0B3","#FFBDAD","#EAE6FF"]),c=p=>{t.editor&&(t.editor.chain().focus().setBackgroundColor(p).run(),r.value=p,n.value&&n.value.togglePopover())},d=()=>{c(r.value)},u=p=>({"#172B4D":"Default","#0747A6":"Bright blue","#008DA6":"Bright blue-green","#006644":"Bright green","#FF991F":"Bright orange","#BF2600":"Bright red","#403294":"Bright purple","#97A0AF":"Gray","#4C9AFF":"Blue","#00B8D9":"Blue-green","#36B37E":"Green","#FFC400":"Yellow","#FF5630":"Red","#6554C0":"Purple",transparent:"Transparent","#B3D4FF":"Bright blue","#B3F5FF":"Bright blue-green","#ABF5D1":"Bright green","#FFF0B3":"Bright yellow","#FFBDAD":"Bright red","#EAE6FF":"Bright purple"})[p]||p;return(p,y)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Background Color",class:e.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-100":a.value}])},[e.createVNode(e.unref(q.PaintBucket),{class:"h-4 w-4"}),e.createElementVNode("span",{class:"block h-1 w-5",style:e.normalizeStyle({backgroundColor:r.value})},null,4)],2)]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("div",hg,[e.createVNode(qr,{modelValue:r.value,"onUpdate:modelValue":y[0]||(y[0]=k=>r.value=k)},null,8,["modelValue"]),e.createElementVNode("button",{onClick:d,class:"h-[38px] w-[38px] bg-blue-500 shrink-0 border rounded-md flex items-center justify-center hover:bg-blue-700 duration-300"},[e.createVNode(e.unref(q.Check),{class:"h-4 w-4 text-white"})])]),e.createElementVNode("div",gg,[e.createElementVNode("button",{onClick:y[1]||(y[1]=k=>c("transparent")),class:"col-span-7 flex items-center justify-center gap-2 bg-gray-100 rounded-md py-1 mb-2 hover:bg-gray-200"},[e.createVNode(e.unref(q.Eraser),{class:"h-4 w-4"}),y[2]||(y[2]=e.createElementVNode("p",null,"no color",-1))]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,k=>(e.openBlock(),e.createElementBlock("div",{key:k,class:"h-8 w-8 p-0.5 rounded border border-transparent hover:border-gray-200 transition-transform cursor-pointer"},[e.createElementVNode("div",yg,[k!=="transparent"?(e.openBlock(),e.createElementBlock("button",{key:0,class:"flex items-center justify-center w-full h-full",style:e.normalizeStyle({backgroundColor:k}),onClick:m=>c(k),title:u(k)},[r.value===k?(e.openBlock(),e.createBlock(e.unref(q.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],12,bg)):e.createCommentVNode("",!0),k==="transparent"?(e.openBlock(),e.createElementBlock("button",{key:1,class:"flex items-center justify-center w-full h-full",onClick:m=>c(k),title:u(k)},[r.value===k?(e.openBlock(),e.createBlock(e.unref(q.Check),{key:0,class:"h-4 w-4 text-gray-500"})):e.createCommentVNode("",!0)],8,kg)):e.createCommentVNode("",!0)])]))),128))])])]),_:1},512))}},wg={__name:"vs-editor-highlight",props:{editor:Object},setup(o){const t=o,n=e.computed(()=>t.editor?.isActive("highlight")),r=()=>{t.editor&&t.editor.chain().focus().toggleHighlight().run()};return(l,a)=>(e.openBlock(),e.createElementBlock("button",{title:"Highlight",onClick:r,class:e.normalizeClass(["flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex",{"bg-gray-200":n.value}])},[e.createVNode(e.unref(q.Highlighter),{class:"h-4 w-4"})],2))}},_g={class:"truncate"},Cg={class:"w-[200px]"},vg={class:"max-h-[200px] overflow-y-auto"},Eg=["onClick"],Bg={__name:"vs-editor-font-family",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref(!1),l=e.ref([{label:"Arial",value:"Arial, sans-serif"},{label:"Helvetica",value:"Helvetica, sans-serif"},{label:"Times New Roman",value:"Times New Roman, serif"},{label:"Georgia",value:"Georgia, serif"},{label:"Verdana",value:"Verdana, sans-serif"},{label:"Courier New",value:"Courier New, monospace"},{label:"Comic Sans MS",value:"Comic Sans MS, cursive"},{label:"Impact",value:"Impact, sans-serif"},{label:"Trebuchet MS",value:"Trebuchet MS, sans-serif"},{label:"Palatino",value:"Palatino, serif"}]),a=e.computed(()=>{if(!t.editor)return"Arial, sans-serif";for(const d of l.value)if(t.editor.isActive("textStyle",{fontFamily:d.value}))return d.value;return"Arial, sans-serif"}),s=e.computed(()=>l.value.find(u=>u.value===a.value)?.label||"Arial"),i=d=>t.editor?t.editor.isActive("textStyle",{fontFamily:d}):!1,c=d=>{t.editor&&(t.editor.chain().focus().setFontFamily(d).run(),n.value&&n.value.togglePopover())};return(d,u)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:n,placement:"bottom",onIsvisible:u[0]||(u[0]=p=>r.value=p)},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Font Family",class:e.normalizeClass(["h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm",[r.value?"bg-gray-100 text-gray-900":"text-gray-700"]]),style:e.normalizeStyle({fontFamily:a.value})},[e.createElementVNode("span",_g,e.toDisplayString(s.value),1),e.createVNode(e.unref(q.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})],6)]),default:e.withCtx(()=>[e.createElementVNode("div",Cg,[e.createElementVNode("ul",vg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,p=>(e.openBlock(),e.createElementBlock("li",{key:p.value,class:e.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",{"bg-gray-100":i(p.value)}]),style:e.normalizeStyle({fontFamily:p.value}),onClick:y=>c(p.value)},e.toDisplayString(p.label),15,Eg))),128))])])]),_:1},512))}},Vg={class:"w-[120px]"},Sg={class:"max-h-[200px] overflow-y-auto"},$g=["onClick"],Ng={__name:"vs-editor-font-size",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref("14px"),l=e.computed(()=>t.editor&&t.editor.getAttributes("textStyle").fontSize||"14px"),a=e.computed(()=>l.value!=="14px"),s=()=>{t.editor&&(r.value=l.value)};e.onMounted(()=>{t.editor&&(t.editor.on("selectionUpdate",s),t.editor.on("update",s),s())}),e.onUnmounted(()=>{t.editor&&(t.editor.off("selectionUpdate",s),t.editor.off("update",s))});const i=e.ref([{label:"8px",value:"8px"},{label:"9px",value:"9px"},{label:"10px",value:"10px"},{label:"11px",value:"11px"},{label:"12px",value:"12px"},{label:"14px",value:"14px"},{label:"16px",value:"16px"},{label:"18px",value:"18px"},{label:"20px",value:"20px"},{label:"24px",value:"24px"},{label:"28px",value:"28px"},{label:"32px",value:"32px"},{label:"36px",value:"36px"},{label:"48px",value:"48px"},{label:"72px",value:"72px"}]),c=d=>{t.editor&&(t.editor.chain().focus().setFontSize(d).run(),r.value=d,n.value&&n.value.togglePopover())};return(d,u)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",{title:"Font Size",class:e.normalizeClass(["h-[30px] px-2 min-w-[30px] rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700 space-x-1",{"bg-gray-100 text-gray-900":a.value}])},[e.createVNode(e.unref(q.ALargeSmall),{class:"h-4 w-4"}),e.createVNode(e.unref(q.ChevronDown),{class:"h-3 w-3 text-gray-400"})],2)]),default:e.withCtx(()=>[e.createElementVNode("div",Vg,[e.createElementVNode("ul",Sg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,p=>(e.openBlock(),e.createElementBlock("li",{key:p.value,class:"px-3 py-2 hover:bg-gray-100 cursor-pointer",onClick:y=>c(p.value)},e.toDisplayString(p.label),9,$g))),128))])])]),_:1},512))}},Ag={components:{Superscript:q.Superscript},props:{editor:Object},methods:{toggleSuperscript(){this.editor&&this.editor.commands.toggleSuperscript()}}};function Fg(o,t,n,r,l,a){const s=e.resolveComponent("Superscript");return e.openBlock(),e.createElementBlock("button",{title:"Superscript",onClick:t[0]||(t[0]=(...i)=>a.toggleSuperscript&&a.toggleSuperscript(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("superscript")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Superscript",-1))],2)}const Mg=xe(Ag,[["render",Fg]]),Dg={components:{Subscript:q.Subscript},props:{editor:Object},methods:{toggleSubscript(){this.editor&&this.editor.commands.toggleSubscript()}}};function Tg(o,t,n,r,l,a){const s=e.resolveComponent("Subscript");return e.openBlock(),e.createElementBlock("button",{title:"Subscript",onClick:t[0]||(t[0]=(...i)=>a.toggleSubscript&&a.toggleSubscript(...i)),class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",{"bg-gray-100 text-gray-900":n.editor?.isActive("subscript")}])},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Subscript",-1))],2)}const Lg=xe(Dg,[["render",Tg]]),Ig={title:"Heading",class:"h-[30px] px-2 rounded-full hover:bg-gray-100 justify-center items-center flex text-sm text-gray-700"},Rg={class:"truncate"},Og={class:"max-h-[200px] overflow-y-auto"},Pg=["onClick"],zg=xe({__name:"vs-editor-heading",props:{editor:Object},setup(o){const t=o,n=e.ref("popover"),r=e.ref([{label:"Heading 1",value:1},{label:"Heading 2",value:2},{label:"Heading 3",value:3},{label:"Heading 4",value:4},{label:"Heading 5",value:5},{label:"Heading 6",value:6}]),l=e.computed(()=>{if(!t.editor)return"Paragraph";for(let c=1;c<=6;c++)if(t.editor.isActive("heading",{level:c}))return`H ${c}`;return"P"}),a=c=>({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;"})[c]||"",s=c=>{t.editor&&(t.editor.chain().focus().setHeading({level:c}).run(),n.value&&n.value.togglePopover())},i=()=>{t.editor&&(t.editor.chain().focus().setParagraph().run(),n.value&&n.value.togglePopover())};return(c,d)=>(e.openBlock(),e.createBlock(At,{ref_key:"popover",ref:n,placement:"bottom"},{reference:e.withCtx(()=>[e.createElementVNode("button",Ig,[e.createElementVNode("span",Rg,e.toDisplayString(l.value),1),e.createVNode(e.unref(q.ChevronDown),{class:"ml-1 h-3 w-3 text-gray-400"})])]),default:e.withCtx(()=>[e.createElementVNode("div",null,[e.createElementVNode("ul",Og,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(r.value,u=>(e.openBlock(),e.createElementBlock("li",{key:u.value,class:e.normalizeClass(["px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm",`heading-level-${u.value}`]),style:e.normalizeStyle(a(u.value)),onClick:p=>s(u.value)},e.toDisplayString(u.label),15,Pg))),128)),e.createElementVNode("li",{class:"px-3 py-2 hover:bg-gray-100 cursor-pointer text-sm border-t border-gray-200 mt-1 pt-2",onClick:i}," Paragraph ")])])]),_:1},512))}},[["__scopeId","data-v-96f02f2a"]]),jg={components:{RemoveFormatting:q.RemoveFormatting},props:{editor:Object},methods:{clearFormatting(){this.editor&&this.editor.commands.unsetAllMarks()}}};function Ug(o,t,n,r,l,a){const s=e.resolveComponent("RemoveFormatting");return e.openBlock(),e.createElementBlock("button",{title:"Clear Formatting",onClick:t[0]||(t[0]=(...i)=>a.clearFormatting&&a.clearFormatting(...i)),class:"h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100"},[e.createVNode(s,{class:"h-4 w-4"}),t[1]||(t[1]=e.createElementVNode("span",{class:"sr-only"},"Clear Formatting",-1))])}const Hg=xe(jg,[["render",Ug]]),qg={class:"relative"},Kg={key:0,class:"mt-4"},Wg=["src","alt","title"],Gg={key:0,class:"text-sm text-red-500"},Yg={key:1,class:"mt-4"},Xg={class:"text-sm text-gray-600 mb-2"},Zg={class:"flex flex-wrap gap-2"},Jg=["src","alt","onError"],Qg=["onClick"],e0={class:"flex justify-end gap-x-2 p-[20px]"},t0=Object.assign({inheritAttrs:!1},{__name:"vs-editor-image",props:{editor:{type:Object,required:!0}},setup(o){const t=o,n=e.ref(!1),r=e.ref(!1),l=e.ref({}),a=e.ref(!1),s=e.ref([]),i=e.ref(null),c=e.ref({src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}),d=e.computed(()=>{if(Array.isArray(c.value.file)){const B=c.value.file.filter(V=>V instanceof File),S=c.value.file.filter(V=>typeof V=="string"&&V.trim()!=="");return B.length+S.length>1}return c.value.file instanceof FileList?c.value.file.length>1:!1}),u=e.computed(()=>Array.isArray(c.value.file)?c.value.file.filter(B=>B instanceof File).length===1:c.value.file instanceof FileList?c.value.file.length===1:c.value.file instanceof File),p=e.computed(()=>{if(d.value)return"";if(c.value.src)return c.value.src;if(u.value){let B=null;if(Array.isArray(c.value.file)||c.value.file instanceof FileList?B=c.value.file[0]:c.value.file instanceof File&&(B=c.value.file),B instanceof File){const S=s.value.find($=>$.file===B);return S?S.preview:""}else if(typeof B=="string")return B}return""}),y=e.computed(()=>[{name:"src",label:"URL зображення",type:"text",required:!1,placeholder:"https://example.com/image.png"},{name:"file",label:"Файл (можна вибрати кілька)",type:"file",multiple:!0,required:!1,placeholder:"Шлях до файлу зображення",accept:"image/*"},{name:"width",label:"Ширина",type:"number",required:!1,placeholder:"Ширина зображення",clearable:!0,min:0},{name:"height",label:"Висота",type:"number",required:!1,placeholder:"Висота зображення",clearable:!0,min:0},{name:"alt",label:"Альтернативний текст",type:"text",required:!1,placeholder:"Опис зображення"},{name:"title",label:"Заголовок (необов'язково)",type:"text",required:!1,placeholder:"Заголовок зображення"},{name:"link",label:"Посилання",type:"text",required:!1,placeholder:"https://example.com"},{name:"openInNewTab",label:"Відкривати у новій вкладці?",type:"switcher",required:!1}]),k=()=>{if(!t.editor)return;if(t.editor.isActive("image")){const{state:S}=t.editor,{selection:$}=S,{$from:V}=$;let M=null,O=null;if(V.parent.type.name==="image")M=V.before(V.depth),O=V.parent;else for(let Q=V.depth;Q>0;Q--){const ke=V.node(Q),he=V.before(Q);ke.type.name==="paragraph"&&ke.forEach((J,me)=>{if(J.type.name==="image"){const de=he+me+1;(M===null||Math.abs(de-$.$from.pos)<Math.abs(M-$.$from.pos))&&(M=de,O=J)}})}if(M!==null&&O){try{t.editor.chain().focus().setNodeSelection(M).run()}catch{t.editor.chain().focus().setTextSelection(M).run()}i.value=M}else{t.editor.chain().focus().selectParentNode().run();const{state:Q}=t.editor;i.value=Q.selection.$from.pos}const E=O?O.attrs:t.editor.getAttributes("image");a.value=!0;let K="",T=!1;const Y=t.editor.getAttributes("link");Y&&Y.href&&(K=Y.href,T=Y.target==="_blank");const I=E.src||"",X=I?[I]:[];c.value={src:I,file:X,alt:E.alt||"",title:E.title||"",width:E.width||"",height:E.height||"",link:K,openInNewTab:T}}else a.value=!1,c.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1};r.value=!1,n.value=!0},m=()=>{n.value=!1,r.value=!1,a.value=!1,s.value=[],i.value=null,c.value={src:"",file:[],alt:"",title:"",width:"",height:"",link:"",openInNewTab:!1}},h=async B=>{if(!B||B.length===0)return;const S=[];for(const $ of B)if($&&$.type&&$.type.startsWith("image/")&&!s.value.some(M=>M.file===$)){const M=new Promise((O,E)=>{const K=new FileReader;K.onload=T=>{s.value.push({file:$,preview:T.target.result,error:!1}),O()},K.onerror=E,K.readAsDataURL($)});S.push(M)}await Promise.all(S)},b=B=>{s.value.splice(B,1),Array.isArray(c.value.file)&&c.value.file.splice(B,1)},_=()=>{const B=c.value.width!==null&&c.value.width!==void 0&&c.value.width!==""&&String(c.value.width).trim()!==""?String(c.value.width).trim():"",S=c.value.height!==null&&c.value.height!==void 0&&c.value.height!==""&&String(c.value.height).trim()!==""?String(c.value.height).trim():"",$={};return B&&S?($.width=B,$.height=S,$.style=`width: ${B}px; height: ${S}px; object-fit: fill;`):B?($.width=B,$.height=void 0):S?($.height=S,$.width=void 0):($.width=void 0,$.height=void 0),$},x=(B,S=null,$=50)=>{const V=()=>{const{view:E}=B;if(!E||!E.dom)return;E.dom.querySelectorAll("img.editor-image[width][height]").forEach(Y=>{if(Y instanceof HTMLImageElement){const I=Y.getAttribute("width"),X=Y.getAttribute("height");I&&X&&I!=="auto"&&X!=="auto"&&I!==""&&X!==""&&!isNaN(Number(I))&&!isNaN(Number(X))&&(Y.style.cssText=`
36
+ width: ${I}px !important;
37
+ height: ${X}px !important;
38
38
  max-width: none !important;
39
39
  max-height: none !important;
40
40
  min-width: auto !important;
41
41
  min-height: auto !important;
42
42
  object-fit: fill !important;
43
- `.replace(/\s+/g," ").trim())}})},M=c.value.width,O=c.value.height;M&&O&&M!==""&&O!==""?[0,N,N*2,N*3,N*4].forEach(K=>{setTimeout(V,K)}):(V(),setTimeout(V,N))},C=async()=>{let E=[],$=[];if(Array.isArray(c.value.file)?(E=c.value.file.filter(B=>B instanceof File),$=c.value.file.filter(B=>typeof B=="string"&&B.trim()!=="")):c.value.file instanceof FileList?E=Array.from(c.value.file):c.value.file instanceof File?E=[c.value.file]:typeof c.value.file=="string"&&c.value.file.trim()!==""&&($=[c.value.file]),E.length===0&&$.length===0&&l.value&&l.value.file){const B=l.value.file;Array.isArray(B)?(E=B.filter(K=>K instanceof File),$=B.filter(K=>typeof K=="string"&&K.trim()!=="")):B instanceof FileList?E=Array.from(B):B instanceof File?E=[B]:typeof B=="string"&&B.trim()!==""&&($=[B])}if($.length>0&&!a.value){for(const B of $)s.value.some(K=>K.url===B)||s.value.push({url:B,preview:B,error:!1});if(E.length===0&&s.value.length>0){await H();return}}const N=E.length,V=N+$.length;if(!(a.value&&N<=1)){if(N>0){const B=E.filter(K=>!s.value.some(I=>I.file===K));B.length>0&&await h(B)}}if(!a.value){if(V>1||d.value||s.value.length>1){if(s.value.length>0){await H();return}else if(N>0){if(await h(E),s.value.length>0){await H();return}}else if($.length>0){await H();return}}else if(s.value.length>1){await H();return}}let M=c.value.src;if(u.value){let B=null;if(Array.isArray(c.value.file)||c.value.file instanceof FileList?B=c.value.file[0]:(c.value.file instanceof File||typeof c.value.file=="string")&&(B=c.value.file),B instanceof File)try{const K=new FileReader,I=await new Promise((G,L)=>{K.onload=Z=>G(Z.target.result),K.onerror=L,K.readAsDataURL(B)});M=I,a.value&&(c.value.src=I)}catch(K){console.error("Помилка при читанні файлу:",K),ue.notify({type:"error",title:"Помилка",message:"Не вдалося прочитати файл"});return}else typeof B=="string"&&B.trim()!==""&&(M=B.trim(),a.value&&B.trim()!==c.value.src&&(c.value.src=B.trim(),M=B.trim()))}else if(Array.isArray(c.value.file)&&c.value.file.length===1){const B=c.value.file[0];typeof B=="string"&&B.trim()!==""&&(M=B.trim(),(!c.value.src||c.value.src!==B.trim())&&(c.value.src=B.trim()))}else typeof c.value.file=="string"&&c.value.file.trim()!==""&&(M=c.value.file.trim(),(!c.value.src||c.value.src!==c.value.file.trim())&&(c.value.src=c.value.file.trim()));const O=M||Array.isArray(c.value.file)&&c.value.file.length>0&&(c.value.file.some(B=>B instanceof File)||c.value.file.some(B=>typeof B=="string"&&B.trim()!==""))||c.value.file instanceof FileList&&c.value.file.length>0||typeof c.value.file=="string"&&c.value.file.trim()!=="";if(!M&&!O){ue.notify({type:"warning",title:"Попередження",message:"Будь ласка, введіть URL зображення або виберіть файл"});return}if(!d.value&&!O&&await l.value.validate()){ue.notify({type:"warning",title:"Попередження",message:"Будь ласка, заповніть всі обов'язкові поля"});return}if(t.editor&&M)if(a.value&&i.value!==null){const{state:B}=t.editor;try{t.editor.chain().focus().setNodeSelection(i.value).run()}catch{t.editor.chain().focus().setTextSelection(i.value).run()}const K=t.editor.getAttributes("link"),I=K&&K.href,G=w(),L={src:M,alt:c.value.alt||"",title:c.value.title||"",...G};if((!c.value.width||c.value.width==="")&&(L.width=void 0),(!c.value.height||c.value.height==="")&&(L.height=void 0),t.editor.chain().focus().updateAttributes("image",L).run(),setTimeout(()=>{const{view:Z}=t.editor;if(!Z||!Z.dom)return;Z.dom.querySelectorAll("img.editor-image").forEach(pe=>{if(pe instanceof HTMLImageElement){const ee=pe.getAttribute("src")||pe.src;(ee===M||ee.includes(M.split("/").pop()))&&(c.value.width&&c.value.height?(pe.style.setProperty("width",`${c.value.width}px`,"important"),pe.style.setProperty("height",`${c.value.height}px`,"important"),pe.style.setProperty("object-fit","fill","important"),pe.style.setProperty("max-width","none","important"),pe.style.setProperty("max-height","none","important")):(pe.style.removeProperty("width"),pe.style.removeProperty("height"),pe.style.removeProperty("object-fit"),pe.style.removeProperty("max-width"),pe.style.removeProperty("max-height")))}})},20),c.value.link&&c.value.link.trim()!==""){let Z=c.value.link.trim();Z.match(/^https?:\/\//i)||(Z="https://"+Z),I?t.editor.chain().focus().extendMarkRange("link").setLink({href:Z,target:c.value.openInNewTab?"_blank":null}).run():t.editor.chain().focus().selectParentNode().setLink({href:Z,target:c.value.openInNewTab?"_blank":null}).run()}else I&&t.editor.chain().focus().extendMarkRange("link").unsetLink().run()}else{const{state:B}=t.editor,{selection:K}=B,{$anchor:I}=K;let G=null;for(let Z=I.depth;Z>0;Z--){const oe=I.node(Z);if(oe&&oe.type.name==="paragraph"){G=oe;break}}if(G&&G.content.content.some(Z=>Z.type.name==="image")){const Z=S(G,I.before(I.depth));if(Z!==null){const oe=w(),be=B.schema.nodes.image.create({src:M,alt:c.value.alt||"",title:c.value.title||"",...oe});if(c.value.link&&c.value.link.trim()!==""){let pe=c.value.link.trim();pe.match(/^https?:\/\//i)||(pe="https://"+pe);const ee=B.schema.marks.link.create({href:pe,target:c.value.openInNewTab?"_blank":null}),ae=be.type.create(be.attrs,be.content,[ee]);t.editor.chain().focus().insertContentAt(Z+1,ae).run(),x(t.editor,M)}else t.editor.chain().focus().insertContentAt(Z+1,be).run(),x(t.editor,M)}else if(c.value.link&&c.value.link.trim()!==""){const oe=w();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...oe}).run(),setTimeout(()=>{let be=c.value.link.trim();be.match(/^https?:\/\//i)||(be="https://"+be),t.editor.chain().focus().selectParentNode().setLink({href:be,target:c.value.openInNewTab?"_blank":null}).run(),x(t.editor,M,20)},10)}else{const oe=w();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...oe}).run(),x(t.editor,M)}}else if(c.value.link&&c.value.link.trim()!==""){const Z=w();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...Z}).run(),setTimeout(()=>{let oe=c.value.link.trim();oe.match(/^https?:\/\//i)||(oe="https://"+oe),t.editor.chain().focus().selectParentNode().setLink({href:oe,target:c.value.openInNewTab?"_blank":null}).run(),x(t.editor,M,20)},10)}else{const Z=w();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...Z}).run(),x(t.editor,M)}}m()},S=(E,$)=>{let N=null;return E.forEach((V,M)=>{V.type.name==="image"&&(N=$+M+1)}),N},H=async()=>{if(t.editor){if(s.value.length===0)if(Array.isArray(c.value.file)&&c.value.file.length>0){const E=c.value.file.filter(N=>typeof N=="string"&&N.trim()!==""),$=c.value.file.filter(N=>N instanceof File);for(const N of E)s.value.some(V=>V.url===N||V.preview===N)||s.value.push({url:N,preview:N,error:!1});$.length>0&&await h($)}else d.value&&await h(c.value.file);if(s.value.length!==0)try{const E=[],$=w();for(const N of s.value){const V=N.url||N.preview||"";if(!V)continue;const M=t.editor.schema.nodes.image.create({src:V,alt:c.value.alt||"",title:c.value.title||"",...$});E.push(M)}E.length>0&&(t.editor.chain().focus().command(({tr:N,dispatch:V})=>{if(V){const{selection:M}=N,{$anchor:O}=M;let B=M.$anchor.pos,K=null,I=null;for(let L=O.depth;L>0;L--){const Z=O.node(L);if(Z&&Z.type.name==="paragraph"){K=Z,I=O.start(L);break}}if(K){let L=null;K.forEach((Z,oe)=>{Z.type.name==="image"&&(L=I+oe+1)}),L!==null?B=L+1:B=I+K.content.size}let G=B;return E.forEach(L=>{N.insert(G,L),G+=L.nodeSize}),!0}return!1}).run(),c.value.width&&c.value.height&&setTimeout(()=>{const{view:N}=t.editor;N&&N.dom&&N.dom.querySelectorAll("img.editor-image").forEach(O=>{O instanceof HTMLImageElement&&Array.from(s.value).some(K=>{const I=K.url||K.preview||"",G=O.src||O.getAttribute("src")||"";return G===I||G.includes(I.split("/").pop())})&&(O.style.setProperty("width",`${c.value.width}px`,"important"),O.style.setProperty("height",`${c.value.height}px`,"important"),O.style.setProperty("object-fit","fill","important"),O.style.setProperty("max-width","none","important"),O.style.setProperty("max-height","none","important"))})},50)),m()}catch(E){console.error("Помилка при додаванні зображень:",E),ue.notify({type:"error",title:"Помилка",message:"Не вдалося додати зображення"})}}},W=async()=>{await C()},T=()=>{m()};return e.watch(()=>c.value.file,async(E,$)=>{if(r.value=!1,!(a.value&&Array.isArray(E)&&E.length===1&&typeof E[0]=="string"&&!E.some(V=>V instanceof File)))if(Array.isArray(E)&&E.length>0){const N=E.filter(M=>M instanceof File),V=E.filter(M=>typeof M=="string"&&M.trim()!=="");if(N.length>0&&(a.value?a.value&&N.length===1&&V.length===0&&(s.value=[]):s.value=[],(!a.value||N.length>1||V.length>0)&&await h(N),a.value&&N.length===1&&V.length===0)){const M=new FileReader;M.onload=O=>{c.value.src=O.target.result},M.readAsDataURL(N[0])}if(V.length>0)if(a.value)a.value&&V.length===1&&N.length===0&&(c.value.src=V[0]);else{N.length===0&&(s.value=[]);for(const M of V)s.value.some(O=>O.url===M||O.preview===M)||s.value.push({url:M,preview:M,error:!1})}}else E&&typeof E=="object"&&E instanceof FileList?(a.value||(s.value=[]),await h(Array.from(E))):E&&typeof E=="object"&&!Array.isArray(E)&&E instanceof File?(a.value||(s.value=[]),await h([E])):a.value||(s.value=[])},{immediate:!1}),e.watch(()=>c.value.src,()=>{r.value=!1}),(E,$)=>(e.openBlock(),e.createElementBlock("div",qg,[e.createElementVNode("button",{onClick:b,class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",o.editor?.isActive("image")?"bg-gray-200 text-gray-900":""]),title:"Додати зображення"},[e.createVNode(e.unref(q.Image),{class:"h-4 w-4"}),$[4]||($[4]=e.createElementVNode("span",{class:"sr-only"},"Додати зображення",-1))],2),e.createVNode(Ur,{modelValue:n.value,"onUpdate:modelValue":$[3]||($[3]=N=>n.value=N),title:a.value?"Редагувати зображення":"Додати зображення"},{footer:e.withCtx(()=>[e.createElementVNode("div",e0,[e.createElementVNode("button",{onClick:T,type:"button",class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"}," Скасувати "),e.createElementVNode("button",{onClick:W,type:"button",class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"},e.toDisplayString(a.value?"Оновити зображення":"Додати зображення"),1)])]),default:e.withCtx(()=>[e.createVNode(at,{modelValue:c.value,"onUpdate:modelValue":$[0]||($[0]=N=>c.value=N),schema:g.value,form:l.value,"onUpdate:form":$[1]||($[1]=N=>l.value=N)},null,8,["modelValue","schema","form"]),p.value&&!d.value?(e.openBlock(),e.createElementBlock("div",Kg,[$[5]||($[5]=e.createElementVNode("p",{class:"text-sm text-gray-600 mb-2"},"Попередній перегляд:",-1)),e.withDirectives(e.createElementVNode("img",{src:p.value,alt:c.value.alt||"Попередній перегляд зображення",title:c.value.title,class:"max-w-full h-auto max-h-32 rounded border",onError:$[2]||($[2]=N=>r.value=!0)},null,40,Wg),[[e.vShow,!r.value]]),r.value?(e.openBlock(),e.createElementBlock("p",Gg," Не вдалося завантажити попередній перегляд зображення ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),s.value.length>0?(e.openBlock(),e.createElementBlock("div",Yg,[e.createElementVNode("p",Xg,"Попередній перегляд ("+e.toDisplayString(s.value.length)+" зображень):",1),$[6]||($[6]=e.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"}," Зображення будуть розміщені в ряд, якщо вони помістяться по ширині ",-1)),e.createElementVNode("div",Zg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(N,V)=>(e.openBlock(),e.createElementBlock("div",{key:V,class:"relative"},[e.withDirectives(e.createElementVNode("img",{src:N.preview,alt:`Попередній перегляд ${V+1}`,class:"max-w-[100px] max-h-[100px] rounded border object-contain",onError:M=>N.error=!0},null,40,Jg),[[e.vShow,!N.error]]),e.createElementVNode("button",{onClick:M=>y(V),class:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs hover:bg-red-600",type:"button"}," × ",8,Qg)]))),128))])])):e.createCommentVNode("",!0)]),_:1},8,["modelValue","title"])]))}}),n0={class:"flex items-center"},o0=["disabled"],r0=["disabled"],l0=ye(Object.assign({inheritAttrs:!1},{__name:"vs-editor-history",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor?.can().undo()&&t.editor.chain().focus().undo().run()},r=()=>{t.editor?.can().redo()&&t.editor.chain().focus().redo().run()};return(l,a)=>(e.openBlock(),e.createElementBlock("div",n0,[e.createElementVNode("button",{onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-l-full hover:text-gray-900 hover:bg-gray-100 border-r border-gray-200",[o.editor?.can().undo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!o.editor?.can().undo(),title:"Undo (Ctrl+Z)"},[e.createVNode(e.unref(q.Undo2),{class:"h-4 w-4"})],10,o0),e.createElementVNode("button",{onClick:r,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-r-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.can().redo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!o.editor?.can().redo(),title:"Redo (Ctrl+Y)"},[e.createVNode(e.unref(q.Redo2),{class:"h-4 w-4"})],10,r0)]))}}),[["__scopeId","data-v-6a87fc55"]]),a0={class:"relative"},s0={class:"p-6"},i0={class:"flex justify-between items-center mb-4"},c0={bold:xh,italic:Ch,color:mg,background_color:xg,highlight:wg,bullet_list:uh,ordered_list:mh,blockquote:ih,codeblock:yh,underline:vh,strike:Eh,link:Gh,table:Qh,text_align:ng,type_tag:lg,font_family:Bg,font_size:Ng,superscript:Fg,subscript:Lg,heading:zg,clear_formatting:Hg,image:t0,history:l0,help:ye(Object.assign({inheritAttrs:!1},{__name:"vs-editor-help",props:{editor:Object},setup(o){const t=e.ref(!1),n=e.ref(null),r=()=>{t.value=!t.value},l=()=>{t.value=!1};return(a,s)=>(e.openBlock(),e.createElementBlock("div",a0,[e.createElementVNode("button",{ref_key:"helpButton",ref:n,onClick:r,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 text-gray-500",[t.value?"bg-gray-100 text-gray-900":"text-gray-500"]]),title:"Markdown Shortcuts Help"},[e.createVNode(e.unref(q.CircleHelp),{class:"h-4 w-4"})],2),t.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[100001]",onClick:l},[e.createElementVNode("div",{class:"bg-white rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",onClick:s[0]||(s[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",s0,[e.createElementVNode("div",i0,[s[1]||(s[1]=e.createElementVNode("h2",{class:"text-xl font-semibold text-gray-900"},"Common Markdown Syntax & Shortcuts",-1)),e.createElementVNode("button",{onClick:l,class:"text-gray-400 hover:text-gray-600 transition-colors"},[e.createVNode(e.unref(q.X),{class:"h-6 w-6"})])]),s[2]||(s[2]=e.createStaticVNode('<div class="space-y-6" data-v-92c21275><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Markdown Syntax</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Element</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Example</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Bold</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>**bold text**</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>__bold text__</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Italics</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>*italic text*</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>_italic text_</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Strikethrough</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>~strikethrough text~</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Headings</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275># Heading 1</code>, <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>## Heading 2</code>, etc., up to <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>###### Heading 6</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Unordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use an asterisk (*), dash (-), or plus sign (+) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Ordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use a number followed by a period and a space (e.g., <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>1. First item</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Blockquotes</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Start with a greater-than sign (&gt;) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Inline Code</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Surround with backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>`</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Code Blocks</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Enclose with three backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>```</code>) before and after the code. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Images</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>![alt text](url)</code> syntax. </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Links</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>[Link Text](url)</code> syntax. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Checklists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Create a list item with <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [ ]</code> for an incomplete task or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [x]</code> for a completed one. </td></tr></tbody></table></div></div><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Common Editing Shortcuts</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Shortcut</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Action</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+A</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Select all text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+B</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply bold formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+C</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Copy selected text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+I</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply italic formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+K</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Open the insert link dialog</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+S</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Save the current document</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+V</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Paste copied text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+X</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Cut selected text</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Y</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Shift+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Z</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr></tbody></table></div></div></div>',1))])])])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-92c21275"]]),horizontal_rule:{__name:"vs-editor-horizontal-rule",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().setHorizontalRule().run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Horizontal Rule",onClick:n,class:"flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex"},[e.createVNode(e.unref(q.Minus),{class:"h-4 w-4"})]))}},fullscreen:{__name:"vs-editor-fullscreen",props:{editor:Object},emits:["toggle-fullscreen"],setup(o,{emit:t}){const n=t,r=()=>{n("toggle-fullscreen")};return(l,a)=>(e.openBlock(),e.createElementBlock("button",{title:"Fullscreen",onClick:r,class:"w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100"},[e.createVNode(e.unref(q.Maximize),{class:"h-4 w-4"})]))}},tab:Object.assign({inheritAttrs:!1},{__name:"vs-editor-tab",props:{editor:{type:Object,required:!0}},setup(o){const t=o,n=()=>{t.editor&&(t.editor.isActive("bulletList")||t.editor.isActive("orderedList"))&&t.editor.chain().focus().sinkListItem("listItem").run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Tab (Increase List Indent)",onClick:n,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none"},[e.createVNode(e.unref(q.ListIndentIncrease),{class:"h-4 w-4"})]))}})},Kr={basic:["history","font_family","font_size","bold","italic","underline","strike","text_align","bullet_list","ordered_list","link","image","clear_formatting","help"],default:["history","heading","font_family","font_size","bold","italic","underline","strike","superscript","subscript","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","clear_formatting","fullscreen","help"],full:["history","heading","font_family","font_size","bold","italic","underline","strike","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","superscript","subscript","clear_formatting","fullscreen","help"]},d0={class:"flex align-middle gap-x-0.5 border-b flex-wrap border-b-gray-200 px-[10px] py-[6px] border-solid border-transparent"},u0={class:"rich-text-scroll-wrapper"},p0={key:0,class:"richtext-loading text-sm text-gray-500"},f0={key:1,class:"richtext-error text-sm text-red-600"},m0={class:"html-source-editor"},h0={class:"flex justify-end border-t border-[#e5e7eb] bg-[#f8fafc] px-4 min-h-[38px] items-start overflow-visible"},g0={class:"inline-flex items-stretch -mt-px"},y0=Object.freeze(Object.defineProperty({__proto__:null,default:Object.assign({inheritAttrs:!1},{__name:"vs-richtext",props:e.mergeModels({modelValue:{type:String,default:()=>""},height:{type:String,default:()=>"300px"},format:{type:String,default:()=>"html"},toolbar:{type:[Array,String],default:()=>"default"}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(null),{t:l}=zn(),a=e.computed(()=>t.format==="md"?"markdown":"html"),s=e.computed(()=>t.format==="md"?l("form.richtext.markdown"):l("form.richtext.html")),{editor:i,editorInstance:c,focusEditor:d,createEditor:u,destroyEditor:p,isLoading:g,loadError:b}=qm(t),{isHtmlMode:m,htmlContent:h,htmlTextarea:y,toggleHtmlMode:w}=Km(i,t.format,(T,E)=>{T==="update:modelValue"&&(n.value=E)},{toEditorContent:ko,toSourceContent:th}),{isFullscreen:x,toggleFullscreen:C}=Wm(),S=e.computed(()=>typeof t.toolbar=="string"?Kr[t.toolbar]||Kr.default:t.toolbar),H=e.computed(()=>S.value.map(T=>c0[T]).filter(Boolean));e.watch(()=>t.modelValue,async T=>{if(i.value){const E=await ko(T||"",t.format),$=i.value.getHTML();E!==$&&E!=="<p></p>"&&i.value.commands.setContent(E,!1)}},{immediate:!0});const W=T=>{if(!T||!T.view||!T.view.dom)return;T.view.dom.querySelectorAll("img.editor-image[width][height]").forEach($=>{if($ instanceof HTMLImageElement){const N=$.getAttribute("width"),V=$.getAttribute("height");N&&V&&N!=="auto"&&V!=="auto"&&N!==""&&V!==""&&!isNaN(Number(N))&&!isNaN(Number(V))&&($.style.cssText=`
44
- width: ${N}px !important;
43
+ `.replace(/\s+/g," ").trim())}})},M=c.value.width,O=c.value.height;M&&O&&M!==""&&O!==""?[0,$,$*2,$*3,$*4].forEach(K=>{setTimeout(V,K)}):(V(),setTimeout(V,$))},v=async()=>{let B=[],S=[];if(Array.isArray(c.value.file)?(B=c.value.file.filter(E=>E instanceof File),S=c.value.file.filter(E=>typeof E=="string"&&E.trim()!=="")):c.value.file instanceof FileList?B=Array.from(c.value.file):c.value.file instanceof File?B=[c.value.file]:typeof c.value.file=="string"&&c.value.file.trim()!==""&&(S=[c.value.file]),B.length===0&&S.length===0&&l.value&&l.value.file){const E=l.value.file;Array.isArray(E)?(B=E.filter(K=>K instanceof File),S=E.filter(K=>typeof K=="string"&&K.trim()!=="")):E instanceof FileList?B=Array.from(E):E instanceof File?B=[E]:typeof E=="string"&&E.trim()!==""&&(S=[E])}if(S.length>0&&!a.value){for(const E of S)s.value.some(K=>K.url===E)||s.value.push({url:E,preview:E,error:!1});if(B.length===0&&s.value.length>0){await U();return}}const $=B.length,V=$+S.length;if(!(a.value&&$<=1)){if($>0){const E=B.filter(K=>!s.value.some(T=>T.file===K));E.length>0&&await h(E)}}if(!a.value){if(V>1||d.value||s.value.length>1){if(s.value.length>0){await U();return}else if($>0){if(await h(B),s.value.length>0){await U();return}}else if(S.length>0){await U();return}}else if(s.value.length>1){await U();return}}let M=c.value.src;if(u.value){let E=null;if(Array.isArray(c.value.file)||c.value.file instanceof FileList?E=c.value.file[0]:(c.value.file instanceof File||typeof c.value.file=="string")&&(E=c.value.file),E instanceof File)try{const K=new FileReader,T=await new Promise((Y,I)=>{K.onload=X=>Y(X.target.result),K.onerror=I,K.readAsDataURL(E)});M=T,a.value&&(c.value.src=T)}catch(K){console.error("Помилка при читанні файлу:",K),pe.notify({type:"error",title:"Помилка",message:"Не вдалося прочитати файл"});return}else typeof E=="string"&&E.trim()!==""&&(M=E.trim(),a.value&&E.trim()!==c.value.src&&(c.value.src=E.trim(),M=E.trim()))}else if(Array.isArray(c.value.file)&&c.value.file.length===1){const E=c.value.file[0];typeof E=="string"&&E.trim()!==""&&(M=E.trim(),(!c.value.src||c.value.src!==E.trim())&&(c.value.src=E.trim()))}else typeof c.value.file=="string"&&c.value.file.trim()!==""&&(M=c.value.file.trim(),(!c.value.src||c.value.src!==c.value.file.trim())&&(c.value.src=c.value.file.trim()));const O=M||Array.isArray(c.value.file)&&c.value.file.length>0&&(c.value.file.some(E=>E instanceof File)||c.value.file.some(E=>typeof E=="string"&&E.trim()!==""))||c.value.file instanceof FileList&&c.value.file.length>0||typeof c.value.file=="string"&&c.value.file.trim()!=="";if(!M&&!O){pe.notify({type:"warning",title:"Попередження",message:"Будь ласка, введіть URL зображення або виберіть файл"});return}if(!d.value&&!O&&await l.value.validate()){pe.notify({type:"warning",title:"Попередження",message:"Будь ласка, заповніть всі обов'язкові поля"});return}if(t.editor&&M)if(a.value&&i.value!==null){const{state:E}=t.editor;try{t.editor.chain().focus().setNodeSelection(i.value).run()}catch{t.editor.chain().focus().setTextSelection(i.value).run()}const K=t.editor.getAttributes("link"),T=K&&K.href,Y=_(),I={src:M,alt:c.value.alt||"",title:c.value.title||"",...Y};if((!c.value.width||c.value.width==="")&&(I.width=void 0),(!c.value.height||c.value.height==="")&&(I.height=void 0),t.editor.chain().focus().updateAttributes("image",I).run(),setTimeout(()=>{const{view:X}=t.editor;if(!X||!X.dom)return;X.dom.querySelectorAll("img.editor-image").forEach(he=>{if(he instanceof HTMLImageElement){const J=he.getAttribute("src")||he.src;(J===M||J.includes(M.split("/").pop()))&&(c.value.width&&c.value.height?(he.style.setProperty("width",`${c.value.width}px`,"important"),he.style.setProperty("height",`${c.value.height}px`,"important"),he.style.setProperty("object-fit","fill","important"),he.style.setProperty("max-width","none","important"),he.style.setProperty("max-height","none","important")):(he.style.removeProperty("width"),he.style.removeProperty("height"),he.style.removeProperty("object-fit"),he.style.removeProperty("max-width"),he.style.removeProperty("max-height")))}})},20),c.value.link&&c.value.link.trim()!==""){let X=c.value.link.trim();X.match(/^https?:\/\//i)||(X="https://"+X),T?t.editor.chain().focus().extendMarkRange("link").setLink({href:X,target:c.value.openInNewTab?"_blank":null}).run():t.editor.chain().focus().selectParentNode().setLink({href:X,target:c.value.openInNewTab?"_blank":null}).run()}else T&&t.editor.chain().focus().extendMarkRange("link").unsetLink().run()}else{const{state:E}=t.editor,{selection:K}=E,{$anchor:T}=K;let Y=null;for(let X=T.depth;X>0;X--){const Q=T.node(X);if(Q&&Q.type.name==="paragraph"){Y=Q;break}}if(Y&&Y.content.content.some(X=>X.type.name==="image")){const X=N(Y,T.before(T.depth));if(X!==null){const Q=_(),ke=E.schema.nodes.image.create({src:M,alt:c.value.alt||"",title:c.value.title||"",...Q});if(c.value.link&&c.value.link.trim()!==""){let he=c.value.link.trim();he.match(/^https?:\/\//i)||(he="https://"+he);const J=E.schema.marks.link.create({href:he,target:c.value.openInNewTab?"_blank":null}),me=ke.type.create(ke.attrs,ke.content,[J]);t.editor.chain().focus().insertContentAt(X+1,me).run(),x(t.editor,M)}else t.editor.chain().focus().insertContentAt(X+1,ke).run(),x(t.editor,M)}else if(c.value.link&&c.value.link.trim()!==""){const Q=_();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...Q}).run(),setTimeout(()=>{let ke=c.value.link.trim();ke.match(/^https?:\/\//i)||(ke="https://"+ke),t.editor.chain().focus().selectParentNode().setLink({href:ke,target:c.value.openInNewTab?"_blank":null}).run(),x(t.editor,M,20)},10)}else{const Q=_();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...Q}).run(),x(t.editor,M)}}else if(c.value.link&&c.value.link.trim()!==""){const X=_();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...X}).run(),setTimeout(()=>{let Q=c.value.link.trim();Q.match(/^https?:\/\//i)||(Q="https://"+Q),t.editor.chain().focus().selectParentNode().setLink({href:Q,target:c.value.openInNewTab?"_blank":null}).run(),x(t.editor,M,20)},10)}else{const X=_();t.editor.chain().focus().setImage({src:M,alt:c.value.alt||"",title:c.value.title||"",...X}).run(),x(t.editor,M)}}m()},N=(B,S)=>{let $=null;return B.forEach((V,M)=>{V.type.name==="image"&&($=S+M+1)}),$},U=async()=>{if(t.editor){if(s.value.length===0)if(Array.isArray(c.value.file)&&c.value.file.length>0){const B=c.value.file.filter($=>typeof $=="string"&&$.trim()!==""),S=c.value.file.filter($=>$ instanceof File);for(const $ of B)s.value.some(V=>V.url===$||V.preview===$)||s.value.push({url:$,preview:$,error:!1});S.length>0&&await h(S)}else d.value&&await h(c.value.file);if(s.value.length!==0)try{const B=[],S=_();for(const $ of s.value){const V=$.url||$.preview||"";if(!V)continue;const M=t.editor.schema.nodes.image.create({src:V,alt:c.value.alt||"",title:c.value.title||"",...S});B.push(M)}B.length>0&&(t.editor.chain().focus().command(({tr:$,dispatch:V})=>{if(V){const{selection:M}=$,{$anchor:O}=M;let E=M.$anchor.pos,K=null,T=null;for(let I=O.depth;I>0;I--){const X=O.node(I);if(X&&X.type.name==="paragraph"){K=X,T=O.start(I);break}}if(K){let I=null;K.forEach((X,Q)=>{X.type.name==="image"&&(I=T+Q+1)}),I!==null?E=I+1:E=T+K.content.size}let Y=E;return B.forEach(I=>{$.insert(Y,I),Y+=I.nodeSize}),!0}return!1}).run(),c.value.width&&c.value.height&&setTimeout(()=>{const{view:$}=t.editor;$&&$.dom&&$.dom.querySelectorAll("img.editor-image").forEach(O=>{O instanceof HTMLImageElement&&Array.from(s.value).some(K=>{const T=K.url||K.preview||"",Y=O.src||O.getAttribute("src")||"";return Y===T||Y.includes(T.split("/").pop())})&&(O.style.setProperty("width",`${c.value.width}px`,"important"),O.style.setProperty("height",`${c.value.height}px`,"important"),O.style.setProperty("object-fit","fill","important"),O.style.setProperty("max-width","none","important"),O.style.setProperty("max-height","none","important"))})},50)),m()}catch(B){console.error("Помилка при додаванні зображень:",B),pe.notify({type:"error",title:"Помилка",message:"Не вдалося додати зображення"})}}},W=async()=>{await v()},L=()=>{m()};return e.watch(()=>c.value.file,async(B,S)=>{if(r.value=!1,!(a.value&&Array.isArray(B)&&B.length===1&&typeof B[0]=="string"&&!B.some(V=>V instanceof File)))if(Array.isArray(B)&&B.length>0){const $=B.filter(M=>M instanceof File),V=B.filter(M=>typeof M=="string"&&M.trim()!=="");if($.length>0&&(a.value?a.value&&$.length===1&&V.length===0&&(s.value=[]):s.value=[],(!a.value||$.length>1||V.length>0)&&await h($),a.value&&$.length===1&&V.length===0)){const M=new FileReader;M.onload=O=>{c.value.src=O.target.result},M.readAsDataURL($[0])}if(V.length>0)if(a.value)a.value&&V.length===1&&$.length===0&&(c.value.src=V[0]);else{$.length===0&&(s.value=[]);for(const M of V)s.value.some(O=>O.url===M||O.preview===M)||s.value.push({url:M,preview:M,error:!1})}}else B&&typeof B=="object"&&B instanceof FileList?(a.value||(s.value=[]),await h(Array.from(B))):B&&typeof B=="object"&&!Array.isArray(B)&&B instanceof File?(a.value||(s.value=[]),await h([B])):a.value||(s.value=[])},{immediate:!1}),e.watch(()=>c.value.src,()=>{r.value=!1}),(B,S)=>(e.openBlock(),e.createElementBlock("div",qg,[e.createElementVNode("button",{onClick:k,class:e.normalizeClass(["h-[30px] w-[30px] flex items-center justify-center text-gray-500 rounded-full cursor-pointer hover:text-gray-900 hover:bg-gray-100",o.editor?.isActive("image")?"bg-gray-200 text-gray-900":""]),title:"Додати зображення"},[e.createVNode(e.unref(q.Image),{class:"h-4 w-4"}),S[4]||(S[4]=e.createElementVNode("span",{class:"sr-only"},"Додати зображення",-1))],2),e.createVNode(Ur,{modelValue:n.value,"onUpdate:modelValue":S[3]||(S[3]=$=>n.value=$),title:a.value?"Редагувати зображення":"Додати зображення"},{footer:e.withCtx(()=>[e.createElementVNode("div",e0,[e.createElementVNode("button",{onClick:L,type:"button",class:"px-4 py-2 text-sm font-medium text-gray-700 bg-white border border-gray-300 rounded-md hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-blue-500"}," Скасувати "),e.createElementVNode("button",{onClick:W,type:"button",class:"px-4 py-2 text-sm font-medium text-white bg-blue-600 border border-transparent rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500"},e.toDisplayString(a.value?"Оновити зображення":"Додати зображення"),1)])]),default:e.withCtx(()=>[e.createVNode(ot,{modelValue:c.value,"onUpdate:modelValue":S[0]||(S[0]=$=>c.value=$),schema:y.value,form:l.value,"onUpdate:form":S[1]||(S[1]=$=>l.value=$)},null,8,["modelValue","schema","form"]),p.value&&!d.value?(e.openBlock(),e.createElementBlock("div",Kg,[S[5]||(S[5]=e.createElementVNode("p",{class:"text-sm text-gray-600 mb-2"},"Попередній перегляд:",-1)),e.withDirectives(e.createElementVNode("img",{src:p.value,alt:c.value.alt||"Попередній перегляд зображення",title:c.value.title,class:"max-w-full h-auto max-h-32 rounded border",onError:S[2]||(S[2]=$=>r.value=!0)},null,40,Wg),[[e.vShow,!r.value]]),r.value?(e.openBlock(),e.createElementBlock("p",Gg," Не вдалося завантажити попередній перегляд зображення ")):e.createCommentVNode("",!0)])):e.createCommentVNode("",!0),s.value.length>0?(e.openBlock(),e.createElementBlock("div",Yg,[e.createElementVNode("p",Xg,"Попередній перегляд ("+e.toDisplayString(s.value.length)+" зображень):",1),S[6]||(S[6]=e.createElementVNode("p",{class:"text-xs text-gray-500 mb-2"}," Зображення будуть розміщені в ряд, якщо вони помістяться по ширині ",-1)),e.createElementVNode("div",Zg,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,($,V)=>(e.openBlock(),e.createElementBlock("div",{key:V,class:"relative"},[e.withDirectives(e.createElementVNode("img",{src:$.preview,alt:`Попередній перегляд ${V+1}`,class:"max-w-[100px] max-h-[100px] rounded border object-contain",onError:M=>$.error=!0},null,40,Jg),[[e.vShow,!$.error]]),e.createElementVNode("button",{onClick:M=>b(V),class:"absolute -top-2 -right-2 bg-red-500 text-white rounded-full w-5 h-5 flex items-center justify-center text-xs hover:bg-red-600",type:"button"}," × ",8,Qg)]))),128))])])):e.createCommentVNode("",!0)]),_:1},8,["modelValue","title"])]))}}),n0={class:"flex items-center"},o0=["disabled"],r0=["disabled"],l0=xe(Object.assign({inheritAttrs:!1},{__name:"vs-editor-history",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor?.can().undo()&&t.editor.chain().focus().undo().run()},r=()=>{t.editor?.can().redo()&&t.editor.chain().focus().redo().run()};return(l,a)=>(e.openBlock(),e.createElementBlock("div",n0,[e.createElementVNode("button",{onClick:n,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-l-full hover:text-gray-900 hover:bg-gray-100 border-r border-gray-200",[o.editor?.can().undo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!o.editor?.can().undo(),title:"Undo (Ctrl+Z)"},[e.createVNode(e.unref(q.Undo2),{class:"h-4 w-4"})],10,o0),e.createElementVNode("button",{onClick:r,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-r-full hover:text-gray-900 hover:bg-gray-100",[o.editor?.can().redo()?"text-gray-500":"text-gray-300 cursor-not-allowed"]]),disabled:!o.editor?.can().redo(),title:"Redo (Ctrl+Y)"},[e.createVNode(e.unref(q.Redo2),{class:"h-4 w-4"})],10,r0)]))}}),[["__scopeId","data-v-6a87fc55"]]),a0={class:"relative"},s0={class:"p-6"},i0={class:"flex justify-between items-center mb-4"},c0={bold:xh,italic:Ch,color:mg,background_color:xg,highlight:wg,bullet_list:uh,ordered_list:mh,blockquote:ih,codeblock:yh,underline:vh,strike:Eh,link:Gh,table:Qh,text_align:ng,type_tag:lg,font_family:Bg,font_size:Ng,superscript:Mg,subscript:Lg,heading:zg,clear_formatting:Hg,image:t0,history:l0,help:xe(Object.assign({inheritAttrs:!1},{__name:"vs-editor-help",props:{editor:Object},setup(o){const t=e.ref(!1),n=e.ref(null),r=()=>{t.value=!t.value},l=()=>{t.value=!1};return(a,s)=>(e.openBlock(),e.createElementBlock("div",a0,[e.createElementVNode("button",{ref_key:"helpButton",ref:n,onClick:r,class:e.normalizeClass(["w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 text-gray-500",[t.value?"bg-gray-100 text-gray-900":"text-gray-500"]]),title:"Markdown Shortcuts Help"},[e.createVNode(e.unref(q.CircleHelp),{class:"h-4 w-4"})],2),t.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-[100001]",onClick:l},[e.createElementVNode("div",{class:"bg-white rounded-lg shadow-xl max-w-2xl w-full mx-4 max-h-[80vh] overflow-y-auto",onClick:s[0]||(s[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("div",s0,[e.createElementVNode("div",i0,[s[1]||(s[1]=e.createElementVNode("h2",{class:"text-xl font-semibold text-gray-900"},"Common Markdown Syntax & Shortcuts",-1)),e.createElementVNode("button",{onClick:l,class:"text-gray-400 hover:text-gray-600 transition-colors"},[e.createVNode(e.unref(q.X),{class:"h-6 w-6"})])]),s[2]||(s[2]=e.createStaticVNode('<div class="space-y-6" data-v-92c21275><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Markdown Syntax</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Element</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Example</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Bold</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>**bold text**</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>__bold text__</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Italics</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>*italic text*</code> or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>_italic text_</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Strikethrough</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>~strikethrough text~</code></td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Headings</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275># Heading 1</code>, <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>## Heading 2</code>, etc., up to <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>###### Heading 6</code></td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Unordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use an asterisk (*), dash (-), or plus sign (+) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Ordered Lists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use a number followed by a period and a space (e.g., <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>1. First item</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Blockquotes</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Start with a greater-than sign (&gt;) followed by a space. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Inline Code</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Surround with backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>`</code>). </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Code Blocks</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Enclose with three backticks (<code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>```</code>) before and after the code. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Images</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>![alt text](url)</code> syntax. </td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Links</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Use <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>[Link Text](url)</code> syntax. </td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275>Checklists</td><td class="border border-gray-200 px-3 py-2" data-v-92c21275> Create a list item with <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [ ]</code> for an incomplete task or <code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>- [x]</code> for a completed one. </td></tr></tbody></table></div></div><div data-v-92c21275><h3 class="text-lg font-medium text-gray-800 mb-3" data-v-92c21275>Common Editing Shortcuts</h3><div class="overflow-x-auto" data-v-92c21275><table class="w-full border-collapse" data-v-92c21275><thead data-v-92c21275><tr class="bg-gray-50" data-v-92c21275><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Shortcut</th><th class="border border-gray-200 px-3 py-2 text-left font-medium text-gray-700" data-v-92c21275>Action</th></tr></thead><tbody class="text-sm" data-v-92c21275><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+A</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Select all text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+B</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply bold formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+C</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Copy selected text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+I</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Apply italic formatting</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+K</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Open the insert link dialog</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+S</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Save the current document</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+V</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Paste copied text</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+X</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Cut selected text</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Y</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Shift+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Redo the last action</td></tr><tr data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Ctrl+Z</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr><tr class="bg-gray-25" data-v-92c21275><td class="border border-gray-200 px-3 py-2 font-medium" data-v-92c21275><code class="bg-gray-100 px-2 py-1 rounded" data-v-92c21275>Alt+Backspace</code></td><td class="border border-gray-200 px-3 py-2" data-v-92c21275>Undo the last action</td></tr></tbody></table></div></div></div>',1))])])])):e.createCommentVNode("",!0)]))}}),[["__scopeId","data-v-92c21275"]]),horizontal_rule:{__name:"vs-editor-horizontal-rule",props:{editor:Object},setup(o){const t=o,n=()=>{t.editor&&t.editor.chain().focus().setHorizontalRule().run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Horizontal Rule",onClick:n,class:"flex flex-col h-[30px] px-1 rounded-full hover:bg-gray-100 justify-center items-center relative flex"},[e.createVNode(e.unref(q.Minus),{class:"h-4 w-4"})]))}},fullscreen:{__name:"vs-editor-fullscreen",props:{editor:Object},emits:["toggle-fullscreen"],setup(o,{emit:t}){const n=t,r=()=>{n("toggle-fullscreen")};return(l,a)=>(e.openBlock(),e.createElementBlock("button",{title:"Fullscreen",onClick:r,class:"w-[30px] h-[30px] flex items-center justify-center text-gray-500 rounded-full hover:text-gray-900 hover:bg-gray-100"},[e.createVNode(e.unref(q.Maximize),{class:"h-4 w-4"})]))}},tab:Object.assign({inheritAttrs:!1},{__name:"vs-editor-tab",props:{editor:{type:Object,required:!0}},setup(o){const t=o,n=()=>{t.editor&&(t.editor.isActive("bulletList")||t.editor.isActive("orderedList"))&&t.editor.chain().focus().sinkListItem("listItem").run()};return(r,l)=>(e.openBlock(),e.createElementBlock("button",{title:"Tab (Increase List Indent)",onClick:n,class:"text-gray-500 w-[30px] h-[30px] flex items-center justify-center rounded-full hover:text-gray-900 hover:bg-gray-100 focus:outline-none"},[e.createVNode(e.unref(q.ListIndentIncrease),{class:"h-4 w-4"})]))}})},Kr={basic:["history","font_family","font_size","bold","italic","underline","strike","text_align","bullet_list","ordered_list","link","image","clear_formatting","help"],default:["history","heading","font_family","font_size","bold","italic","underline","strike","superscript","subscript","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","clear_formatting","fullscreen","help"],full:["history","heading","font_family","font_size","bold","italic","underline","strike","color","background_color","highlight","text_align","bullet_list","ordered_list","blockquote","codeblock","table","link","image","horizontal_rule","superscript","subscript","clear_formatting","fullscreen","help"]},d0={class:"flex align-middle gap-x-0.5 border-b flex-wrap border-b-gray-200 px-[10px] py-[6px] border-solid border-transparent"},u0={class:"rich-text-scroll-wrapper"},p0={key:0,class:"richtext-loading text-sm text-gray-500"},f0={key:1,class:"richtext-error text-sm text-red-600"},m0={class:"html-source-editor"},h0={class:"flex justify-end border-t border-[#e5e7eb] bg-[#f8fafc] px-4 min-h-[38px] items-start overflow-visible"},g0={class:"inline-flex items-stretch -mt-px"},y0=Object.freeze(Object.defineProperty({__proto__:null,default:Object.assign({inheritAttrs:!1},{__name:"vs-richtext",props:e.mergeModels({modelValue:{type:String,default:()=>""},height:{type:String,default:()=>"300px"},format:{type:String,default:()=>"html"},toolbar:{type:[Array,String],default:()=>"default"}},{modelValue:{},modelModifiers:{}}),emits:e.mergeModels(["update:modelValue"],["update:modelValue"]),setup(o){const t=o,n=e.useModel(o,"modelValue"),r=e.ref(null),{t:l}=zn(),a=e.computed(()=>t.format==="md"?"markdown":"html"),s=e.computed(()=>t.format==="md"?l("form.richtext.markdown"):l("form.richtext.html")),{editor:i,editorInstance:c,focusEditor:d,createEditor:u,destroyEditor:p,isLoading:y,loadError:k}=qm(t),{isHtmlMode:m,htmlContent:h,htmlTextarea:b,toggleHtmlMode:_}=Km(i,t.format,(L,B)=>{L==="update:modelValue"&&(n.value=B)},{toEditorContent:xo,toSourceContent:th}),{isFullscreen:x,toggleFullscreen:v}=Wm(),N=e.computed(()=>typeof t.toolbar=="string"?Kr[t.toolbar]||Kr.default:t.toolbar),U=e.computed(()=>N.value.map(L=>c0[L]).filter(Boolean));e.watch(()=>t.modelValue,async L=>{if(i.value){const B=await xo(L||"",t.format),S=i.value.getHTML();B!==S&&B!=="<p></p>"&&i.value.commands.setContent(B,!1)}},{immediate:!0});const W=L=>{if(!L||!L.view||!L.view.dom)return;L.view.dom.querySelectorAll("img.editor-image[width][height]").forEach(S=>{if(S instanceof HTMLImageElement){const $=S.getAttribute("width"),V=S.getAttribute("height");$&&V&&$!=="auto"&&V!=="auto"&&$!==""&&V!==""&&!isNaN(Number($))&&!isNaN(Number(V))&&(S.style.cssText=`
44
+ width: ${$}px !important;
45
45
  height: ${V}px !important;
46
46
  max-width: none !important;
47
47
  max-height: none !important;
48
48
  min-width: auto !important;
49
49
  min-height: auto !important;
50
50
  object-fit: fill !important;
51
- `.replace(/\s+/g," ").trim())}})};return e.watch(i,T=>{T&&(e.nextTick(()=>{W(i.value)}),i.value.on("update",async E=>{const $=E.editor.getHTML(),N=await nh($,t.format);N!==t.modelValue&&$!=="<p></p>"&&(n.value=N),setTimeout(()=>{W(E.editor)},10)}))}),e.onMounted(async()=>{const T=await ko(t.modelValue||"",t.format);await u(r.value,T),e.nextTick(()=>{i.value&&setTimeout(()=>{W(i.value)},100)})}),e.onBeforeUnmount(()=>{p()}),(T,E)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["bg-white rounded-md w-full",{"fixed left-0 right-0 top-0 bottom-0 z-[100000]":e.unref(x)}])},[e.createElementVNode("div",d0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(H.value,$=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:$},[e.unref(i)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent($),{key:0,editor:e.unref(c),onToggleFullscreen:e.unref(C)},null,40,["editor","onToggleFullscreen"])):e.createCommentVNode("",!0)],64))),128))]),e.createElementVNode("div",{onClick:E[1]||(E[1]=(...$)=>e.unref(d)&&e.unref(d)(...$)),class:"relative w-full px-4 py-2 bg-white rounded-b-lg editor-content",style:e.normalizeStyle({height:e.unref(x)?"calc(95vh - 44px)":o.height})},[e.withDirectives(e.createElementVNode("div",u0,[e.createElementVNode("div",{ref_key:"editorElement",ref:r,class:"relative w-full"},null,512),e.unref(g)?(e.openBlock(),e.createElementBlock("div",p0,"Loading editor...")):e.createCommentVNode("",!0),e.unref(b)?(e.openBlock(),e.createElementBlock("div",f0,e.toDisplayString(e.unref(b)),1)):e.createCommentVNode("",!0)],512),[[e.vShow,!e.unref(m)]]),e.withDirectives(e.createElementVNode("div",m0,[e.createVNode(to,{ref_key:"htmlTextarea",ref:y,modelValue:e.unref(h),"onUpdate:modelValue":E[0]||(E[0]=$=>e.isRef(h)?h.value=$:null),height:"100%",syntax:a.value,theme:"vs-light"},null,8,["modelValue","syntax"])],512),[[e.vShow,e.unref(m)]])],4),e.createElementVNode("div",h0,[e.createElementVNode("div",g0,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-bl-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",e.unref(m)?"text-[#8f99aa]":"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]"]),onClick:E[2]||(E[2]=$=>e.unref(w)(!1))},e.toDisplayString(e.unref(l)("form.richtext.editor")),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] border-l-0 bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-br-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",e.unref(m)?"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]":"text-[#8f99aa]"]),onClick:E[3]||(E[3]=$=>e.unref(w)(!0))},e.toDisplayString(s.value),3)])])],2))}})},Symbol.toStringTag,{value:"Module"}));he.ModalEdit=cr,he.VForm=at,he.VsInputAddress=or,he.VsInputArray=nr,he.VsInputArraySelect=Bn,he.VsInputCheckbox=No,he.VsInputCodegen=Zo,he.VsInputColor=er,he.VsInputContainer=Lo,he.VsInputDate=Sm,he.VsInputEmail=Gn,he.VsInputFile=Fo,he.VsInputFileList=Do,he.VsInputInlineSelect=kn,he.VsInputKeyValue=Jo,he.VsInputMask=mn,he.VsInputMonaco=to,he.VsInputNumber=Vo,he.VsInputRadio=Xn,he.VsInputRange=tr,he.VsInputRichtext=Po,he.VsInputSelect=Qn,he.VsInputSlug=Xo,he.VsInputStatic=Wn,he.VsInputSwitcher=Kn,he.VsInputTag=Yo,he.VsInputTel=Yn,he.VsInputText=zt,he.VsInputTextArray=Qo,he.VsInputTextarea=Oo,he.default=at,he.inputs=rr,he.richtextLocaleEn=kr,he.richtextLocaleUk=xr,he.richtextMessages=io,he.vsInputDatatable=zo,he.vsInputMap=Go,Object.defineProperties(he,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
51
+ `.replace(/\s+/g," ").trim())}})};return e.watch(i,L=>{L&&(e.nextTick(()=>{W(i.value)}),i.value.on("update",async B=>{const S=B.editor.getHTML(),$=await nh(S,t.format);$!==t.modelValue&&S!=="<p></p>"&&(n.value=$),setTimeout(()=>{W(B.editor)},10)}))}),e.onMounted(async()=>{const L=await xo(t.modelValue||"",t.format);await u(r.value,L),e.nextTick(()=>{i.value&&setTimeout(()=>{W(i.value)},100)})}),e.onBeforeUnmount(()=>{p()}),(L,B)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["bg-white rounded-md w-full",{"fixed left-0 right-0 top-0 bottom-0 z-[100000]":e.unref(x)}])},[e.createElementVNode("div",d0,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(U.value,S=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:S},[e.unref(i)?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(S),{key:0,editor:e.unref(c),onToggleFullscreen:e.unref(v)},null,40,["editor","onToggleFullscreen"])):e.createCommentVNode("",!0)],64))),128))]),e.createElementVNode("div",{onClick:B[1]||(B[1]=(...S)=>e.unref(d)&&e.unref(d)(...S)),class:"relative w-full px-4 py-2 bg-white rounded-b-lg editor-content",style:e.normalizeStyle({height:e.unref(x)?"calc(95vh - 44px)":o.height})},[e.withDirectives(e.createElementVNode("div",u0,[e.createElementVNode("div",{ref_key:"editorElement",ref:r,class:"relative w-full"},null,512),e.unref(y)?(e.openBlock(),e.createElementBlock("div",p0,"Loading editor...")):e.createCommentVNode("",!0),e.unref(k)?(e.openBlock(),e.createElementBlock("div",f0,e.toDisplayString(e.unref(k)),1)):e.createCommentVNode("",!0)],512),[[e.vShow,!e.unref(m)]]),e.withDirectives(e.createElementVNode("div",m0,[e.createVNode(no,{ref_key:"htmlTextarea",ref:b,modelValue:e.unref(h),"onUpdate:modelValue":B[0]||(B[0]=S=>e.isRef(h)?h.value=S:null),height:"100%",syntax:a.value,theme:"vs-light"},null,8,["modelValue","syntax"])],512),[[e.vShow,e.unref(m)]])],4),e.createElementVNode("div",h0,[e.createElementVNode("div",g0,[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-bl-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",e.unref(m)?"text-[#8f99aa]":"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]"]),onClick:B[2]||(B[2]=S=>e.unref(_)(!1))},e.toDisplayString(e.unref(l)("form.richtext.editor")),3),e.createElementVNode("button",{type:"button",class:e.normalizeClass(["min-w-[96px] h-[30px] px-[14px] border border-[#cfd6e0] border-l-0 bg-[#f3f5f8] text-[8px] font-bold uppercase tracking-[0.06em] leading-none cursor-pointer transition-colors duration-200 border-b-[1px] border-b-[#cfd6e0] rounded-none rounded-br-[8px] hover:bg-[#eef1f5] hover:text-[#667284]",e.unref(m)?"!bg-white text-[#49556a] border-[#cfd6e0] border-t-transparent relative z-[1]":"text-[#8f99aa]"]),onClick:B[3]||(B[3]=S=>e.unref(_)(!0))},e.toDisplayString(s.value),3)])])],2))}})},Symbol.toStringTag,{value:"Module"}));ye.ModalEdit=cr,ye.VForm=ot,ye.VsInputAddress=or,ye.VsInputArray=nr,ye.VsInputArraySelect=Bn,ye.VsInputCheckbox=No,ye.VsInputCodegen=Zo,ye.VsInputColor=er,ye.VsInputContainer=Lo,ye.VsInputDate=Sm,ye.VsInputEmail=Yn,ye.VsInputFile=Mo,ye.VsInputFileList=Do,ye.VsInputInlineSelect=kn,ye.VsInputKeyValue=Jo,ye.VsInputMask=mn,ye.VsInputMonaco=no,ye.VsInputNumber=Vo,ye.VsInputRadio=Zn,ye.VsInputRange=tr,ye.VsInputRichtext=Po,ye.VsInputSelect=eo,ye.VsInputSlug=Xo,ye.VsInputStatic=Gn,ye.VsInputSwitcher=Wn,ye.VsInputTag=Yo,ye.VsInputTel=Xn,ye.VsInputText=zt,ye.VsInputTextArray=Qo,ye.VsInputTextarea=Oo,ye.default=ot,ye.inputs=rr,ye.richtextLocaleEn=kr,ye.richtextLocaleUk=xr,ye.richtextMessages=co,ye.vsInputDatatable=zo,ye.vsInputMap=Go,Object.defineProperties(ye,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});