json-schema-builder-react 0.0.4 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -1
- package/dist-lib/components/JsonSchemaBuilder.d.ts +6 -1
- package/dist-lib/components/PropertyDocument.d.ts +2 -1
- package/dist-lib/components/PropertyEditDialog.d.ts +2 -1
- package/dist-lib/components/ui/button.d.ts +1 -1
- package/dist-lib/components/ui/dialog.d.ts +1 -1
- package/dist-lib/hooks/useChildManager.d.ts +60 -0
- package/dist-lib/hooks/useDialogManager.d.ts +75 -0
- package/dist-lib/hooks/useInlineEditor.d.ts +71 -0
- package/dist-lib/hooks/usePropertyEditor.d.ts +1 -1
- package/dist-lib/hooks/useTypeSelector.d.ts +49 -0
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/index.cjs.map +1 -1
- package/dist-lib/index.js +1077 -3232
- package/dist-lib/index.js.map +1 -1
- package/package.json +22 -12
- package/dist-lib/about.txt +0 -6
- package/dist-lib/android-chrome-192x192.png +0 -0
- package/dist-lib/android-chrome-512x512.png +0 -0
- package/dist-lib/apple-touch-icon.png +0 -0
- package/dist-lib/favicon-16x16.png +0 -0
- package/dist-lib/favicon-32x32.png +0 -0
- package/dist-lib/favicon.ico +0 -0
- package/dist-lib/site.webmanifest +0 -1
package/dist-lib/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),k=require("react"),Ke=require("@radix-ui/react-slot"),v=require("lucide-react"),He=require("@radix-ui/react-tooltip"),Xe=require("@radix-ui/react-dialog"),Ze=require("@radix-ui/react-label"),Qe=require("@radix-ui/react-select"),Ye=require("@radix-ui/react-checkbox");function Z(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(r,s,n.get?n:{enumerable:!0,get:()=>e[s]})}}return r.default=e,Object.freeze(r)}const T=Z(k),se=Z(He),V=Z(Xe),Ie=Z(Ze),z=Z(Qe),ae=Z(Ye);function Pe(e){var r,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(r=0;r<o;r++)e[r]&&(s=Pe(e[r]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function ze(){for(var e,r,s=0,n="",o=arguments.length;s<o;s++)(e=arguments[s])&&(r=Pe(e))&&(n&&(n+=" "),n+=r);return n}const we=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,Ne=ze,Ae=(e,r)=>s=>{var n;if((r==null?void 0:r.variants)==null)return Ne(e,s==null?void 0:s.class,s==null?void 0:s.className);const{variants:o,defaultVariants:a}=r,i=Object.keys(o).map(l=>{const f=s==null?void 0:s[l],w=a==null?void 0:a[l];if(f===null)return null;const y=we(f)||we(w);return o[l][y]}),d=s&&Object.entries(s).reduce((l,f)=>{let[w,y]=f;return y===void 0||(l[w]=y),l},{}),c=r==null||(n=r.compoundVariants)===null||n===void 0?void 0:n.reduce((l,f)=>{let{class:w,className:y,...S}=f;return Object.entries(S).every(x=>{let[m,p]=x;return Array.isArray(p)?p.includes({...a,...d}[m]):{...a,...d}[m]===p})?[...l,w,y]:l},[]);return Ne(e,i,c,s==null?void 0:s.class,s==null?void 0:s.className)},ge="-",et=e=>{const r=st(e),{conflictingClassGroups:s,conflictingClassGroupModifiers:n}=e;return{getClassGroupId:i=>{const d=i.split(ge);return d[0]===""&&d.length!==1&&d.shift(),Re(d,r)||tt(i)},getConflictingClassGroupIds:(i,d)=>{const c=s[i]||[];return d&&n[i]?[...c,...n[i]]:c}}},Re=(e,r)=>{var i;if(e.length===0)return r.classGroupId;const s=e[0],n=r.nextPart.get(s),o=n?Re(e.slice(1),n):void 0;if(o)return o;if(r.validators.length===0)return;const a=e.join(ge);return(i=r.validators.find(({validator:d})=>d(a)))==null?void 0:i.classGroupId},Ce=/^\[(.+)\]$/,tt=e=>{if(Ce.test(e)){const r=Ce.exec(e)[1],s=r==null?void 0:r.substring(0,r.indexOf(":"));if(s)return"arbitrary.."+s}},st=e=>{const{theme:r,prefix:s}=e,n={nextPart:new Map,validators:[]};return nt(Object.entries(e.classGroups),s).forEach(([a,i])=>{ie(i,n,a,r)}),n},ie=(e,r,s,n)=>{e.forEach(o=>{if(typeof o=="string"){const a=o===""?r:ke(r,o);a.classGroupId=s;return}if(typeof o=="function"){if(rt(o)){ie(o(n),r,s,n);return}r.validators.push({validator:o,classGroupId:s});return}Object.entries(o).forEach(([a,i])=>{ie(i,ke(r,a),s,n)})})},ke=(e,r)=>{let s=e;return r.split(ge).forEach(n=>{s.nextPart.has(n)||s.nextPart.set(n,{nextPart:new Map,validators:[]}),s=s.nextPart.get(n)}),s},rt=e=>e.isThemeGetter,nt=(e,r)=>r?e.map(([s,n])=>{const o=n.map(a=>typeof a=="string"?r+a:typeof a=="object"?Object.fromEntries(Object.entries(a).map(([i,d])=>[r+i,d])):a);return[s,o]}):e,ot=e=>{if(e<1)return{get:()=>{},set:()=>{}};let r=0,s=new Map,n=new Map;const o=(a,i)=>{s.set(a,i),r++,r>e&&(r=0,n=s,s=new Map)};return{get(a){let i=s.get(a);if(i!==void 0)return i;if((i=n.get(a))!==void 0)return o(a,i),i},set(a,i){s.has(a)?s.set(a,i):o(a,i)}}},qe="!",at=e=>{const{separator:r,experimentalParseClassName:s}=e,n=r.length===1,o=r[0],a=r.length,i=d=>{const c=[];let l=0,f=0,w;for(let p=0;p<d.length;p++){let b=d[p];if(l===0){if(b===o&&(n||d.slice(p,p+a)===r)){c.push(d.slice(f,p)),f=p+a;continue}if(b==="/"){w=p;continue}}b==="["?l++:b==="]"&&l--}const y=c.length===0?d:d.substring(f),S=y.startsWith(qe),x=S?y.substring(1):y,m=w&&w>f?w-f:void 0;return{modifiers:c,hasImportantModifier:S,baseClassName:x,maybePostfixModifierPosition:m}};return s?d=>s({className:d,parseClassName:i}):i},it=e=>{if(e.length<=1)return e;const r=[];let s=[];return e.forEach(n=>{n[0]==="["?(r.push(...s.sort(),n),s=[]):s.push(n)}),r.push(...s.sort()),r},lt=e=>({cache:ot(e.cacheSize),parseClassName:at(e),...et(e)}),dt=/\s+/,ct=(e,r)=>{const{parseClassName:s,getClassGroupId:n,getConflictingClassGroupIds:o}=r,a=[],i=e.trim().split(dt);let d="";for(let c=i.length-1;c>=0;c-=1){const l=i[c],{modifiers:f,hasImportantModifier:w,baseClassName:y,maybePostfixModifierPosition:S}=s(l);let x=!!S,m=n(x?y.substring(0,S):y);if(!m){if(!x){d=l+(d.length>0?" "+d:d);continue}if(m=n(y),!m){d=l+(d.length>0?" "+d:d);continue}x=!1}const p=it(f).join(":"),b=w?p+qe:p,I=b+m;if(a.includes(I))continue;a.push(I);const u=o(m,x);for(let A=0;A<u.length;++A){const D=u[A];a.push(b+D)}d=l+(d.length>0?" "+d:d)}return d};function ut(){let e=0,r,s,n="";for(;e<arguments.length;)(r=arguments[e++])&&(s=Le(r))&&(n&&(n+=" "),n+=s);return n}const Le=e=>{if(typeof e=="string")return e;let r,s="";for(let n=0;n<e.length;n++)e[n]&&(r=Le(e[n]))&&(s&&(s+=" "),s+=r);return s};function mt(e,...r){let s,n,o,a=i;function i(c){const l=r.reduce((f,w)=>w(f),e());return s=lt(l),n=s.cache.get,o=s.cache.set,a=d,d(c)}function d(c){const l=n(c);if(l)return l;const f=ct(c,s);return o(c,f),f}return function(){return a(ut.apply(null,arguments))}}const C=e=>{const r=s=>s[e]||[];return r.isThemeGetter=!0,r},Ee=/^\[(?:([a-z-]+):)?(.+)\]$/i,pt=/^\d+\/\d+$/,ht=new Set(["px","full","screen"]),ft=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,gt=/\d+(%|px|r?em|[sdl]?v([hwib]|min|max)|pt|pc|in|cm|mm|cap|ch|ex|r?lh|cq(w|h|i|b|min|max))|\b(calc|min|max|clamp)\(.+\)|^0$/,xt=/^(rgba?|hsla?|hwb|(ok)?(lab|lch))\(.+\)$/,bt=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,yt=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,B=e=>X(e)||ht.has(e)||pt.test(e),U=e=>Q(e,"length",Tt),X=e=>!!e&&!Number.isNaN(Number(e)),oe=e=>Q(e,"number",X),ee=e=>!!e&&Number.isInteger(Number(e)),vt=e=>e.endsWith("%")&&X(e.slice(0,-1)),g=e=>Ee.test(e),W=e=>ft.test(e),jt=new Set(["length","size","percentage"]),wt=e=>Q(e,jt,Me),Nt=e=>Q(e,"position",Me),Ct=new Set(["image","url"]),kt=e=>Q(e,Ct,Pt),St=e=>Q(e,"",It),te=()=>!0,Q=(e,r,s)=>{const n=Ee.exec(e);return n?n[1]?typeof r=="string"?n[1]===r:r.has(n[1]):s(n[2]):!1},Tt=e=>gt.test(e)&&!xt.test(e),Me=()=>!1,It=e=>bt.test(e),Pt=e=>yt.test(e),zt=()=>{const e=C("colors"),r=C("spacing"),s=C("blur"),n=C("brightness"),o=C("borderColor"),a=C("borderRadius"),i=C("borderSpacing"),d=C("borderWidth"),c=C("contrast"),l=C("grayscale"),f=C("hueRotate"),w=C("invert"),y=C("gap"),S=C("gradientColorStops"),x=C("gradientColorStopPositions"),m=C("inset"),p=C("margin"),b=C("opacity"),I=C("padding"),u=C("saturate"),A=C("scale"),D=C("sepia"),$=C("skew"),O=C("space"),F=C("translate"),M=()=>["auto","contain","none"],J=()=>["auto","hidden","clip","visible","scroll"],_=()=>["auto",g,r],j=()=>[g,r],h=()=>["",B,U],E=()=>["auto",X,g],H=()=>["bottom","center","left","left-bottom","left-top","right","right-bottom","right-top","top"],K=()=>["solid","dashed","dotted","double","none"],ve=()=>["normal","multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity"],ne=()=>["start","end","center","between","around","evenly","stretch"],Y=()=>["","0",g],je=()=>["auto","avoid","all","avoid-page","page","left","right","column"],G=()=>[X,g];return{cacheSize:500,separator:":",theme:{colors:[te],spacing:[B,U],blur:["none","",W,g],brightness:G(),borderColor:[e],borderRadius:["none","","full",W,g],borderSpacing:j(),borderWidth:h(),contrast:G(),grayscale:Y(),hueRotate:G(),invert:Y(),gap:j(),gradientColorStops:[e],gradientColorStopPositions:[vt,U],inset:_(),margin:_(),opacity:G(),padding:j(),saturate:G(),scale:G(),sepia:Y(),skew:G(),space:j(),translate:j()},classGroups:{aspect:[{aspect:["auto","square","video",g]}],container:["container"],columns:[{columns:[W]}],"break-after":[{"break-after":je()}],"break-before":[{"break-before":je()}],"break-inside":[{"break-inside":["auto","avoid","avoid-page","avoid-column"]}],"box-decoration":[{"box-decoration":["slice","clone"]}],box:[{box:["border","content"]}],display:["block","inline-block","inline","flex","inline-flex","table","inline-table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row-group","table-row","flow-root","grid","inline-grid","contents","list-item","hidden"],float:[{float:["right","left","none","start","end"]}],clear:[{clear:["left","right","both","none","start","end"]}],isolation:["isolate","isolation-auto"],"object-fit":[{object:["contain","cover","fill","none","scale-down"]}],"object-position":[{object:[...H(),g]}],overflow:[{overflow:J()}],"overflow-x":[{"overflow-x":J()}],"overflow-y":[{"overflow-y":J()}],overscroll:[{overscroll:M()}],"overscroll-x":[{"overscroll-x":M()}],"overscroll-y":[{"overscroll-y":M()}],position:["static","fixed","absolute","relative","sticky"],inset:[{inset:[m]}],"inset-x":[{"inset-x":[m]}],"inset-y":[{"inset-y":[m]}],start:[{start:[m]}],end:[{end:[m]}],top:[{top:[m]}],right:[{right:[m]}],bottom:[{bottom:[m]}],left:[{left:[m]}],visibility:["visible","invisible","collapse"],z:[{z:["auto",ee,g]}],basis:[{basis:_()}],"flex-direction":[{flex:["row","row-reverse","col","col-reverse"]}],"flex-wrap":[{flex:["wrap","wrap-reverse","nowrap"]}],flex:[{flex:["1","auto","initial","none",g]}],grow:[{grow:Y()}],shrink:[{shrink:Y()}],order:[{order:["first","last","none",ee,g]}],"grid-cols":[{"grid-cols":[te]}],"col-start-end":[{col:["auto",{span:["full",ee,g]},g]}],"col-start":[{"col-start":E()}],"col-end":[{"col-end":E()}],"grid-rows":[{"grid-rows":[te]}],"row-start-end":[{row:["auto",{span:[ee,g]},g]}],"row-start":[{"row-start":E()}],"row-end":[{"row-end":E()}],"grid-flow":[{"grid-flow":["row","col","dense","row-dense","col-dense"]}],"auto-cols":[{"auto-cols":["auto","min","max","fr",g]}],"auto-rows":[{"auto-rows":["auto","min","max","fr",g]}],gap:[{gap:[y]}],"gap-x":[{"gap-x":[y]}],"gap-y":[{"gap-y":[y]}],"justify-content":[{justify:["normal",...ne()]}],"justify-items":[{"justify-items":["start","end","center","stretch"]}],"justify-self":[{"justify-self":["auto","start","end","center","stretch"]}],"align-content":[{content:["normal",...ne(),"baseline"]}],"align-items":[{items:["start","end","center","baseline","stretch"]}],"align-self":[{self:["auto","start","end","center","stretch","baseline"]}],"place-content":[{"place-content":[...ne(),"baseline"]}],"place-items":[{"place-items":["start","end","center","baseline","stretch"]}],"place-self":[{"place-self":["auto","start","end","center","stretch"]}],p:[{p:[I]}],px:[{px:[I]}],py:[{py:[I]}],ps:[{ps:[I]}],pe:[{pe:[I]}],pt:[{pt:[I]}],pr:[{pr:[I]}],pb:[{pb:[I]}],pl:[{pl:[I]}],m:[{m:[p]}],mx:[{mx:[p]}],my:[{my:[p]}],ms:[{ms:[p]}],me:[{me:[p]}],mt:[{mt:[p]}],mr:[{mr:[p]}],mb:[{mb:[p]}],ml:[{ml:[p]}],"space-x":[{"space-x":[O]}],"space-x-reverse":["space-x-reverse"],"space-y":[{"space-y":[O]}],"space-y-reverse":["space-y-reverse"],w:[{w:["auto","min","max","fit","svw","lvw","dvw",g,r]}],"min-w":[{"min-w":[g,r,"min","max","fit"]}],"max-w":[{"max-w":[g,r,"none","full","min","max","fit","prose",{screen:[W]},W]}],h:[{h:[g,r,"auto","min","max","fit","svh","lvh","dvh"]}],"min-h":[{"min-h":[g,r,"min","max","fit","svh","lvh","dvh"]}],"max-h":[{"max-h":[g,r,"min","max","fit","svh","lvh","dvh"]}],size:[{size:[g,r,"auto","min","max","fit"]}],"font-size":[{text:["base",W,U]}],"font-smoothing":["antialiased","subpixel-antialiased"],"font-style":["italic","not-italic"],"font-weight":[{font:["thin","extralight","light","normal","medium","semibold","bold","extrabold","black",oe]}],"font-family":[{font:[te]}],"fvn-normal":["normal-nums"],"fvn-ordinal":["ordinal"],"fvn-slashed-zero":["slashed-zero"],"fvn-figure":["lining-nums","oldstyle-nums"],"fvn-spacing":["proportional-nums","tabular-nums"],"fvn-fraction":["diagonal-fractions","stacked-fractions"],tracking:[{tracking:["tighter","tight","normal","wide","wider","widest",g]}],"line-clamp":[{"line-clamp":["none",X,oe]}],leading:[{leading:["none","tight","snug","normal","relaxed","loose",B,g]}],"list-image":[{"list-image":["none",g]}],"list-style-type":[{list:["none","disc","decimal",g]}],"list-style-position":[{list:["inside","outside"]}],"placeholder-color":[{placeholder:[e]}],"placeholder-opacity":[{"placeholder-opacity":[b]}],"text-alignment":[{text:["left","center","right","justify","start","end"]}],"text-color":[{text:[e]}],"text-opacity":[{"text-opacity":[b]}],"text-decoration":["underline","overline","line-through","no-underline"],"text-decoration-style":[{decoration:[...K(),"wavy"]}],"text-decoration-thickness":[{decoration:["auto","from-font",B,U]}],"underline-offset":[{"underline-offset":["auto",B,g]}],"text-decoration-color":[{decoration:[e]}],"text-transform":["uppercase","lowercase","capitalize","normal-case"],"text-overflow":["truncate","text-ellipsis","text-clip"],"text-wrap":[{text:["wrap","nowrap","balance","pretty"]}],indent:[{indent:j()}],"vertical-align":[{align:["baseline","top","middle","bottom","text-top","text-bottom","sub","super",g]}],whitespace:[{whitespace:["normal","nowrap","pre","pre-line","pre-wrap","break-spaces"]}],break:[{break:["normal","words","all","keep"]}],hyphens:[{hyphens:["none","manual","auto"]}],content:[{content:["none",g]}],"bg-attachment":[{bg:["fixed","local","scroll"]}],"bg-clip":[{"bg-clip":["border","padding","content","text"]}],"bg-opacity":[{"bg-opacity":[b]}],"bg-origin":[{"bg-origin":["border","padding","content"]}],"bg-position":[{bg:[...H(),Nt]}],"bg-repeat":[{bg:["no-repeat",{repeat:["","x","y","round","space"]}]}],"bg-size":[{bg:["auto","cover","contain",wt]}],"bg-image":[{bg:["none",{"gradient-to":["t","tr","r","br","b","bl","l","tl"]},kt]}],"bg-color":[{bg:[e]}],"gradient-from-pos":[{from:[x]}],"gradient-via-pos":[{via:[x]}],"gradient-to-pos":[{to:[x]}],"gradient-from":[{from:[S]}],"gradient-via":[{via:[S]}],"gradient-to":[{to:[S]}],rounded:[{rounded:[a]}],"rounded-s":[{"rounded-s":[a]}],"rounded-e":[{"rounded-e":[a]}],"rounded-t":[{"rounded-t":[a]}],"rounded-r":[{"rounded-r":[a]}],"rounded-b":[{"rounded-b":[a]}],"rounded-l":[{"rounded-l":[a]}],"rounded-ss":[{"rounded-ss":[a]}],"rounded-se":[{"rounded-se":[a]}],"rounded-ee":[{"rounded-ee":[a]}],"rounded-es":[{"rounded-es":[a]}],"rounded-tl":[{"rounded-tl":[a]}],"rounded-tr":[{"rounded-tr":[a]}],"rounded-br":[{"rounded-br":[a]}],"rounded-bl":[{"rounded-bl":[a]}],"border-w":[{border:[d]}],"border-w-x":[{"border-x":[d]}],"border-w-y":[{"border-y":[d]}],"border-w-s":[{"border-s":[d]}],"border-w-e":[{"border-e":[d]}],"border-w-t":[{"border-t":[d]}],"border-w-r":[{"border-r":[d]}],"border-w-b":[{"border-b":[d]}],"border-w-l":[{"border-l":[d]}],"border-opacity":[{"border-opacity":[b]}],"border-style":[{border:[...K(),"hidden"]}],"divide-x":[{"divide-x":[d]}],"divide-x-reverse":["divide-x-reverse"],"divide-y":[{"divide-y":[d]}],"divide-y-reverse":["divide-y-reverse"],"divide-opacity":[{"divide-opacity":[b]}],"divide-style":[{divide:K()}],"border-color":[{border:[o]}],"border-color-x":[{"border-x":[o]}],"border-color-y":[{"border-y":[o]}],"border-color-s":[{"border-s":[o]}],"border-color-e":[{"border-e":[o]}],"border-color-t":[{"border-t":[o]}],"border-color-r":[{"border-r":[o]}],"border-color-b":[{"border-b":[o]}],"border-color-l":[{"border-l":[o]}],"divide-color":[{divide:[o]}],"outline-style":[{outline:["",...K()]}],"outline-offset":[{"outline-offset":[B,g]}],"outline-w":[{outline:[B,U]}],"outline-color":[{outline:[e]}],"ring-w":[{ring:h()}],"ring-w-inset":["ring-inset"],"ring-color":[{ring:[e]}],"ring-opacity":[{"ring-opacity":[b]}],"ring-offset-w":[{"ring-offset":[B,U]}],"ring-offset-color":[{"ring-offset":[e]}],shadow:[{shadow:["","inner","none",W,St]}],"shadow-color":[{shadow:[te]}],opacity:[{opacity:[b]}],"mix-blend":[{"mix-blend":[...ve(),"plus-lighter","plus-darker"]}],"bg-blend":[{"bg-blend":ve()}],filter:[{filter:["","none"]}],blur:[{blur:[s]}],brightness:[{brightness:[n]}],contrast:[{contrast:[c]}],"drop-shadow":[{"drop-shadow":["","none",W,g]}],grayscale:[{grayscale:[l]}],"hue-rotate":[{"hue-rotate":[f]}],invert:[{invert:[w]}],saturate:[{saturate:[u]}],sepia:[{sepia:[D]}],"backdrop-filter":[{"backdrop-filter":["","none"]}],"backdrop-blur":[{"backdrop-blur":[s]}],"backdrop-brightness":[{"backdrop-brightness":[n]}],"backdrop-contrast":[{"backdrop-contrast":[c]}],"backdrop-grayscale":[{"backdrop-grayscale":[l]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[f]}],"backdrop-invert":[{"backdrop-invert":[w]}],"backdrop-opacity":[{"backdrop-opacity":[b]}],"backdrop-saturate":[{"backdrop-saturate":[u]}],"backdrop-sepia":[{"backdrop-sepia":[D]}],"border-collapse":[{border:["collapse","separate"]}],"border-spacing":[{"border-spacing":[i]}],"border-spacing-x":[{"border-spacing-x":[i]}],"border-spacing-y":[{"border-spacing-y":[i]}],"table-layout":[{table:["auto","fixed"]}],caption:[{caption:["top","bottom"]}],transition:[{transition:["none","all","","colors","opacity","shadow","transform",g]}],duration:[{duration:G()}],ease:[{ease:["linear","in","out","in-out",g]}],delay:[{delay:G()}],animate:[{animate:["none","spin","ping","pulse","bounce",g]}],transform:[{transform:["","gpu","none"]}],scale:[{scale:[A]}],"scale-x":[{"scale-x":[A]}],"scale-y":[{"scale-y":[A]}],rotate:[{rotate:[ee,g]}],"translate-x":[{"translate-x":[F]}],"translate-y":[{"translate-y":[F]}],"skew-x":[{"skew-x":[$]}],"skew-y":[{"skew-y":[$]}],"transform-origin":[{origin:["center","top","top-right","right","bottom-right","bottom","bottom-left","left","top-left",g]}],accent:[{accent:["auto",e]}],appearance:[{appearance:["none","auto"]}],cursor:[{cursor:["auto","default","pointer","wait","text","move","help","not-allowed","none","context-menu","progress","cell","crosshair","vertical-text","alias","copy","no-drop","grab","grabbing","all-scroll","col-resize","row-resize","n-resize","e-resize","s-resize","w-resize","ne-resize","nw-resize","se-resize","sw-resize","ew-resize","ns-resize","nesw-resize","nwse-resize","zoom-in","zoom-out",g]}],"caret-color":[{caret:[e]}],"pointer-events":[{"pointer-events":["none","auto"]}],resize:[{resize:["none","y","x",""]}],"scroll-behavior":[{scroll:["auto","smooth"]}],"scroll-m":[{"scroll-m":j()}],"scroll-mx":[{"scroll-mx":j()}],"scroll-my":[{"scroll-my":j()}],"scroll-ms":[{"scroll-ms":j()}],"scroll-me":[{"scroll-me":j()}],"scroll-mt":[{"scroll-mt":j()}],"scroll-mr":[{"scroll-mr":j()}],"scroll-mb":[{"scroll-mb":j()}],"scroll-ml":[{"scroll-ml":j()}],"scroll-p":[{"scroll-p":j()}],"scroll-px":[{"scroll-px":j()}],"scroll-py":[{"scroll-py":j()}],"scroll-ps":[{"scroll-ps":j()}],"scroll-pe":[{"scroll-pe":j()}],"scroll-pt":[{"scroll-pt":j()}],"scroll-pr":[{"scroll-pr":j()}],"scroll-pb":[{"scroll-pb":j()}],"scroll-pl":[{"scroll-pl":j()}],"snap-align":[{snap:["start","end","center","align-none"]}],"snap-stop":[{snap:["normal","always"]}],"snap-type":[{snap:["none","x","y","both"]}],"snap-strictness":[{snap:["mandatory","proximity"]}],touch:[{touch:["auto","none","manipulation"]}],"touch-x":[{"touch-pan":["x","left","right"]}],"touch-y":[{"touch-pan":["y","up","down"]}],"touch-pz":["touch-pinch-zoom"],select:[{select:["none","text","all","auto"]}],"will-change":[{"will-change":["auto","scroll","contents","transform",g]}],fill:[{fill:[e,"none"]}],"stroke-w":[{stroke:[B,U,oe]}],stroke:[{stroke:[e,"none"]}],sr:["sr-only","not-sr-only"],"forced-color-adjust":[{"forced-color-adjust":["auto","none"]}]},conflictingClassGroups:{overflow:["overflow-x","overflow-y"],overscroll:["overscroll-x","overscroll-y"],inset:["inset-x","inset-y","start","end","top","right","bottom","left"],"inset-x":["right","left"],"inset-y":["top","bottom"],flex:["basis","grow","shrink"],gap:["gap-x","gap-y"],p:["px","py","ps","pe","pt","pr","pb","pl"],px:["pr","pl"],py:["pt","pb"],m:["mx","my","ms","me","mt","mr","mb","ml"],mx:["mr","ml"],my:["mt","mb"],size:["w","h"],"font-size":["leading"],"fvn-normal":["fvn-ordinal","fvn-slashed-zero","fvn-figure","fvn-spacing","fvn-fraction"],"fvn-ordinal":["fvn-normal"],"fvn-slashed-zero":["fvn-normal"],"fvn-figure":["fvn-normal"],"fvn-spacing":["fvn-normal"],"fvn-fraction":["fvn-normal"],"line-clamp":["display","overflow"],rounded:["rounded-s","rounded-e","rounded-t","rounded-r","rounded-b","rounded-l","rounded-ss","rounded-se","rounded-ee","rounded-es","rounded-tl","rounded-tr","rounded-br","rounded-bl"],"rounded-s":["rounded-ss","rounded-es"],"rounded-e":["rounded-se","rounded-ee"],"rounded-t":["rounded-tl","rounded-tr"],"rounded-r":["rounded-tr","rounded-br"],"rounded-b":["rounded-br","rounded-bl"],"rounded-l":["rounded-tl","rounded-bl"],"border-spacing":["border-spacing-x","border-spacing-y"],"border-w":["border-w-s","border-w-e","border-w-t","border-w-r","border-w-b","border-w-l"],"border-w-x":["border-w-r","border-w-l"],"border-w-y":["border-w-t","border-w-b"],"border-color":["border-color-s","border-color-e","border-color-t","border-color-r","border-color-b","border-color-l"],"border-color-x":["border-color-r","border-color-l"],"border-color-y":["border-color-t","border-color-b"],"scroll-m":["scroll-mx","scroll-my","scroll-ms","scroll-me","scroll-mt","scroll-mr","scroll-mb","scroll-ml"],"scroll-mx":["scroll-mr","scroll-ml"],"scroll-my":["scroll-mt","scroll-mb"],"scroll-p":["scroll-px","scroll-py","scroll-ps","scroll-pe","scroll-pt","scroll-pr","scroll-pb","scroll-pl"],"scroll-px":["scroll-pr","scroll-pl"],"scroll-py":["scroll-pt","scroll-pb"],touch:["touch-x","touch-y","touch-pz"],"touch-x":["touch"],"touch-y":["touch"],"touch-pz":["touch"]},conflictingClassGroupModifiers:{"font-size":["leading"]}}},At=mt(zt);function N(...e){return At(ze(e))}const Rt=Ae("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover-elevate active-elevate-2",{variants:{variant:{default:"bg-primary text-primary-foreground border border-primary-border",destructive:"bg-destructive text-destructive-foreground border border-destructive-border",outline:" border [border-color:var(--button-outline)] shadow-xs active:shadow-none ",secondary:"border bg-secondary text-secondary-foreground border border-secondary-border ",ghost:"border border-transparent"},size:{default:"min-h-9 px-4 py-2",sm:"min-h-8 rounded-md px-3 text-xs",lg:"min-h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),q=T.forwardRef(({className:e,variant:r,size:s,asChild:n=!1,...o},a)=>{const i=n?Ke.Slot:"button";return t.jsx(i,{className:N(Rt({variant:r,size:s,className:e})),ref:a,...o})});q.displayName="Button";const L=T.forwardRef(({className:e,type:r,...s},n)=>t.jsx("input",{type:r,className:N("flex h-9 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:n,...s}));L.displayName="Input";const qt=se.Provider,Lt=se.Root,Et=se.Trigger,Oe=T.forwardRef(({className:e,sideOffset:r=4,...s},n)=>t.jsx(se.Content,{ref:n,sideOffset:r,className:N("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",e),...s}));Oe.displayName=se.Content.displayName;const Mt=V.Root,Ot=V.Portal,Fe=T.forwardRef(({className:e,...r},s)=>t.jsx(V.Overlay,{ref:s,className:N("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...r}));Fe.displayName=V.Overlay.displayName;const De=T.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(Ot,{children:[t.jsx(Fe,{}),t.jsxs(V.Content,{ref:n,className:N("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...s,children:[r,t.jsxs(V.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[t.jsx(v.X,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));De.displayName=V.Content.displayName;const Ve=({className:e,...r})=>t.jsx("div",{className:N("flex flex-col space-y-1.5 text-center sm:text-left",e),...r});Ve.displayName="DialogHeader";const _e=({className:e,...r})=>t.jsx("div",{className:N("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...r});_e.displayName="DialogFooter";const Ge=T.forwardRef(({className:e,...r},s)=>t.jsx(V.Title,{ref:s,className:N("text-lg font-semibold leading-none tracking-tight",e),...r}));Ge.displayName=V.Title.displayName;const Ft=T.forwardRef(({className:e,...r},s)=>t.jsx(V.Description,{ref:s,className:N("text-sm text-muted-foreground",e),...r}));Ft.displayName=V.Description.displayName;const Dt=Ae("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),P=T.forwardRef(({className:e,...r},s)=>t.jsx(Ie.Root,{ref:s,className:N(Dt(),e),...r}));P.displayName=Ie.Root.displayName;const Se=z.Root,Te=z.Value,le=T.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(z.Trigger,{ref:n,className:N("flex h-9 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",e),...s,children:[r,t.jsx(z.Icon,{asChild:!0,children:t.jsx(v.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));le.displayName=z.Trigger.displayName;const Be=T.forwardRef(({className:e,...r},s)=>t.jsx(z.ScrollUpButton,{ref:s,className:N("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(v.ChevronUp,{className:"h-4 w-4"})}));Be.displayName=z.ScrollUpButton.displayName;const $e=T.forwardRef(({className:e,...r},s)=>t.jsx(z.ScrollDownButton,{ref:s,className:N("flex cursor-default items-center justify-center py-1",e),...r,children:t.jsx(v.ChevronDown,{className:"h-4 w-4"})}));$e.displayName=z.ScrollDownButton.displayName;const de=T.forwardRef(({className:e,children:r,position:s="popper",...n},o)=>t.jsx(z.Portal,{children:t.jsxs(z.Content,{ref:o,className:N("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:s,...n,children:[t.jsx(Be,{}),t.jsx(z.Viewport,{className:N("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:r}),t.jsx($e,{})]})}));de.displayName=z.Content.displayName;const Vt=T.forwardRef(({className:e,...r},s)=>t.jsx(z.Label,{ref:s,className:N("py-1.5 pl-8 pr-2 text-sm font-semibold",e),...r}));Vt.displayName=z.Label.displayName;const R=T.forwardRef(({className:e,children:r,...s},n)=>t.jsxs(z.Item,{ref:n,className:N("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...s,children:[t.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:t.jsx(z.ItemIndicator,{children:t.jsx(v.Check,{className:"h-4 w-4"})})}),t.jsx(z.ItemText,{children:r})]}));R.displayName=z.Item.displayName;const _t=T.forwardRef(({className:e,...r},s)=>t.jsx(z.Separator,{ref:s,className:N("-mx-1 my-1 h-px bg-muted",e),...r}));_t.displayName=z.Separator.displayName;const ce=T.forwardRef(({className:e,...r},s)=>t.jsx(ae.Root,{ref:s,className:N("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...r,children:t.jsx(ae.Indicator,{className:N("flex items-center justify-center text-current"),children:t.jsx(v.Check,{className:"h-4 w-4"})})}));ce.displayName=ae.Root.displayName;const xe=T.forwardRef(({className:e,...r},s)=>t.jsx("textarea",{className:N("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),ref:s,...r}));xe.displayName="Textarea";const Gt=e=>e.trim().toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g,"_"),Bt=(e,r,s=!1)=>{const n=(c,l)=>{r({...e,[c]:l})};return{handleTitleChange:c=>{n("title",c)},handleTitleBlur:()=>{if(s&&e.title){const c=Gt(e.title);n("key",c)}},handleKeyChange:c=>{s&&n("key",c)},handleFieldChange:n,handleConstraintChange:(c,l)=>{r({...e,[c]:l})}}},ue={string:"String",number:"Number",integer:"Integer",boolean:"Boolean",object:"Object",array:"Array",null:"Null",file:"File"},Je=k.createContext({getTypeLabel:e=>ue[e],typeLabels:ue});function $t({children:e,customLabels:r={}}){const s={...ue,...r},n=o=>s[o]||o;return t.jsx(Je.Provider,{value:{getTypeLabel:n,typeLabels:s},children:e})}function Ue(){return k.useContext(Je)}function me({property:e,open:r,onOpenChange:s,onUpdate:n,isArrayItem:o=!1,isNewProperty:a=!1,propertyLabel:i={singular:"Property",plural:"Properties"},showRegex:d=!1}){var I;const{typeLabels:c}=Ue(),[l,f]=k.useState(e);k.useEffect(()=>{r&&f(e)},[e,r]);const{handleTitleChange:w,handleTitleBlur:y,handleKeyChange:S,handleFieldChange:x,handleConstraintChange:m}=Bt(l,f,a),p=()=>{var u;(u=l.title)!=null&&u.trim()&&(n(l),s(!1))},b=()=>{f(e),s(!1)};return t.jsx(Mt,{open:r,onOpenChange:s,children:t.jsxs(De,{className:"max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0","data-testid":"dialog-edit-property",children:[t.jsx(Ve,{className:"px-6 pt-6 pb-4 shrink-0",children:t.jsx(Ge,{children:a?`Add ${i.singular}`:`Edit ${i.singular}`})}),t.jsxs("div",{className:"space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsxs(P,{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Type"]}),t.jsxs(Se,{value:l.type,onValueChange:u=>x("type",u),"data-testid":"select-type-dialog",children:[t.jsx(le,{children:t.jsx(Te,{})}),t.jsxs(de,{children:[t.jsx(R,{value:"string",children:c.string}),t.jsx(R,{value:"number",children:c.number}),t.jsx(R,{value:"integer",children:c.integer}),t.jsx(R,{value:"boolean",children:c.boolean}),t.jsx(R,{value:"object",children:c.object}),t.jsx(R,{value:"array",children:c.array}),t.jsx(R,{value:"file",children:c.file}),t.jsx(R,{value:"null",children:c.null})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsxs(P,{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Title"]}),t.jsx(L,{value:l.title||"",onChange:u=>w(u.target.value),onBlur:y,placeholder:"Property Title","data-testid":"input-title-dialog",required:!0}),!a&&l.key&&t.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Key: ",l.key]})]}),a&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{children:"Key"}),t.jsx(L,{value:l.key,onChange:u=>S(u.target.value),placeholder:"property_key","data-testid":"input-key-dialog"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{children:"Description"}),t.jsx(xe,{placeholder:"Optional description",value:l.description||"",onChange:u=>x("description",u.target.value),rows:2,"data-testid":"input-edit-description"})]}),l.type==="array"&&t.jsxs("div",{className:"space-y-2 border-l-2 border-border pl-4 mt-2",children:[t.jsxs(P,{className:"font-semibold text-xs text-muted-foreground",children:[c.array," Items"]}),l.items?t.jsxs("div",{className:"bg-muted/40 p-2 rounded",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{children:"Item Type"}),t.jsxs(Se,{value:l.items.type,onValueChange:u=>f({...l,items:{...l.items,type:u}}),children:[t.jsx(le,{children:t.jsx(Te,{})}),t.jsxs(de,{children:[t.jsx(R,{value:"string",children:c.string}),t.jsx(R,{value:"number",children:c.number}),t.jsx(R,{value:"integer",children:c.integer}),t.jsx(R,{value:"boolean",children:c.boolean}),t.jsx(R,{value:"object",children:c.object}),t.jsx(R,{value:"array",children:c.array}),t.jsx(R,{value:"file",children:c.file}),t.jsx(R,{value:"null",children:c.null})]})]})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{children:"Item Title"}),t.jsx(L,{value:l.items.title||"",onChange:u=>f({...l,items:{...l.items,title:u.target.value}}),placeholder:"Item Title"})]}),t.jsxs(q,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>f({...l,items:void 0}),children:["Remove ",c.array," Item Schema"]})]}):t.jsxs(q,{variant:"outline",size:"sm",onClick:()=>{f({...l,items:{id:Date.now().toString()+Math.random(),key:"item",type:"string",required:!1}})},children:["Add ",c.array," Item Schema"]})]}),!o&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ce,{id:"prop-required",checked:l.required,onCheckedChange:u=>x("required",u),"data-testid":"checkbox-edit-required"}),t.jsx(P,{htmlFor:"prop-required",className:"cursor-pointer",children:"Required field"})]}),l.type==="string"&&t.jsxs("details",{className:"border rounded-md",children:[t.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:t.jsxs("h4",{className:"text-sm font-medium inline",children:[c.string," Constraints"]})}),t.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"min-length",children:"Minimum Length"}),t.jsx(L,{id:"min-length",type:"number",placeholder:"0",value:l.minLength||"",onChange:u=>m("minLength",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-minlength"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"max-length",children:"Maximum Length"}),t.jsx(L,{id:"max-length",type:"number",placeholder:"∞",value:l.maxLength||"",onChange:u=>m("maxLength",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-maxlength"})]})]}),d&&t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"pattern",children:"Pattern (regex)"}),t.jsx(L,{id:"pattern",placeholder:"^[a-z]+$",value:l.pattern||"",onChange:u=>m("pattern",u.target.value),className:"font-mono text-sm","data-testid":"input-edit-pattern"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{children:"Enum Values"}),t.jsx("div",{className:"space-y-2",children:[...l.enum||[],""].map((u,A)=>{var D;return t.jsx(L,{placeholder:A===(((D=l.enum)==null?void 0:D.length)||0)?"Add new value...":"Enum value",value:u,onChange:$=>{const O=$.target.value,F=l.enum||[];if(A===F.length)O.trim()&&m("enum",[...F,O.trim()]);else if(O.trim()){const M=[...F];M[A]=O.trim(),m("enum",M)}else{const M=F.filter((J,_)=>_!==A);m("enum",M.length>0?M:void 0)}},"data-testid":`input-edit-enum-${A}`},A)})}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter allowed values (empty fields will be removed)"})]})]})]}),(l.type==="number"||l.type==="integer")&&t.jsxs("details",{className:"border rounded-md",children:[t.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:t.jsx("h4",{className:"text-sm font-medium inline",children:"Numeric Constraints"})}),t.jsx("div",{className:"space-y-4 p-4 pt-0",children:t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"minimum",children:"Minimum Value"}),t.jsx(L,{id:"minimum",type:"number",placeholder:"-∞",value:l.minimum??"",onChange:u=>m("minimum",u.target.value?parseFloat(u.target.value):void 0),"data-testid":"input-edit-minimum"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"maximum",children:"Maximum Value"}),t.jsx(L,{id:"maximum",type:"number",placeholder:"∞",value:l.maximum??"",onChange:u=>m("maximum",u.target.value?parseFloat(u.target.value):void 0),"data-testid":"input-edit-maximum"})]})]})})]}),l.type==="array"&&t.jsxs("details",{className:"border rounded-md",children:[t.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:t.jsxs("h4",{className:"text-sm font-medium inline",children:[c.array," Constraints"]})}),t.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[t.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"min-items",children:"Minimum Items"}),t.jsx(L,{id:"min-items",type:"number",placeholder:"0",value:l.minItems||"",onChange:u=>m("minItems",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-minitems"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"max-items",children:"Maximum Items"}),t.jsx(L,{id:"max-items",type:"number",placeholder:"∞",value:l.maxItems||"",onChange:u=>m("maxItems",u.target.value?parseInt(u.target.value):void 0),"data-testid":"input-edit-maxitems"})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(ce,{id:"unique-items",checked:l.uniqueItems||!1,onCheckedChange:u=>m("uniqueItems",u),"data-testid":"checkbox-edit-unique"}),t.jsx(P,{htmlFor:"unique-items",className:"cursor-pointer",children:"All items must be unique"})]})]})]})]}),t.jsxs(_e,{className:"px-6 py-4 border-t bg-background shrink-0",children:[t.jsx(q,{variant:"outline",onClick:b,"data-testid":"button-cancel",children:"Cancel"}),t.jsx(q,{onClick:p,"data-testid":"button-save",disabled:!((I=l.title)!=null&&I.trim()),children:"Save Changes"})]})]})})}const be=()=>`${Date.now()}-${Math.random()}`;function pe({property:e,onUpdate:r,onDelete:s,level:n=1,isArrayItem:o=!1,showRegex:a=!1}){const{getTypeLabel:i}=Ue(),[d,c]=k.useState(!1),[l,f]=k.useState(null),[w,y]=k.useState(!1),[S,x]=k.useState(!1),[m,p]=k.useState(e.title||"");k.useEffect(()=>{S||p(e.title||"")},[e.title,S]);const b=`h${Math.min(n,6)}`,I=e.type==="object",u=I&&e.children&&e.children.length>0,A={1:"text-lg font-semibold",2:"text-base",3:"text-base",4:"text-base",5:"text-sm",6:"text-sm"}[n]||"text-sm",D=(h,E)=>{const H=e.children.map(K=>K.id===h?E:K);r({...e,children:H})},$=h=>{const E=e.children.filter(H=>H.id!==h);r({...e,children:E})},O=()=>{const h={id:be(),key:"",type:"string",required:!1};f(h),y(!0)},F=h=>{r({...e,children:[...e.children||[],h]}),y(!1),f(null)},M=()=>{y(!1),f(null)},J=()=>{const h=e.title||e.key||"";p(h),x(!0)},_=()=>{const h=m.trim();if(!h){p(e.title||""),x(!1);return}h!==e.title&&r({...e,title:h}),x(!1)},j=h=>{h.key==="Enter"?_():h.key==="Escape"&&(p(e.title||""),x(!1))};return t.jsxs("div",{className:"group",children:[t.jsxs("div",{className:"flex gap-4 items-center rounded-md -mx-2 px-2 py-1 transition-colors hover:bg-accent/50",children:[t.jsx("div",{className:"flex-1 min-w-0",children:t.jsxs("div",{className:"flex items-start gap-3",children:[!o&&t.jsx("button",{onClick:()=>r({...e,required:!e.required}),className:"shrink-0 transition-all hover:scale-110 mt-0.5",title:e.required?"Required field - click to make optional":"Optional field - click to make required",children:e.required?t.jsx("span",{className:"block w-4 h-4 rounded-full bg-primary"}):t.jsx("span",{className:"block w-4 h-4 rounded-full border border-dashed border-gray-400"})}),S?t.jsx(L,{value:m,onChange:h=>p(h.target.value),onBlur:_,onKeyDown:j,autoFocus:!0,className:A,placeholder:"Enter title"}):t.jsxs("div",{className:"flex gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx(b,{className:`${A} cursor-pointer hover:text-primary transition-colors leading-none`,onClick:J,children:e.title||e.key||t.jsx("span",{className:"text-muted-foreground italic",children:"unnamed"})}),t.jsx(qt,{children:t.jsxs(Lt,{children:[t.jsx(Et,{asChild:!0,children:t.jsxs("span",{children:[e.type==="string"&&t.jsx(v.Type,{className:"w-5 h-5 text-muted-foreground"}),e.type==="number"&&t.jsx(v.Hash,{className:"w-5 h-5 text-muted-foreground"}),e.type==="integer"&&t.jsx(v.Hash,{className:"w-5 h-5 text-muted-foreground"}),e.type==="boolean"&&t.jsx(v.CheckSquare,{className:"w-5 h-5 text-muted-foreground"}),e.type==="object"&&t.jsx(v.Braces,{className:"w-5 h-5 text-muted-foreground"}),e.type==="array"&&t.jsx(v.List,{className:"w-5 h-5 text-muted-foreground"}),e.type==="file"&&t.jsx(v.FileText,{className:"w-5 h-5 text-muted-foreground"})]})}),t.jsxs(Oe,{side:"top",children:[i(e.type),e.type==="array"&&e.items?` of ${i(e.items.type)}`:""]})]})}),e.type==="object"&&t.jsx(q,{variant:"ghost",size:"icon",className:"opacity-0 group-hover:opacity-100 h-6 w-6",onClick:O,"data-testid":`button-add-child-${e.id}`,children:t.jsx(v.Plus,{className:"!w-5 !h-5"})})]}),e.description&&t.jsx("p",{className:"text-sm text-muted-foreground flex-1 min-w-[200px]","data-testid":`text-description-${e.id}`,children:e.description})]})]})}),t.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[t.jsx(q,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>c(!0),"data-testid":`button-edit-${e.id}`,children:t.jsx(v.Pencil,{className:"w-3 h-3"})}),I&&e.type!=="object"&&t.jsx(q,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:O,"data-testid":`button-add-child-${e.id}`,children:t.jsx(v.Plus,{className:"w-3 h-3"})}),t.jsx(q,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:s,"data-testid":`button-delete-${e.id}`,children:t.jsx(v.Trash2,{className:"w-3 h-3"})})]})]}),u&&t.jsx("div",{className:n===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:e.children.map(h=>t.jsx(pe,{property:h,onUpdate:E=>D(h.id,E),onDelete:()=>$(h.id),level:n+1,showRegex:a},h.id))}),e.type==="array"&&e.items&&t.jsxs("div",{className:n===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:[t.jsxs("div",{className:"mb-2 text-xs text-muted-foreground font-semibold uppercase",children:[i("array")," Items"]}),t.jsx(pe,{property:e.items,onUpdate:h=>r({...e,items:h}),onDelete:()=>r({...e,items:void 0}),level:n+1,isArrayItem:!0,showRegex:a})]}),t.jsx(me,{property:e,open:d,onOpenChange:c,onUpdate:r,isArrayItem:o,isNewProperty:!1,showRegex:a}),w&&l&&t.jsx(me,{property:l,open:w,isNewProperty:!0,onOpenChange:h=>{h||M()},onUpdate:F,showRegex:a})]})}const ye=T.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("shadcn-card rounded-xl border bg-card border-card-border text-card-foreground shadow-sm",e),...r}));ye.displayName="Card";const Jt=T.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("flex flex-col space-y-1.5 p-6",e),...r}));Jt.displayName="CardHeader";const Ut=T.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("text-2xl font-semibold leading-none tracking-tight",e),...r}));Ut.displayName="CardTitle";const Wt=T.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("text-sm text-muted-foreground",e),...r}));Wt.displayName="CardDescription";const Kt=T.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("p-6 pt-0",e),...r}));Kt.displayName="CardContent";const Ht=T.forwardRef(({className:e,...r},s)=>t.jsx("div",{ref:s,className:N("flex items-center p-6 pt-0",e),...r}));Ht.displayName="CardFooter";const Xt=()=>new Promise((e,r)=>{const s=document.createElement("input");s.type="file",s.accept=".json",s.onchange=n=>{var i;const o=(i=n.target.files)==null?void 0:i[0];if(!o){r(new Error("No file selected"));return}const a=new FileReader;a.onload=d=>{var c;try{const l=JSON.parse((c=d.target)==null?void 0:c.result);e(l)}catch{r(new Error("Invalid JSON file"))}},a.onerror=()=>r(new Error("Failed to read file")),a.readAsText(o)},s.click()}),We=(e,r="schema.json")=>{const s=JSON.stringify(e,null,2),n=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(n),a=document.createElement("a");a.href=o,a.download=r,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(o)};function Zt({schema:e}){const[r,s]=k.useState(!1),n=JSON.stringify(e,null,2),o=async()=>{await navigator.clipboard.writeText(n),s(!0),setTimeout(()=>s(!1),2e3)},a=()=>{We(e,"schema.json")};return t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[t.jsx("h2",{className:"text-sm font-medium",children:"JSON Schema Output"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(q,{variant:"outline",size:"sm",onClick:o,"data-testid":"button-copy",children:r?t.jsx(v.CheckCircle2,{className:"w-4 h-4"}):t.jsx(v.Copy,{className:"w-4 h-4"})}),t.jsx(q,{variant:"outline",size:"sm",onClick:a,"data-testid":"button-download",children:t.jsx(v.Download,{className:"w-4 h-4"})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:t.jsx(ye,{className:"m-4 bg-muted/30",children:t.jsx("pre",{className:"p-6 text-xs font-mono overflow-auto","data-testid":"text-json-output",children:t.jsx("code",{children:n})})})})]})}function Qt({title:e,description:r,version:s,onUpdate:n}){const[o,a]=k.useState(!1);return t.jsxs(ye,{className:"p-4",children:[t.jsxs(q,{variant:"ghost",onClick:()=>a(!o),className:"w-full justify-between px-2 h-auto hover:bg-transparent","data-testid":"button-toggle-metadata",children:[t.jsx("h3",{className:"text-sm font-medium",children:"Schema Metadata"}),o?t.jsx(v.ChevronDown,{className:"w-4 h-4"}):t.jsx(v.ChevronRight,{className:"w-4 h-4"})]}),o&&t.jsxs("div",{className:"mt-4 space-y-4",children:[t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"schema-title",className:"text-xs text-muted-foreground",children:"Title"}),t.jsx(L,{id:"schema-title",placeholder:"My Schema",value:e,onChange:i=>n("title",i.target.value),"data-testid":"input-title"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"schema-description",className:"text-xs text-muted-foreground",children:"Description"}),t.jsx(xe,{id:"schema-description",placeholder:"Describe your schema...",value:r,onChange:i=>n("description",i.target.value),className:"resize-none",rows:3,"data-testid":"input-schema-description"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(P,{htmlFor:"schema-version",className:"text-xs text-muted-foreground",children:"Version"}),t.jsx(L,{id:"schema-version",placeholder:"1.0.0",value:s,onChange:i=>n("version",i.target.value),"data-testid":"input-version"})]})]})]})}const re=(e,r,s=!0)=>{const n={type:"object"};s&&r&&(r.title&&(n.title=r.title),r.description&&(n.description=r.description));const o=he(e);Object.keys(o).length>0&&(n.properties=o);const a=e.filter(i=>i.required&&i.key).map(i=>i.key);return a.length>0&&(n.required=a),n},he=e=>{const r={};return e.forEach(s=>{if(!s.key)return;const o={type:s.type==="file"?"string":s.type};if(s.title&&(o.title=s.title),s.description&&(o.description=s.description),s.type==="file"&&(o.format="filename"),s.type==="string"&&(s.minLength!==void 0&&(o.minLength=s.minLength),s.maxLength!==void 0&&(o.maxLength=s.maxLength),s.pattern&&(o.pattern=s.pattern),s.enum&&s.enum.length>0&&(o.enum=s.enum)),(s.type==="number"||s.type==="integer")&&(s.minimum!==void 0&&(o.minimum=s.minimum),s.maximum!==void 0&&(o.maximum=s.maximum)),s.type==="array"&&(s.minItems!==void 0&&(o.minItems=s.minItems),s.maxItems!==void 0&&(o.maxItems=s.maxItems),s.uniqueItems&&(o.uniqueItems=s.uniqueItems),s.items&&(o.items=he([s.items])[s.items.key]||{type:s.items.type})),s.type==="object"&&s.children&&s.children.length>0){o.properties=he(s.children);const a=s.children.filter(i=>i.required&&i.key).map(i=>i.key);a.length>0&&(o.required=a)}r[s.key]=o}),r},Yt=e=>{const r={properties:[]};return(e.title||e.description)&&(r.metadata={title:typeof e.title=="string"?e.title:"",description:typeof e.description=="string"?e.description:"",version:"1.0.0"}),e.properties&&typeof e.properties=="object"&&(r.properties=fe(e.properties,Array.isArray(e.required)?e.required:[])),r},fe=(e,r=[])=>e?Object.entries(e).filter(([,s])=>typeof s=="object").map(([s,n])=>{const o=n;let a=typeof o.type=="string"?o.type:"string";a==="string"&&o.format==="filename"&&(a="file");const i={id:be(),key:s,title:typeof o.title=="string"?o.title:void 0,type:a,description:typeof o.description=="string"?o.description:void 0,required:r.includes(s)};return o.minLength!==void 0&&(i.minLength=o.minLength),o.maxLength!==void 0&&(i.maxLength=o.maxLength),o.pattern&&(i.pattern=o.pattern),o.enum&&Array.isArray(o.enum)&&(i.enum=o.enum),o.minimum!==void 0&&(i.minimum=o.minimum),o.maximum!==void 0&&(i.maximum=o.maximum),o.minItems!==void 0&&(i.minItems=o.minItems),o.maxItems!==void 0&&(i.maxItems=o.maxItems),o.uniqueItems&&(i.uniqueItems=o.uniqueItems),i.type==="array"&&o.items&&typeof o.items=="object"&&!Array.isArray(o.items)&&(i.items=fe({item:o.items},[]).find(d=>d.key==="item")),o.properties&&typeof o.properties=="object"&&(i.children=fe(o.properties,Array.isArray(o.required)?o.required:[])),i}):[],es=({schema:e,onChange:r,includeMetadata:s=!0})=>{const{properties:n,metadata:o}=k.useMemo(()=>Yt(e),[e]),a=n,i=o||{title:"",description:"",version:""},d=k.useCallback(()=>({id:be(),key:"",type:"string",required:!1}),[]),c=k.useCallback((x,m)=>{const p=a.some(u=>u.id===x);let b;p?b=a.map(u=>u.id===x?m:u):b=[...a,m];const I=re(b,i,s);r(I)},[a,i,s,r]),l=k.useCallback(x=>{const m=a.filter(b=>b.id!==x),p=re(m,i,s);r(p)},[a,i,s,r]),f=k.useCallback(()=>{const m=re([],{title:"",description:""},s);r(m)},[s,r]),w=k.useCallback((x,m)=>{const p={...i,[x]:m},b=re(a,p,s);r(b)},[a,i,s,r]),y=k.useCallback(async()=>{const x=await Xt();r(x)},[r]),S=k.useCallback(()=>{We(e,"schema.json")},[e]);return{properties:a,metadata:i,addProperty:d,updateProperty:c,deleteProperty:l,clearAll:f,updateMetadata:w,importSchema:y,downloadSchema:S}};function ts(){const[e,r]=k.useState("light");k.useEffect(()=>{const o=localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");r(o),document.documentElement.classList.toggle("dark",o==="dark")},[]);const s=()=>{const n=e==="light"?"dark":"light";r(n),localStorage.setItem("theme",n),document.documentElement.classList.toggle("dark",n==="dark")};return t.jsx(q,{variant:"ghost",size:"icon",onClick:s,"data-testid":"button-theme-toggle",children:e==="light"?t.jsx(v.Moon,{className:"w-4 h-4"}):t.jsx(v.Sun,{className:"w-4 h-4"})})}function ss({schema:e,onChange:r,showMetadata:s=!1,showImport:n=!0,showClear:o=!0,showOutput:a=!0,showHeader:i=!0,className:d="",showSummary:c=!1,typeLabels:l,propertyLabel:f={singular:"property",plural:"properties"},showRegex:w=!1}){const[y,S]=k.useState(null),[x,m]=k.useState(!1),{properties:p,metadata:b,addProperty:I,updateProperty:u,deleteProperty:A,clearAll:D,updateMetadata:$,importSchema:O}=es({schema:e,onChange:r,includeMetadata:s}),F=()=>{const h=I();S(h),m(!0)},M=h=>{u(h.id,h),m(!1),S(null)},J=()=>{m(!1),S(null)},_=()=>{D()},j=async()=>{await O()};return t.jsx($t,{customLabels:l,children:t.jsxs("div",{className:`${d} flex flex-col json-schema-builder-react`,children:[i&&t.jsx("header",{className:"h-16 border-b flex items-center justify-between px-6",children:t.jsxs("div",{className:"flex items-center gap-3",children:[n&&t.jsx(q,{variant:"outline",size:"sm",onClick:j,"data-testid":"button-import",children:t.jsx(v.Upload,{className:"w-4 h-4"})}),o&&t.jsx(q,{variant:"outline",size:"sm",onClick:_,disabled:p.length===0,"data-testid":"button-clear",children:t.jsx(v.Trash2,{className:"w-4 h-4"})}),t.jsx(ts,{})]})}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:a?"w-3/5 border-r":"w-full",children:t.jsxs("div",{className:"h-full overflow-auto p-2 space-y-4",children:[s&&t.jsx(Qt,{title:b.title,description:b.description,version:b.version,onUpdate:(h,E)=>$(h,E)}),p.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[t.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:t.jsx(v.Plus,{className:"w-8 h-8 text-muted-foreground"})}),t.jsxs("h2",{className:"text-lg font-medium mb-2",children:["No ",f.plural," yet"]}),t.jsxs("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:["Start building your JSON schema by adding your first"," ",f.singular]}),t.jsxs(q,{onClick:F,"data-testid":"button-add-first",children:[t.jsx(v.Plus,{className:"w-4 h-4 mr-2"}),"Add ",f.singular]})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"space-y-1",children:p.map(h=>t.jsx(pe,{property:h,onUpdate:E=>u(h.id,E),onDelete:()=>A(h.id),showRegex:w},h.id))}),t.jsx("div",{className:"pt-6",children:t.jsxs(q,{onClick:F,className:"w-full",variant:"outline","data-testid":"button-add-property",children:[t.jsx(v.Plus,{className:"w-4 h-4 mr-2"}),"Add ",f.singular]})}),c&&t.jsxs("div",{className:"pt-4 border-t flex items-center justify-between text-sm text-muted-foreground",children:[t.jsxs("span",{children:[p.length," ",p.length===1?f.singular:f.plural]}),t.jsxs("span",{children:[p.filter(h=>h.required).length," required"]})]})]})]})}),a&&t.jsx("div",{className:"w-2/5",children:t.jsx(Zt,{schema:e})})]}),x&&y&&t.jsx(me,{property:y,open:x,isNewProperty:!0,onOpenChange:h=>{h||J()},propertyLabel:f,onUpdate:M,showRegex:w})]})})}exports.JsonSchemaBuilder=ss;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("react"),ge=require("@radix-ui/react-slot"),ae=require("class-variance-authority"),je=require("clsx"),ve=require("tailwind-merge"),u=require("lucide-react"),ye=require("@radix-ui/react-tooltip"),be=require("@radix-ui/react-select"),Ne=require("@radix-ui/react-dialog"),we=require("@radix-ui/react-label"),Ce=require("@radix-ui/react-checkbox");function F(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:()=>t[s]})}}return a.default=t,Object.freeze(a)}const v=F(j),E=F(ye),w=F(be),L=F(Ne),ie=F(we),K=F(Ce);function f(...t){return ve.twMerge(je.clsx(t))}const ke=ae.cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-full px-3 text-xs",lg:"h-10 rounded-full px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),I=v.forwardRef(({className:t,variant:a,size:s,asChild:r=!1,...i},l)=>{const n=r?ge.Slot:"button";return e.jsx(n,{className:f(ke({variant:a,size:s,className:t})),ref:l,...i})});I.displayName="Button";const D=v.forwardRef(({className:t,type:a,...s},r)=>e.jsx("input",{type:a,className:f("flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...s}));D.displayName="Input";const Se=E.Provider,Ie=E.Root,Te=E.Trigger,ne=v.forwardRef(({className:t,sideOffset:a=4,...s},r)=>e.jsx(E.Portal,{children:e.jsx(E.Content,{ref:r,sideOffset:a,className:f("z-50 overflow-hidden rounded-md bg-popover px-3 py-1.5 text-xs text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-tooltip-content-transform-origin]",t),...s})}));ne.displayName=E.Content.displayName;const J=w.Root,V=w.Value,M=v.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(w.Trigger,{ref:r,className:f("flex h-9 w-full items-center justify-between whitespace-nowrap rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",t),...s,children:[a,e.jsx(w.Icon,{asChild:!0,children:e.jsx(u.ChevronDown,{className:"h-4 w-4 opacity-50"})})]}));M.displayName=w.Trigger.displayName;const re=v.forwardRef(({className:t,...a},s)=>e.jsx(w.ScrollUpButton,{ref:s,className:f("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(u.ChevronUp,{className:"h-4 w-4"})}));re.displayName=w.ScrollUpButton.displayName;const le=v.forwardRef(({className:t,...a},s)=>e.jsx(w.ScrollDownButton,{ref:s,className:f("flex cursor-default items-center justify-center py-1",t),...a,children:e.jsx(u.ChevronDown,{className:"h-4 w-4"})}));le.displayName=w.ScrollDownButton.displayName;const _=v.forwardRef(({className:t,children:a,position:s="popper",...r},i)=>e.jsx(w.Portal,{children:e.jsxs(w.Content,{ref:i,className:f("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",s==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:s,...r,children:[e.jsx(re,{}),e.jsx(w.Viewport,{className:f("p-1",s==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:a}),e.jsx(le,{})]})}));_.displayName=w.Content.displayName;const De=v.forwardRef(({className:t,...a},s)=>e.jsx(w.Label,{ref:s,className:f("px-2 py-1.5 text-sm font-semibold",t),...a}));De.displayName=w.Label.displayName;const k=v.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(w.Item,{ref:r,className:f("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-2 pr-8 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...s,children:[e.jsx("span",{className:"absolute right-2 flex h-3.5 w-3.5 items-center justify-center",children:e.jsx(w.ItemIndicator,{children:e.jsx(u.Check,{className:"h-4 w-4"})})}),e.jsx(w.ItemText,{children:a})]}));k.displayName=w.Item.displayName;const qe=v.forwardRef(({className:t,...a},s)=>e.jsx(w.Separator,{ref:s,className:f("-mx-1 my-1 h-px bg-muted",t),...a}));qe.displayName=w.Separator.displayName;const Pe=L.Root,Oe=L.Portal,de=v.forwardRef(({className:t,...a},s)=>e.jsx(L.Overlay,{ref:s,className:f("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...a}));de.displayName=L.Overlay.displayName;const oe=v.forwardRef(({className:t,children:a,...s},r)=>e.jsxs(Oe,{children:[e.jsx(de,{}),e.jsxs(L.Content,{ref:r,className:f("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...s,children:[a,e.jsxs(L.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[e.jsx(u.X,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));oe.displayName=L.Content.displayName;const ce=({className:t,...a})=>e.jsx("div",{className:f("flex flex-col space-y-1.5 text-center sm:text-left",t),...a});ce.displayName="DialogHeader";const me=({className:t,...a})=>e.jsx("div",{className:f("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...a});me.displayName="DialogFooter";const ue=v.forwardRef(({className:t,...a},s)=>e.jsx(L.Title,{ref:s,className:f("text-lg font-semibold leading-none tracking-tight",t),...a}));ue.displayName=L.Title.displayName;const Le=v.forwardRef(({className:t,...a},s)=>e.jsx(L.Description,{ref:s,className:f("text-sm text-muted-foreground",t),...a}));Le.displayName=L.Description.displayName;const Re=ae.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),N=v.forwardRef(({className:t,...a},s)=>e.jsx(ie.Root,{ref:s,className:f(Re(),t),...a}));N.displayName=ie.Root.displayName;const H=v.forwardRef(({className:t,...a},s)=>e.jsx(K.Root,{ref:s,className:f("grid place-content-center peer h-4 w-4 shrink-0 rounded-sm border border-primary shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",t),...a,children:e.jsx(K.Indicator,{className:f("grid place-content-center text-current"),children:e.jsx(u.Check,{className:"h-4 w-4"})})}));H.displayName=K.Root.displayName;const Y=v.forwardRef(({className:t,...a},s)=>e.jsx("textarea",{className:f("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:s,...a}));Y.displayName="Textarea";const Ee=t=>t.trim().toLowerCase().replace(/[^\w\s]/g,"").replace(/\s+/g,"_"),Fe=(t,a,s=!1,r=!1)=>{const i=(o,d)=>{a({...t,[o]:d})};return{handleTitleChange:o=>{i("title",o)},handleTitleBlur:()=>{if(s&&t.title){const o=Ee(t.title);i("key",o)}},handleKeyChange:o=>{(s||r)&&i("key",o)},handleFieldChange:i,handleConstraintChange:(o,d)=>{a({...t,[o]:d})}}},U={string:"String",number:"Number",integer:"Integer",boolean:"Boolean",object:"Object",array:"Array",null:"Null",file:"File"},he=j.createContext({getTypeLabel:t=>U[t],typeLabels:U});function ze({children:t,customLabels:a={}}){const s={...U,...a},r=i=>s[i]||i;return e.jsx(he.Provider,{value:{getTypeLabel:r,typeLabels:s},children:t})}function xe(){return j.useContext(he)}function X({property:t,open:a,onOpenChange:s,onUpdate:r,isArrayItem:i=!1,isNewProperty:l=!1,propertyLabel:n={singular:"Property",plural:"Properties"},showRegex:m=!1,keyEditable:C=!1}){var O;const{typeLabels:o}=xe(),[d,g]=j.useState(t);j.useEffect(()=>{a&&g(t)},[t,a]);const{handleTitleChange:y,handleTitleBlur:p,handleKeyChange:x,handleFieldChange:S,handleConstraintChange:b}=Fe(d,g,l,C),P=()=>{var c;(c=d.title)!=null&&c.trim()&&(r(d),s(!1))},h=()=>{g(t),s(!1)};return e.jsx(Pe,{open:a,onOpenChange:s,children:e.jsxs(oe,{className:"max-w-2xl max-h-[80vh] flex flex-col gap-0 p-0","data-testid":"dialog-edit-property",children:[e.jsx(ce,{className:"px-6 pt-6 pb-4 shrink-0",children:e.jsx(ue,{children:l?`Add ${n.singular}`:`Edit ${n.singular}`})}),e.jsxs("div",{className:"space-y-6 px-6 pb-4 overflow-y-auto flex-1 min-h-0",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Type"]}),e.jsxs(J,{value:d.type,onValueChange:c=>S("type",c),"data-testid":"select-type-dialog",children:[e.jsx(M,{children:e.jsx(V,{})}),e.jsxs(_,{children:[e.jsx(k,{value:"string",children:o.string}),e.jsx(k,{value:"number",children:o.number}),e.jsx(k,{value:"integer",children:o.integer}),e.jsx(k,{value:"boolean",children:o.boolean}),e.jsx(k,{value:"object",children:o.object}),e.jsx(k,{value:"array",children:o.array}),e.jsx(k,{value:"file",children:o.file}),e.jsx(k,{value:"null",children:o.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(N,{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-red-500"}),"Title"]}),e.jsx(D,{value:d.title||"",onChange:c=>y(c.target.value),onBlur:p,placeholder:"Property Title","data-testid":"input-title-dialog",required:!0}),!l&&d.key&&e.jsxs("p",{className:"text-xs text-muted-foreground font-mono",children:["Key: ",d.key]})]}),(l||C)&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Key"}),e.jsx(D,{value:d.key,onChange:c=>x(c.target.value),placeholder:"property_key","data-testid":"input-key-dialog"}),!l&&e.jsx("p",{className:"text-xs text-yellow-600 dark:text-yellow-500",children:"⚠️ Changing the key may break existing references to this property"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Description"}),e.jsx(Y,{placeholder:"Optional description",value:d.description||"",onChange:c=>S("description",c.target.value),rows:2,"data-testid":"input-edit-description"})]}),d.type==="array"&&e.jsxs("div",{className:"space-y-2 border-l-2 border-border pl-4 mt-2",children:[e.jsxs(N,{className:"font-semibold text-xs text-muted-foreground",children:[o.array," Items"]}),d.items?e.jsxs("div",{className:"bg-muted/40 p-2 rounded",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Item Type"}),e.jsxs(J,{value:d.items.type,onValueChange:c=>g({...d,items:{...d.items,type:c}}),children:[e.jsx(M,{children:e.jsx(V,{})}),e.jsxs(_,{children:[e.jsx(k,{value:"string",children:o.string}),e.jsx(k,{value:"number",children:o.number}),e.jsx(k,{value:"integer",children:o.integer}),e.jsx(k,{value:"boolean",children:o.boolean}),e.jsx(k,{value:"object",children:o.object}),e.jsx(k,{value:"array",children:o.array}),e.jsx(k,{value:"file",children:o.file}),e.jsx(k,{value:"null",children:o.null})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Item Title"}),e.jsx(D,{value:d.items.title||"",onChange:c=>g({...d,items:{...d.items,title:c.target.value}}),placeholder:"Item Title"})]}),e.jsxs(I,{variant:"ghost",size:"sm",className:"mt-2",onClick:()=>g({...d,items:void 0}),children:["Remove ",o.array," Item Schema"]})]}):e.jsxs(I,{variant:"outline",size:"sm",onClick:()=>{g({...d,items:{id:Date.now().toString()+Math.random(),key:"item",type:"string",required:!1}})},children:["Add ",o.array," Item Schema"]})]}),!i&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{id:"prop-required",checked:d.required,onCheckedChange:c=>S("required",c),"data-testid":"checkbox-edit-required"}),e.jsx(N,{htmlFor:"prop-required",className:"cursor-pointer",children:"Required field"})]}),d.type==="string"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[o.string," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"min-length",children:"Minimum Length"}),e.jsx(D,{id:"min-length",type:"number",placeholder:"0",value:d.minLength||"",onChange:c=>b("minLength",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-minlength"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"max-length",children:"Maximum Length"}),e.jsx(D,{id:"max-length",type:"number",placeholder:"∞",value:d.maxLength||"",onChange:c=>b("maxLength",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-maxlength"})]})]}),m&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"pattern",children:"Pattern (regex)"}),e.jsx(D,{id:"pattern",placeholder:"^[a-z]+$",value:d.pattern||"",onChange:c=>b("pattern",c.target.value),className:"font-mono text-sm","data-testid":"input-edit-pattern"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{children:"Enum Values"}),e.jsx("div",{className:"space-y-2",children:[...d.enum||[],""].map((c,q)=>{var B;return e.jsx(D,{placeholder:q===(((B=d.enum)==null?void 0:B.length)||0)?"Add new value...":"Enum value",value:c,onChange:$=>{const T=$.target.value,R=d.enum||[];if(q===R.length)T.trim()&&b("enum",[...R,T.trim()]);else if(T.trim()){const z=[...R];z[q]=T.trim(),b("enum",z)}else{const z=R.filter((Ye,pe)=>pe!==q);b("enum",z.length>0?z:void 0)}},"data-testid":`input-edit-enum-${q}`},q)})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enter allowed values (empty fields will be removed)"})]})]})]}),(d.type==="number"||d.type==="integer")&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsx("h4",{className:"text-sm font-medium inline",children:"Numeric Constraints"})}),e.jsx("div",{className:"space-y-4 p-4 pt-0",children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"minimum",children:"Minimum Value"}),e.jsx(D,{id:"minimum",type:"number",placeholder:"-∞",value:d.minimum??"",onChange:c=>b("minimum",c.target.value?parseFloat(c.target.value):void 0),"data-testid":"input-edit-minimum"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"maximum",children:"Maximum Value"}),e.jsx(D,{id:"maximum",type:"number",placeholder:"∞",value:d.maximum??"",onChange:c=>b("maximum",c.target.value?parseFloat(c.target.value):void 0),"data-testid":"input-edit-maximum"})]})]})})]}),d.type==="array"&&e.jsxs("details",{className:"border rounded-md",children:[e.jsx("summary",{className:"p-4 cursor-pointer hover:bg-accent/50 transition-colors",children:e.jsxs("h4",{className:"text-sm font-medium inline",children:[o.array," Constraints"]})}),e.jsxs("div",{className:"space-y-4 p-4 pt-0",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"min-items",children:"Minimum Items"}),e.jsx(D,{id:"min-items",type:"number",placeholder:"0",value:d.minItems||"",onChange:c=>b("minItems",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-minitems"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"max-items",children:"Maximum Items"}),e.jsx(D,{id:"max-items",type:"number",placeholder:"∞",value:d.maxItems||"",onChange:c=>b("maxItems",c.target.value?parseInt(c.target.value):void 0),"data-testid":"input-edit-maxitems"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(H,{id:"unique-items",checked:d.uniqueItems||!1,onCheckedChange:c=>b("uniqueItems",c),"data-testid":"checkbox-edit-unique"}),e.jsx(N,{htmlFor:"unique-items",className:"cursor-pointer",children:"All items must be unique"})]})]})]})]}),e.jsxs(me,{className:"px-6 py-4 border-t bg-background shrink-0",children:[e.jsx(I,{variant:"outline",onClick:h,"data-testid":"button-cancel",children:"Cancel"}),e.jsx(I,{onClick:P,"data-testid":"button-save",disabled:!((O=d.title)!=null&&O.trim()),children:"Save Changes"})]})]})})}function se(t,a,s={}){const{allowEmpty:r=!1,onEditStart:i,onEditCancel:l}=s,[n,m]=j.useState(!1),[C,o]=j.useState(t);j.useEffect(()=>{n||o(t)},[t,n]);const d=()=>{o(t),m(!0),i==null||i()},g=x=>{o(x)},y=()=>{const x=C.trim();if(!r&&!x){o(t),m(!1);return}x!==t&&a(x),m(!1)};return{isEditing:n,value:C,startEdit:d,handleChange:g,handleBlur:y,handleKeyDown:x=>{x.key==="Enter"?y():x.key==="Escape"&&(o(t),m(!1),l==null||l())}}}function Be(t,a){const[s,r]=j.useState(!1);return{isChangingType:s,setIsChangingType:r,handleTypeChange:n=>{const m={...t,type:n};n!=="string"&&(delete m.minLength,delete m.maxLength,delete m.pattern,delete m.enum),n!=="number"&&n!=="integer"&&(delete m.minimum,delete m.maximum),n!=="array"&&(delete m.minItems,delete m.maxItems,delete m.uniqueItems,delete m.items),n!=="object"&&delete m.children,a(m),r(!1)},availableTypes:["string","number","integer","boolean","object","array","file"]}}const Z=()=>`${Date.now()}-${Math.random()}`;function ee(t={}){const{onConfirm:a,onCancel:s,createInitialData:r}=t,[i,l]=j.useState(!1),[n,m]=j.useState(null),C=y=>{const p=y??(r?r():null);m(p),l(!0)},o=()=>{l(!1),m(null),s==null||s()};return{isOpen:i,data:n,open:C,close:o,confirm:y=>{a==null||a(y),l(!1),m(null)},setIsOpen:y=>{y?l(!0):o()}}}function Ae(t,a){const s=ee({createInitialData:()=>({id:Z(),key:"",type:"string",required:!1}),onConfirm:l=>{a({...t,children:[...t.children||[],l]})}});return{addChild:()=>s.open(),updateChild:(l,n)=>{const m=t.children.map(C=>C.id===l?n:C);a({...t,children:m})},deleteChild:l=>{const n=t.children.filter(m=>m.id!==l);a({...t,children:n})},addChildDialog:{isOpen:s.isOpen,data:s.data,setIsOpen:s.setIsOpen,confirm:s.confirm}}}function G({property:t,onUpdate:a,onDelete:s,level:r=1,isArrayItem:i=!1,showRegex:l=!1,keyEditable:n=!1}){const{getTypeLabel:m,typeLabels:C}=xe(),o=ee(),d=se(t.title||t.key||"",h=>a({...t,title:h}),{allowEmpty:!1}),g=se(t.description||"",h=>a({...t,description:h||void 0}),{allowEmpty:!0}),y=Be(t,a),p=Ae(t,a),x=`h${Math.min(r,6)}`,S=t.type==="object",b=S&&t.children&&t.children.length>0,P={1:"text-lg font-semibold",2:"text-base",3:"text-base",4:"text-base",5:"text-sm",6:"text-sm"}[r]||"text-sm";return e.jsxs("div",{className:"group",children:[e.jsxs("div",{className:"flex gap-4 items-center rounded-md -mx-2 px-2 py-1 transition-colors hover:bg-accent/50",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsxs("div",{className:"flex items-start gap-3",children:[!i&&e.jsx("button",{onClick:()=>a({...t,required:!t.required}),className:"shrink-0 transition-all hover:scale-110 mt-0.5",title:t.required?"Required field - click to make optional":"Optional field - click to make required",children:t.required?e.jsx("span",{className:"block w-4 h-4 rounded-full bg-primary"}):e.jsx("span",{className:"block w-4 h-4 rounded-full border border-dashed border-gray-400"})}),d.isEditing?e.jsx(D,{value:d.value,onChange:h=>d.handleChange(h.target.value),onBlur:d.handleBlur,onKeyDown:d.handleKeyDown,autoFocus:!0,className:P,placeholder:"Enter title"}):e.jsxs("div",{className:"flex gap-2 flex-wrap flex-1",children:[e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsx(x,{className:`${P} cursor-pointer hover:text-primary transition-colors leading-none`,onClick:d.startEdit,children:t.title||t.key||e.jsx("span",{className:"text-muted-foreground italic",children:"unnamed"})}),y.isChangingType?e.jsxs(J,{value:t.type,onValueChange:h=>y.handleTypeChange(h),open:y.isChangingType,onOpenChange:y.setIsChangingType,children:[e.jsx(M,{className:"w-[140px] h-7",children:e.jsx(V,{})}),e.jsx(_,{children:y.availableTypes.map(h=>e.jsx(k,{value:h,children:C[h]},h))})]}):e.jsx(Se,{children:e.jsxs(Ie,{children:[e.jsx(Te,{asChild:!0,children:e.jsxs("button",{onClick:()=>y.setIsChangingType(!0),className:"cursor-pointer hover:bg-accent rounded p-0.5 transition-colors",children:[t.type==="string"&&e.jsx(u.Type,{className:"w-5 h-5 text-muted-foreground"}),t.type==="number"&&e.jsx(u.Hash,{className:"w-5 h-5 text-muted-foreground"}),t.type==="integer"&&e.jsx(u.Hash,{className:"w-5 h-5 text-muted-foreground"}),t.type==="boolean"&&e.jsx(u.CheckSquare,{className:"w-5 h-5 text-muted-foreground"}),t.type==="object"&&e.jsx(u.Braces,{className:"w-5 h-5 text-muted-foreground"}),t.type==="array"&&e.jsx(u.List,{className:"w-5 h-5 text-muted-foreground"}),t.type==="file"&&e.jsx(u.FileText,{className:"w-5 h-5 text-muted-foreground"})]})}),e.jsxs(ne,{children:[m(t.type),t.type==="array"&&t.items?` of ${m(t.items.type)}`:"",e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:"Click to change type"})]})]})}),t.type==="object"&&e.jsx(I,{variant:"ghost",size:"icon",className:"opacity-0 group-hover:opacity-100 h-6 w-6",onClick:p.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(u.Plus,{className:"!w-5 !h-5"})})]}),e.jsx("div",{className:"flex-1",children:g.isEditing?e.jsx(D,{value:g.value,onChange:h=>g.handleChange(h.target.value),onBlur:g.handleBlur,onKeyDown:g.handleKeyDown,autoFocus:!0,className:"text-sm flex-1",placeholder:"Enter description"}):e.jsx(e.Fragment,{children:t.description?e.jsx("p",{className:"text-sm text-muted-foreground flex-1 min-w-[200px] cursor-pointer hover:text-foreground transition-colors","data-testid":`text-description-${t.id}`,onClick:g.startEdit,children:t.description}):e.jsx("p",{className:"text-sm text-muted-foreground/50 flex-1 min-w-[200px] cursor-pointer hover:text-muted-foreground italic transition-colors",onClick:g.startEdit,children:"Add description..."})})})]})]})}),e.jsxs("div",{className:"flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",children:[e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>o.open(t),"data-testid":`button-edit-${t.id}`,children:e.jsx(u.Pencil,{className:"w-3 h-3"})}),S&&t.type!=="object"&&e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:p.addChild,"data-testid":`button-add-child-${t.id}`,children:e.jsx(u.Plus,{className:"w-3 h-3"})}),e.jsx(I,{variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground hover:text-destructive",onClick:s,"data-testid":`button-delete-${t.id}`,children:e.jsx(u.Trash2,{className:"w-3 h-3"})})]})]}),b&&e.jsx("div",{className:r===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:t.children.map(h=>e.jsx(G,{property:h,onUpdate:O=>p.updateChild(h.id,O),onDelete:()=>p.deleteChild(h.id),level:r+1,showRegex:l,keyEditable:n},h.id))}),t.type==="array"&&t.items&&e.jsxs("div",{className:r===1?"ml-6 mt-1 border-l-2 border-border pl-6":"ml-4 mt-1 border-l border-border pl-4",children:[e.jsxs("div",{className:"mb-2 text-xs text-muted-foreground font-semibold uppercase",children:[m("array")," Items"]}),e.jsx(G,{property:t.items,onUpdate:h=>a({...t,items:h}),onDelete:()=>a({...t,items:void 0}),level:r+1,isArrayItem:!0,showRegex:l,keyEditable:n})]}),e.jsx(X,{property:o.data||t,open:o.isOpen,onOpenChange:o.setIsOpen,onUpdate:h=>{a(h),o.close()},isArrayItem:i,isNewProperty:!1,showRegex:l,keyEditable:n}),p.addChildDialog.isOpen&&p.addChildDialog.data&&e.jsx(X,{property:p.addChildDialog.data,open:p.addChildDialog.isOpen,isNewProperty:!0,onOpenChange:p.addChildDialog.setIsOpen,onUpdate:p.addChildDialog.confirm,showRegex:l,keyEditable:n})]})}const te=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("rounded-xl border bg-card text-card-foreground shadow",t),...a}));te.displayName="Card";const Me=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("flex flex-col space-y-1.5 p-6",t),...a}));Me.displayName="CardHeader";const _e=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("font-semibold leading-none tracking-tight",t),...a}));_e.displayName="CardTitle";const $e=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("text-sm text-muted-foreground",t),...a}));$e.displayName="CardDescription";const Ke=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("p-6 pt-0",t),...a}));Ke.displayName="CardContent";const Je=v.forwardRef(({className:t,...a},s)=>e.jsx("div",{ref:s,className:f("flex items-center p-6 pt-0",t),...a}));Je.displayName="CardFooter";const Ve=()=>new Promise((t,a)=>{const s=document.createElement("input");s.type="file",s.accept=".json",s.onchange=r=>{var n;const i=(n=r.target.files)==null?void 0:n[0];if(!i){a(new Error("No file selected"));return}const l=new FileReader;l.onload=m=>{var C;try{const o=JSON.parse((C=m.target)==null?void 0:C.result);t(o)}catch{a(new Error("Invalid JSON file"))}},l.onerror=()=>a(new Error("Failed to read file")),l.readAsText(i)},s.click()}),fe=(t,a="schema.json")=>{const s=JSON.stringify(t,null,2),r=new Blob([s],{type:"application/json"}),i=URL.createObjectURL(r),l=document.createElement("a");l.href=i,l.download=a,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(i)};function He({schema:t}){const[a,s]=j.useState(!1),r=JSON.stringify(t,null,2),i=async()=>{await navigator.clipboard.writeText(r),s(!0),setTimeout(()=>s(!1),2e3)},l=()=>{fe(t,"schema.json")};return e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[e.jsx("h2",{className:"text-sm font-medium",children:"JSON Schema Output"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(I,{variant:"outline",size:"sm",onClick:i,"data-testid":"button-copy",children:a?e.jsx(u.CheckCircle2,{className:"w-4 h-4"}):e.jsx(u.Copy,{className:"w-4 h-4"})}),e.jsx(I,{variant:"outline",size:"sm",onClick:l,"data-testid":"button-download",children:e.jsx(u.Download,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx(te,{className:"m-4 bg-muted/30",children:e.jsx("pre",{className:"p-6 text-xs font-mono overflow-auto","data-testid":"text-json-output",children:e.jsx("code",{children:r})})})})]})}function Ue({title:t,description:a,version:s,onUpdate:r}){const[i,l]=j.useState(!1);return e.jsxs(te,{className:"p-4",children:[e.jsxs(I,{variant:"ghost",onClick:()=>l(!i),className:"w-full justify-between px-2 h-auto hover:bg-transparent","data-testid":"button-toggle-metadata",children:[e.jsx("h3",{className:"text-sm font-medium",children:"Schema Metadata"}),i?e.jsx(u.ChevronDown,{className:"w-4 h-4"}):e.jsx(u.ChevronRight,{className:"w-4 h-4"})]}),i&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-title",className:"text-xs text-muted-foreground",children:"Title"}),e.jsx(D,{id:"schema-title",placeholder:"My Schema",value:t,onChange:n=>r("title",n.target.value),"data-testid":"input-title"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-description",className:"text-xs text-muted-foreground",children:"Description"}),e.jsx(Y,{id:"schema-description",placeholder:"Describe your schema...",value:a,onChange:n=>r("description",n.target.value),className:"resize-none",rows:3,"data-testid":"input-schema-description"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(N,{htmlFor:"schema-version",className:"text-xs text-muted-foreground",children:"Version"}),e.jsx(D,{id:"schema-version",placeholder:"1.0.0",value:s,onChange:n=>r("version",n.target.value),"data-testid":"input-version"})]})]})]})}const A=(t,a,s=!0)=>{const r={type:"object"};s&&a&&(a.title&&(r.title=a.title),a.description&&(r.description=a.description));const i=Q(t);Object.keys(i).length>0&&(r.properties=i);const l=t.filter(n=>n.required&&n.key).map(n=>n.key);return l.length>0&&(r.required=l),r},Q=t=>{const a={};return t.forEach(s=>{if(!s.key)return;const i={type:s.type==="file"?"string":s.type};if(s.title&&(i.title=s.title),s.description&&(i.description=s.description),s.type==="file"&&(i.format="filename"),s.type==="string"&&(s.minLength!==void 0&&(i.minLength=s.minLength),s.maxLength!==void 0&&(i.maxLength=s.maxLength),s.pattern&&(i.pattern=s.pattern),s.enum&&s.enum.length>0&&(i.enum=s.enum)),(s.type==="number"||s.type==="integer")&&(s.minimum!==void 0&&(i.minimum=s.minimum),s.maximum!==void 0&&(i.maximum=s.maximum)),s.type==="array"&&(s.minItems!==void 0&&(i.minItems=s.minItems),s.maxItems!==void 0&&(i.maxItems=s.maxItems),s.uniqueItems&&(i.uniqueItems=s.uniqueItems),s.items&&(i.items=Q([s.items])[s.items.key]||{type:s.items.type})),s.type==="object"&&s.children&&s.children.length>0){i.properties=Q(s.children);const l=s.children.filter(n=>n.required&&n.key).map(n=>n.key);l.length>0&&(i.required=l)}a[s.key]=i}),a},Xe=t=>{const a={properties:[]};return(t.title||t.description)&&(a.metadata={title:typeof t.title=="string"?t.title:"",description:typeof t.description=="string"?t.description:"",version:"1.0.0"}),t.properties&&typeof t.properties=="object"&&(a.properties=W(t.properties,Array.isArray(t.required)?t.required:[])),a},W=(t,a=[])=>t?Object.entries(t).filter(([,s])=>typeof s=="object").map(([s,r])=>{const i=r;let l=typeof i.type=="string"?i.type:"string";l==="string"&&i.format==="filename"&&(l="file");const n={id:Z(),key:s,title:typeof i.title=="string"?i.title:void 0,type:l,description:typeof i.description=="string"?i.description:void 0,required:a.includes(s)};return i.minLength!==void 0&&(n.minLength=i.minLength),i.maxLength!==void 0&&(n.maxLength=i.maxLength),i.pattern&&(n.pattern=i.pattern),i.enum&&Array.isArray(i.enum)&&(n.enum=i.enum),i.minimum!==void 0&&(n.minimum=i.minimum),i.maximum!==void 0&&(n.maximum=i.maximum),i.minItems!==void 0&&(n.minItems=i.minItems),i.maxItems!==void 0&&(n.maxItems=i.maxItems),i.uniqueItems&&(n.uniqueItems=i.uniqueItems),n.type==="array"&&i.items&&typeof i.items=="object"&&!Array.isArray(i.items)&&(n.items=W({item:i.items},[]).find(m=>m.key==="item")),i.properties&&typeof i.properties=="object"&&(n.children=W(i.properties,Array.isArray(i.required)?i.required:[])),n}):[],Ge=({schema:t,onChange:a,includeMetadata:s=!0})=>{const{properties:r,metadata:i}=j.useMemo(()=>Xe(t),[t]),l=r,n=i||{title:"",description:"",version:""},m=j.useCallback(()=>({id:Z(),key:"",type:"string",required:!1}),[]),C=j.useCallback((x,S)=>{const b=l.some(O=>O.id===x);let P;b?P=l.map(O=>O.id===x?S:O):P=[...l,S];const h=A(P,n,s);a(h)},[l,n,s,a]),o=j.useCallback(x=>{const S=l.filter(P=>P.id!==x),b=A(S,n,s);a(b)},[l,n,s,a]),d=j.useCallback(()=>{const S=A([],{title:"",description:""},s);a(S)},[s,a]),g=j.useCallback((x,S)=>{const b={...n,[x]:S},P=A(l,b,s);a(P)},[l,n,s,a]),y=j.useCallback(async()=>{const x=await Ve();a(x)},[a]),p=j.useCallback(()=>{fe(t,"schema.json")},[t]);return{properties:l,metadata:n,addProperty:m,updateProperty:C,deleteProperty:o,clearAll:d,updateMetadata:g,importSchema:y,downloadSchema:p}};function Qe(){const[t,a]=j.useState("light");j.useEffect(()=>{const i=localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");a(i),document.documentElement.classList.toggle("dark",i==="dark")},[]);const s=()=>{const r=t==="light"?"dark":"light";a(r),localStorage.setItem("theme",r),document.documentElement.classList.toggle("dark",r==="dark")};return e.jsx(I,{variant:"ghost",size:"icon",onClick:s,"data-testid":"button-theme-toggle",children:t==="light"?e.jsx(u.Moon,{className:"w-4 h-4"}):e.jsx(u.Sun,{className:"w-4 h-4"})})}function We({schema:t,onChange:a,showMetadata:s=!1,showImport:r=!0,showClear:i=!0,showOutput:l=!0,showHeader:n=!0,className:m="",showSummary:C=!1,typeLabels:o,propertyLabel:d={singular:"property",plural:"properties"},showRegex:g=!1,keyEditable:y=!1}){const{properties:p,metadata:x,addProperty:S,updateProperty:b,deleteProperty:P,clearAll:h,updateMetadata:O,importSchema:c}=Ge({schema:t,onChange:a,includeMetadata:s}),q=ee({createInitialData:()=>S(),onConfirm:T=>{b(T.id,T)}}),B=()=>{h()},$=async()=>{await c()};return e.jsx(ze,{customLabels:o,children:e.jsxs("div",{className:`${m} flex flex-col json-schema-builder-react`,children:[n&&e.jsx("header",{className:"h-16 border-b flex items-center justify-between px-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[r&&e.jsx(I,{variant:"outline",size:"sm",onClick:$,"data-testid":"button-import",children:e.jsx(u.Upload,{className:"w-4 h-4"})}),i&&e.jsx(I,{variant:"outline",size:"sm",onClick:B,disabled:p.length===0,"data-testid":"button-clear",children:e.jsx(u.Trash2,{className:"w-4 h-4"})}),e.jsx(Qe,{})]})}),e.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[e.jsx("div",{className:l?"w-3/5 border-r":"w-full",children:e.jsxs("div",{className:"h-full flex flex-col",children:[e.jsxs("div",{className:"flex-1 overflow-auto p-2 space-y-4",children:[s&&e.jsx(Ue,{title:x.title,description:x.description,version:x.version,onUpdate:(T,R)=>O(T,R)}),p.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(u.Plus,{className:"w-8 h-8 text-muted-foreground"})}),e.jsxs("h2",{className:"text-lg font-medium mb-2",children:["No ",d.plural," yet"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6 max-w-sm",children:["Start building your JSON schema by adding your first"," ",d.singular]}),e.jsxs(I,{onClick:()=>q.open(),"data-testid":"button-add-first",children:[e.jsx(u.Plus,{className:"w-4 h-4 mr-2"}),"Add ",d.singular]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"space-y-1",children:p.map(T=>e.jsx(G,{property:T,onUpdate:R=>b(T.id,R),onDelete:()=>P(T.id),showRegex:g,keyEditable:y},T.id))}),C&&e.jsxs("div",{className:"pt-4 border-t flex items-center justify-between text-sm text-muted-foreground",children:[e.jsxs("span",{children:[p.length," ",p.length===1?d.singular:d.plural]}),e.jsxs("span",{children:[p.filter(T=>T.required).length," required"]})]})]})]}),p.length>0&&e.jsx("div",{className:"border-t p-2 pt-4 bg-background",children:e.jsxs(I,{onClick:()=>q.open(),className:"w-full",variant:"outline","data-testid":"button-add-property",children:[e.jsx(u.Plus,{className:"w-4 h-4"}),"Add ",d.singular]})})]})}),l&&e.jsx("div",{className:"w-2/5",children:e.jsx(He,{schema:t})})]}),q.isOpen&&q.data&&e.jsx(X,{property:q.data,open:q.isOpen,isNewProperty:!0,onOpenChange:q.setIsOpen,propertyLabel:d,onUpdate:q.confirm,showRegex:g,keyEditable:y})]})})}exports.JsonSchemaBuilder=We;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|