import{C as e,E as t,Mt as n,Qt as r,W as i,X as a,Y as o,_ as s,c,ct as l,dt as u,g as d,h as f,m as p,tn as m,v as h,w as g}from"./vendor/json-editor-vue-ddj4xtqm.js";import{c as _,j as v,k as y,on as b}from"#entry";import{t as x}from"./nselect-cmll6q59.js";import{t as S}from"./ncheckbox-f4a8016e.js";var C={p4:``,flex:`~ col gap-4`},w={key:1,ml2:``,flex:``},T=[`value`],E={key:0,flex:``,"gap-4":``},D=t({__name:`ServerRouteInputs`,props:{modelValue:{},keys:{default:()=>[]},default:{default:()=>({})},disabled:{type:Boolean,default:!1}},setup(t,{emit:D}){let O=t,k=b(O,`modelValue`,D,{passive:!0}),A=p(()=>[...O.keys,`active`,`key`,`value`,`type`]),j=p(()=>{let e={};for(let t of A.value)e[t]=O.default[t]||``;return e}),M=[`string`,`number`,`boolean`,`file`,`date`,`time`,`datetime-local`];function N(e,t){let n=t.target;if(n.files&&n.files[0]){let t=n.files[0],r=new FileReader;r.readAsDataURL(t),r.onload=()=>{k.value[e].value=r.result}}}return l(()=>k,e=>{e.value.forEach(e=>{if(e.type===`number`&&typeof e.value!=`number`){let t=Number.parseFloat(e.value);e.value=Number.isNaN(t)?0:t}else e.type===`boolean`&&typeof e.value!=`boolean`?e.value=!0:e.type===`file`&&typeof e.value!=`object`?e.value=``:e.type===`date`&&typeof e.value==`string`&&!e.value.match(/^\d{4}-\d{2}-\d{2}$/)?e.value=new Date().toISOString().slice(0,10):e.type===`time`&&typeof e.value==`string`&&!e.value.match(/^\d{2}:\d{2}$/)?e.value=new Date().toISOString().slice(11,16):e.type===`datetime-local`&&typeof e.value==`string`&&!e.value.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}$/)?e.value=new Date().toISOString().slice(0,16):e.type===`string`&&(e.value=e.value.toString())})},{deep:!0,immediate:!0,flush:`sync`}),(l,p)=>{let b=S,D=_,O=x,P=v,F=y;return i(),h(`div`,C,[(i(!0),h(c,null,o(n(k),(e,p)=>(i(),h(`div`,{key:p,flex:`~ gap-2`,"justify-around":``},[a(l.$slots,`input`,{item:e}),(i(!0),h(c,null,o(A.value,n=>(i(),h(c,{key:n},[e.type!==null&&n===`active`?(i(),d(b,{key:0,modelValue:e[n],"onUpdate:modelValue":t=>e[n]=t,n:`sm primary`,disabled:t.disabled},null,8,[`modelValue`,`onUpdate:modelValue`,`disabled`])):s(``,!0),e.type!==null&&n===`key`?(i(),d(D,{key:1,modelValue:e[n],"onUpdate:modelValue":t=>e[n]=t,placeholder:n,"flex-1":``,"font-mono":``,n:`sm primary`,disabled:t.disabled,class:r(t.disabled?`op50`:``)},null,8,[`modelValue`,`onUpdate:modelValue`,`placeholder`,`disabled`,`class`])):n===`value`?(i(),h(c,{key:2},[e.type===`file`?(i(),d(D,{key:0,type:`file`,disabled:t.disabled,class:r(t.disabled?`op75`:``),onChange:e=>N(p,e)},null,8,[`disabled`,`class`,`onChange`])):e.type===`boolean`?(i(),h(`div`,w,[g(b,{modelValue:e.value,"onUpdate:modelValue":t=>e.value=t,placeholder:`Value`,n:`green lg`,disabled:t.disabled},null,8,[`modelValue`,`onUpdate:modelValue`,`disabled`])])):(i(),d(D,{key:2,modelValue:e.value,"onUpdate:modelValue":t=>e.value=t,type:e.type,placeholder:`Value`,"flex-1":``,"font-mono":``,n:`sm primary`,disabled:t.disabled,class:r(t.disabled?`op75`:``)},null,8,[`modelValue`,`onUpdate:modelValue`,`type`,`disabled`,`class`]))],64)):n===`type`?(i(),d(O,{key:3,modelValue:e.type,"onUpdate:modelValue":t=>e.type=t,n:`sm green`,class:r(t.disabled?`op75`:``),disabled:t.disabled},{default:u(()=>[(i(),h(c,null,o(M,e=>f(`option`,{key:e,value:e},m(e),9,T)),64))]),_:1},8,[`modelValue`,`onUpdate:modelValue`,`class`,`disabled`])):s(``,!0)],64))),128)),a(l.$slots,`input-actions`,{},()=>[g(F,{n:`red`,disabled:t.disabled,class:r(t.disabled?`op0!`:``),onClick:e=>n(k).splice(p,1)},{default:u(()=>[g(P,{icon:`carbon:trash-can`})]),_:1},8,[`disabled`,`class`,`onClick`])])]))),128)),t.disabled?s(``,!0):(i(),h(`div`,E,[a(l.$slots,`actions`,{params:n(k)},()=>[g(F,{icon:`carbon-add`,n:`sm primary`,my1:``,"px-3":``,onClick:p[0]||=e=>n(k).push({...j.value})},{default:u(()=>[...p[2]||=[e(` Add `,-1)]]),_:1}),p[4]||=f(`div`,{"flex-auto":``},null,-1),n(k).length?(i(),d(F,{key:0,icon:`carbon-trash-can`,n:`sm red`,my1:``,"px-3":``,onClick:p[1]||=e=>n(k).splice(0,n(k).length)},{default:u(()=>[...p[3]||=[e(` Remove All `,-1)]]),_:1})):s(``,!0)])])),a(l.$slots,`default`)])}}}),O=Object.assign(D,{__name:`ServerRouteInputs`});export{O as t};