import{_ as A}from"./nselect.vue-jigqjeiw.js";import{u as E,c as F,a as W,_ as q}from"./f1cbvne4.js";import{_ as z}from"./nswitch.vue-km9qm824.js";import{_ as J}from"./ndropdown.vue-ji36i25f.js";import{_ as O}from"./ncode-block.vue-lex5o4lv.js";import{_ as R}from"./ndrawer.vue-nkn577bf.js";import{A as h,d as x}from"./vendor/quicktype-core-gg1jfx29.js";import{p as G,k,q as N,x as C,U as c,S as m,a2 as n,a4 as d,a3 as r,R as i,I as f,F as D,af as S,u as _,a9 as b,ad as H}from"./vendor/json-editor-vue-g7zhhq6q.js";import"./vendor/unocss-hvn0t0zz.js";import"./vendor/shiki-hjqm7vcp.js";import"./client-etfulgf7.js";const K={border:"b base",flex:"~ items-center gap-2",sticky:"","left-0":"","right-0":"","top-0":"","z-1":"",p3:"","bg-base":""},M={key:0,flex:"~ items-center justify-center",absolute:"","bottom--1":"","right--2":"","h-4":"","w-4":"","rounded-full":"","bg-lime:30":"","text-8px":""},P={flex:"~ col","w-100":"","of-auto":"",py2:""},Q={"text-xs":"",capitalize:"",op75:""},ie=G({__name:"DataSchemaDrawer",setup(X){const s=E(),V=k(0),l=k("TypeScript"),v=N(()=>h.all.find(e=>e.displayName===l.value)),o=k(v.value?.optionDefinitions.filter(e=>typeof e.defaultValue=="boolean")),y=F(async()=>{if(V.value,!s.value)return"";const e=x.jsonInputForTargetLanguage(l.value);await e.addSource({name:s.value.name??"Data",samples:[s.value.input]});const t=new x.InputData;return t.addInput(e),(await x.quicktype({inputData:t,lang:l.value,rendererOptions:o.value?.reduce((u,p)=>(u[p.name]=p.defaultValue,u),{})})).lines.join(`
`)}),j=N(()=>{const e=l.value.toLocaleLowerCase();return e.startsWith("javascript")?"javascript":e.startsWith("json")?"json":e.startsWith("typescript")?"typescript":e});C(o,()=>{V.value++},{deep:!0}),C(l,()=>{o.value=v.value?.optionDefinitions.filter(e=>typeof e.defaultValue=="boolean")});const $=W();function B(){$(y.value||"")}return(e,t)=>{const w=A,u=q,p=z,I=J,L=O,T=R;return v.value?(n(),c(H,{key:0,to:"body"},[d(T,{"model-value":!!_(s)?.input,"auto-close":"","max-w-screen":"","w-2xl":"","n-code-block":"",onClose:t[2]||(t[2]=a=>s.value=null)},{default:r(()=>[i("div",K,[t[3]||(t[3]=i("p",{"mr-2":""}," Schema ",-1)),d(w,{modelValue:l.value,"onUpdate:modelValue":t[0]||(t[0]=a=>l.value=a),n:"xs primary"},{default:r(()=>[(n(!0),f(D,null,S(_(h.all),a=>(n(),f("option",{key:a.displayName},b(a.displayName),1))),128))]),_:1},8,["modelValue"]),o.value?.length?(n(),c(I,{key:0,n:"sm lime"},{trigger:r(({click:a})=>[d(u,{icon:"carbon-settings","h-full":"",onClick:g=>a()},null,8,["onClick"]),o.value?(n(),f("span",M,b(o.value.length),1)):m("",!0)]),default:r(()=>[i("div",P,[(n(!0),f(D,null,S(o.value,(a,g)=>(n(),c(p,{key:a.name,modelValue:o.value[g].defaultValue,"onUpdate:modelValue":U=>o.value[g].defaultValue=U,flex:"~ gap-2",rounded:"",px2:"",py2:""},{default:r(()=>[i("span",Q,b(a.description),1)]),_:2},1032,["modelValue","onUpdate:modelValue"]))),128))])]),_:1})):m("",!0),t[4]||(t[4]=i("div",{"flex-auto":""},null,-1)),d(u,{icon:"carbon-copy","mr-6":"","h-full":"",onClick:t[1]||(t[1]=a=>B())})]),_(y)?(n(),c(L,{key:0,lang:j.value,code:_(y)},null,8,["lang","code"])):m("",!0)]),_:1},8,["model-value"])])):m("",!0)}}});export{ie as default};
