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