bknd
Version:
Lightweight Firebase/Supabase alternative built to run anywhere — incl. Next.js, React Router, Astro, Cloudflare, Bun, Node, AWS Lambda & more.
2 lines (1 loc) • 28.5 kB
JavaScript
import{u as xe,r as m,n as pe,M as fe,a as je,j as e,S as K,B as ge,D as se,I as Y,T as be,b as ye,c as v,d as ve,e as we,f as Ne,t as B,g as Se,h as Te,F as Ce,i as A,E as Ie,C as Ae,G as T,L as E,k as re,l as S,J as ae,m as N,o as Ee,p as Oe,q as ie,s as ke,A as De,v as Fe,w as L,x as Me,y as le,z as $e,H as M,K as k,N as qe,O as z,P as $,Q as q,R as Le,U as ee,V as R,W as Je,X as Ve,Y as Pe,Z as Be,_ as ze,$ as U,a0 as Re,a1 as oe,a2 as He,a3 as ce,a4 as Ue,a5 as W,a6 as We,a7 as Ge,a8 as Qe,a9 as Ke,aa as Ye,ab as _e,ac as Xe,ad as Ze,ae as et,af as tt,ag as nt,ah as V,ai as st,aj as te,ak as de,al as rt,am as at,an as it,ao as lt,ap as ot}from"./main-BgziOQpI.js";import"./TextareaWidget-C8tThLP4.js";function ct(t,n){return xe("(prefers-color-scheme: dark)",t==="dark",n)?"dark":"light"}function dt(t=[]){const[n,s]=m.useState(t);return[n,{setState:s,append:(...d)=>s(u=>[...u,...d]),prepend:(...d)=>s(u=>[...d,...u]),insert:(d,...u)=>s(j=>[...j.slice(0,d),...u,...j.slice(d)]),pop:()=>s(d=>{const u=[...d];return u.pop(),u}),shift:()=>s(d=>{const u=[...d];return u.shift(),u}),apply:d=>s(u=>u.map((j,x)=>d(j,x))),applyWhere:(d,u)=>s(j=>j.map((x,c)=>d(x,c)?u(x,c):x)),remove:(...d)=>s(u=>u.filter((j,x)=>!d.includes(x))),reorder:({from:d,to:u})=>s(j=>{const x=[...j],c=j[d];return x.splice(d,1),x.splice(u,0,c),x}),swap:({from:d,to:u})=>s(j=>{const x=[...j],c=x[d],f=x[u];return x.splice(u,1,c),x.splice(d,1,f),x}),setItem:(d,u)=>s(j=>{const x=[...j];return x[d]=u,x}),setItemProp:(d,u,j)=>s(x=>{const c=[...x];return c[d]={...c[d],[u]:j},c}),filter:d=>{s(u=>u.filter(d))}}]}function ne(t){const n=document.createElement("style");return n.setAttribute("data-mantine-styles","inline"),n.innerHTML="*, *::before, *::after {transition: none !important;}",n.setAttribute("data-mantine-disable-transition","true"),t&&n.setAttribute("nonce",t),document.head.appendChild(n),()=>document.querySelectorAll("[data-mantine-disable-transition]").forEach(r=>r.remove())}function ut({keepTransitions:t}={}){const n=m.useRef(pe),s=m.useRef(-1),r=m.useContext(fe),a=je(),i=m.useRef(a==null?void 0:a());if(!r)throw new Error("[@mantine/core] MantineProvider was not found in tree");const l=h=>{r.setColorScheme(h),n.current=t?()=>{}:ne(i.current),window.clearTimeout(s.current),s.current=window.setTimeout(()=>{var b;(b=n.current)==null||b.call(n)},10)},o=()=>{r.clearColorScheme(),n.current=t?()=>{}:ne(i.current),window.clearTimeout(s.current),s.current=window.setTimeout(()=>{var h;(h=n.current)==null||h.call(n)},10)},y=ct("light",{getInitialValueInEffect:!1}),O=r.colorScheme==="auto"?y:r.colorScheme,p=m.useCallback(()=>l(O==="light"?"dark":"light"),[l,O]);return m.useEffect(()=>()=>{var h;(h=n.current)==null||h.call(n),window.clearTimeout(s.current)},[]),{colorScheme:r.colorScheme,setColorScheme:l,clearColorScheme:o,toggleColorScheme:p}}function ue(t,n){const s=(t==null?void 0:t.tagName.toLowerCase())??"",r=["input","select","textarea"];return!t||!(n!=null&&n.contains(t))||!r.includes(s)||!("name"in t)||t.hasAttribute("data-ignore")||t.closest("[data-ignore]")}function mt(t){const n=t.currentTarget,s=t.target;return ue(s,n)?null:s}function ht(t,n){const s=t.querySelectorAll(`[name="${n}"]`);return Array.from(s).filter(r=>ue(r))}function xt(t,n){if(!t)return n;const s=t.required;if(!(!n&&!s))if(t.type==="number"){const r=Number(n);if(Number.isNaN(r)&&!s)return;const a="min"in t&&t.min.length>0?Number(t.min):void 0,i="max"in t&&t.max.length>0?Number(t.max):void 0,l="step"in t&&t.step.length>0?Number(t.step):void 0;return a&&r<a?a:i&&r>i?i:l&&l!==1?Math.round(r/l)*l:r}else if(t.type==="text"){const r="maxLength"in t&&t.maxLength>-1?Number(t.maxLength):void 0,a="pattern"in t?new RegExp(t.pattern):void 0;return r&&n.length>r?n.slice(0,r):a&&!a.test(n)?"":n}else return t.type==="checkbox"?"checked"in t?!!t.checked:["on","1","true",1,!0].includes(n):n}function G(t,n){if(!t)return t;const s=[null,void 0,""],r={empty:(n==null?void 0:n.empty)??s,emptyInArray:(n==null?void 0:n.emptyInArray)??s,keepEmptyArray:(n==null?void 0:n.keepEmptyArray)??!1};return Object.entries(t).reduce((a,[i,l])=>{if(l&&Array.isArray(l)&&l.some(o=>typeof o=="object")){const o=l.map(y=>G(y,r));(o.length>0||r!=null&&r.keepEmptyArray)&&(a[i]=o)}else if(l&&typeof l=="object"&&!Array.isArray(l)){const o=G(l,r);Object.keys(o).length>0&&(a[i]=o)}else if(Array.isArray(l)){const o=l.filter(y=>!r.emptyInArray.includes(y));(o.length>0||r!=null&&r.keepEmptyArray)&&(a[i]=o)}else r.empty.includes(l)||(a[i]=l);return a},{})}function me(t,n,s){let r=n;if(typeof r=="string"){const l=o=>o[0]==='"'&&o.at(-1)==='"';r=r.split(/[.\[\]]+/).filter(o=>o).map(o=>Number.isNaN(Number(o))?o:Number(o)).map(o=>typeof o=="string"&&l(o)?o.slice(1,-1):o)}if(r.length===0)throw new Error("The path must have at least one entry in it");const[a,...i]=r;return i.length===0?(t[a]=s,t):(a in t||(t[a]=typeof i[0]=="number"?[]:{}),me(t[a],i,s),t)}function pt({children:t,validateOn:n="submit",hiddenSubmit:s=!1,errorFieldSelector:r,reportValidity:a,onSubmit:i,onSubmitInvalid:l,onError:o,clean:y,disableSubmitOnError:O=!0,...p}){const h=m.useRef(null),[b,C]=m.useState([]);m.useEffect(()=>{!h.current||p.noValidate||F()},[]),m.useEffect(()=>{if(!h.current||p.noValidate)return;const c=b.length>0;h.current.querySelectorAll("[type=submit]").forEach(f=>{!f||!("type"in f)||f.type!=="submit"||(f.disabled=c)}),o==null||o(b)},[b]);const D=(c,f)=>{var I;if(p.noValidate||!c||!("name"in c))return;const g=(I=h.current)==null?void 0:I.querySelector((r==null?void 0:r(c.name))??`[data-role="input-error"][data-name="${c.name}"]`);if(c.checkValidity())C(w=>w.filter(J=>J.name!==c.name)),g&&(g.textContent="");else{const w={name:c.name,message:c.validationMessage};return C(J=>[...J.filter(H=>H.name!==c.name),w]),f!=null&&f.report&&(g?g.textContent=w.message:a&&c.reportValidity()),w}},F=c=>{if(!h.current||p.noValidate)return[];const f=[];return h.current.querySelectorAll("input, select, textarea").forEach(g=>{const w=D(g,c);w&&f.push(w)}),O&&h.current.querySelectorAll("[type=submit]").forEach(g=>{f.length>0?g.setAttribute("disabled","disabled"):g.removeAttribute("disabled")}),f},d=()=>{if(!h.current)return{};const c=new FormData(h.current),f={};return c.forEach((g,I)=>{const w=ht(h.current,I);if(w.length===0){console.warn(`No target found for key: ${I}`);return}const H=w.length>1;w.forEach((X,he)=>{let Z=I;H&&(Z=`${I}[${he}]`),me(f,Z,xt(X,X.value))})}),typeof y>"u"?f:G(f,y===!0?void 0:y)},u=async c=>{if(!h.current)return;const g=mt(c);g&&((n==="change"||b.length>0)&&D(g,{report:!0}),p.onChange&&await p.onChange(d(),{event:c,key:g.name,value:g.value,errors:b}))},j=async c=>{c.preventDefault();const f=h.current;if(!f)return;const g=F({report:!0});if(g.length>0){l==null||l(g,{event:c});return}i?await i(d(),{event:c}):f.submit()},x=c=>{h.current&&c.keyCode===13&&b.length>0&&!p.noValidate&&a&&h.current.reportValidity()};return e.jsxs("form",{...p,onChange:u,onSubmit:j,ref:h,onKeyDown:x,children:[t,s&&e.jsx("input",{type:"submit",style:{visibility:"hidden"}})]})}const P=({title:t,open:n,toggle:s,ActiveIcon:r=Se,children:a,renderHeaderRight:i})=>e.jsxs("div",{style:{minHeight:49},className:B("flex flex-col flex-animate overflow-hidden",n?"flex-open border-b border-b-muted":"flex-initial cursor-pointer hover:bg-primary/5"),children:[e.jsxs("div",{className:B("flex flex-row border-muted border-b h-14 py-4 pr-4 pl-2 items-center gap-2"),onClick:s,children:[e.jsx(Y,{Icon:n?r:Te,disabled:n}),e.jsx("h2",{className:"text-lg dark:font-bold font-semibold select-text",children:t}),e.jsx("div",{className:"flex flex-grow"}),i==null?void 0:i({open:n})]}),e.jsx("div",{className:B("overflow-y-scroll transition-all",n?" flex-grow":"h-0 opacity-0"),children:e.jsx("div",{className:"flex flex-col gap-5 p-4 ",children:a})})]});function ft(){const[t,n]=m.useState("1");function s(r){return()=>n(r)}return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx(K,{right:e.jsx(se,{items:[{label:"Settings"}],position:"bottom-end",children:e.jsx(Y,{Icon:be})}),className:"pl-3",children:e.jsx(ge,{path:[{label:"Schema",href:"/"},{label:"Quizzes"}],backTo:"/"})}),e.jsx(P,{title:"Fields",open:t==="1",toggle:s("1"),ActiveIcon:ye,renderHeaderRight:({open:r})=>r?e.jsx(v,{variant:"primary",disabled:!r,children:"Update"}):null}),e.jsx(P,{title:"Settings",open:t==="2",toggle:s("2"),ActiveIcon:ve}),e.jsx(P,{title:"Relations",open:t==="3",toggle:s("3"),ActiveIcon:we}),e.jsx(P,{title:"Indices",open:t==="4",toggle:s("4"),ActiveIcon:Ne})]})}class jt{async validate(n,s){return Ae(n,s)?[]:[...Ie(n,s)]}}const gt=new jt,bt=A.Object({name:A.String(),age:A.Optional(A.Number())});function yt(){const[t,n]=m.useState(null);return e.jsxs(e.Fragment,{children:[e.jsx(Ce,{schema:bt,validator:gt,validationMode:"change",children:({errors:s,dirty:r,reset:a})=>e.jsxs(e.Fragment,{children:[e.jsx("div",{children:e.jsxs("b",{children:["Form ",r?"*":""," (valid: ",s.length===0?"valid":"invalid",")"]})}),e.jsxs("div",{children:[e.jsx("input",{type:"text",name:"name"}),e.jsx("input",{type:"number",name:"age"})]}),e.jsxs("div",{children:[e.jsx("button",{type:"submit",children:"submit"}),e.jsx("button",{type:"button",onClick:a,children:"reset"})]})]})}),e.jsx("pre",{children:JSON.stringify(t,null,2)})]})}function vt(){return e.jsxs("div",{className:"flex flex-col gap-3",children:["formy",e.jsxs(T,{children:[e.jsx(E,{children:"label"}),e.jsx(re,{onCheckedChange:console.log})]}),e.jsxs(T,{children:[e.jsx(E,{children:"label"}),e.jsx(S,{})]})]})}function wt(){const[t,n]=m.useState(),[s,r]=m.useState();return e.jsxs("div",{className:"flex flex-col p-3",children:[e.jsx("h1",{children:"html"}),e.jsxs(pt,{className:"flex flex-col gap-3",validateOn:"change",onChange:n,onSubmit:a=>console.log("submit",a),onSubmitInvalid:a=>console.log("invalid",a),onError:r,reportValidity:!0,clean:!0,children:[e.jsx(S,{type:"text",name:"what",minLength:2,maxLength:5,required:!0}),e.jsx("div",{"data-role":"input-error","data-name":"what"}),e.jsx(S,{type:"number",name:"age",step:5,required:!0}),e.jsx(S,{type:"checkbox",name:"verified"}),e.jsx(S,{type:"text",name:"tag",minLength:1,required:!0}),e.jsx(S,{type:"number",name:"tag"}),e.jsx(v,{type:"submit",children:"submit"})]}),e.jsx(ae,{json:{data:t,errors:s},expand:9})]})}function Nt(){return m.useEffect(()=>{const t=document.createElement("script");return t.src="https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui-bundle.js",t.crossOrigin="anonymous",t.async=!0,t.onload=()=>{window.SwaggerUIBundle&&(window.ui=window.SwaggerUIBundle({url:"http://localhost:28623/api/system/openapi.json",dom_id:"#swagger-ui"}))},document.body.appendChild(t),()=>{document.body.removeChild(t)}},[]),e.jsxs(e.Fragment,{children:[e.jsx("link",{rel:"stylesheet",href:"https://unpkg.com/swagger-ui-dist@5.11.0/swagger-ui.css"}),e.jsx(N,{children:e.jsx("div",{id:"swagger-ui"})})]})}function St(){const[t,n]=m.useState(""),{data:s,...r}=Ee(i=>i.data.readOne("comments",1),{refine:i=>i.data,revalidateOnFocus:!0}),a=s||null;return m.useEffect(()=>{n((a==null?void 0:a.content)??"")},[a]),e.jsxs(N,{children:[e.jsx("pre",{children:JSON.stringify(r.key)}),r.error&&e.jsx("div",{children:"failed to load"}),r.isLoading&&e.jsx("div",{children:"loading..."}),s&&e.jsx("pre",{children:JSON.stringify(s,null,2)}),s&&e.jsxs("form",{onSubmit:async i=>{if(i.preventDefault(),!!a)return!1},children:[e.jsx("input",{type:"text",value:t,onChange:i=>n(i.target.value)}),e.jsx("button",{type:"submit",children:"submit"})]})]})}function Tt(){return e.jsxs(N,{children:["asdf",e.jsx(At,{}),e.jsx(It,{}),e.jsx(Ct,{})]})}function Ct(){const{mutate:t}=ke("comments"),{data:n,...s}=ie("comments",void 0,{limit:2});return e.jsxs("div",{children:["bla",e.jsx("pre",{children:JSON.stringify(s.key)}),s.error&&e.jsx("div",{children:"failed to load"}),s.isLoading&&e.jsx("div",{children:"loading..."}),n&&e.jsx("pre",{children:JSON.stringify(n,null,2)}),n&&e.jsx("div",{children:n.map(r=>e.jsx("input",{type:"text",value:r.content,onChange:async a=>{await t(r.id,{content:a.target.value})},className:"border border-black"},String(r.id)))})]})}function It(){const{data:t,update:n,...s}=ie("users",void 0,{sort:{by:"id",dir:"asc"},limit:3});return e.jsxs("div",{children:[e.jsx("pre",{children:JSON.stringify(s.key)}),s.error&&e.jsx("div",{children:"failed to load"}),s.isLoading&&e.jsx("div",{children:"loading..."}),t&&e.jsx("pre",{children:JSON.stringify(t,null,2)})]})}function At(){const[t,n]=m.useState(),{read:s}=Oe("comments");return m.useEffect(()=>{s().then(r=>n(r))},[]),e.jsx("pre",{children:JSON.stringify(t,null,2)})}function Et(){const t=new De().getSchema(),[n,s]=m.useState(Fe(t,{}));return e.jsxs(N,{children:[e.jsx("div",{className:"flex flex-col p-3",children:e.jsx(L,{schema:t,onChange:s,className:"legacy hide-required-mark"})}),e.jsx(ae,{json:n,expand:9})]})}function Ot({task:t,onChange:n,...s}){const r=t.constructor.schema,a=t.params;return Object.fromEntries(Object.keys(r.properties).map(i=>[i,{"ui:field":"template","ui:fieldReplacesAnyOrOneOf":!0}])),e.jsx(L,{className:"legacy",schema:r,onChange:n,formData:a,...s})}function kt(){const[t,n]=m.useState(null),s=new Me("Fetch Something",{url:"https://jsonplaceholder.typicode.com/todos/1",method:"{{ input.mode }}"});return e.jsxs("div",{className:"flex flex-col p-3",children:[e.jsx(Ot,{task:s,onChange:n}),e.jsx("pre",{children:JSON.stringify(t,null,2)})]})}function Dt(){const[t,{open:n,close:s}]=le(!0);return e.jsxs("div",{className:"flex flex-col w-full h-full justify-center items-center",children:[e.jsx("button",{onClick:n,children:"Open"}),e.jsx($e,{open:t,onClose:s,children:e.jsxs("div",{className:"border-blue-500 border-2 p-10",children:["Modal content ",e.jsx("button",{onClick:s,children:"close"})]})})]})}const Ft={definitions:{primitive:{anyOf:[{title:"String",type:"string"},{title:"Number",type:"number"},{title:"Boolean",type:"boolean"}]},numeric:{anyOf:[{title:"Number",type:"number"},{title:"Datetime",type:"string",format:"date-time"},{title:"Date",type:"string",format:"date"},{title:"Time",type:"string",format:"time"}]},boolean:{title:"Boolean",type:"boolean"}},type:"object",properties:{operand:{enum:["$and","$or"],default:"$and",type:"string"},conditions:{type:"array",items:{type:"object",properties:{operand:{enum:["$and","$or"],default:"$and",type:"string"},key:{type:"string"},operator:{type:"array",items:{anyOf:[{title:"Equals",type:"object",properties:{$eq:{$ref:"#/definitions/primitive"}},required:["$eq"]},{title:"Lower than",type:"object",properties:{$lt:{$ref:"#/definitions/numeric"}},required:["$lt"]},{title:"Greather than",type:"object",properties:{$gt:{$ref:"#/definitions/numeric"}},required:["$gt"]},{title:"Between",type:"object",properties:{$between:{type:"array",items:{$ref:"#/definitions/numeric"},minItems:2,maxItems:2}},required:["$between"]},{title:"In",type:"object",properties:{$in:{type:"array",items:{$ref:"#/definitions/primitive"},minItems:1}}}]},minItems:1}},required:["key","operator"]},minItems:1}},required:["operand","conditions"]};function Mt(){const[t,n]=m.useState(null);return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-3 p-3",children:[e.jsx(L,{schema:Ft,onChange:n}),e.jsx("pre",{children:JSON.stringify(t,null,2)})]})})}function $t(){return e.jsx("div",{className:"flex flex-col w-full h-full justify-center items-center",children:e.jsx(se,{items:[{label:"Item 1",value:"item1"},{label:"Item 2",value:"item2"},{label:"Item 3",value:"item3"}],children:e.jsx("button",{children:"Dropdown"})})})}function qt(){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col w-full h-full p-4 gap-4",children:[e.jsxs("div",{children:[e.jsx("b",{children:"Dropzone User Avatar 1 (overwrite)"}),e.jsx(M.Dropzone,{entity:{name:"models",id:38,field:"inputs"},maxItems:6,autoUpload:!1})]}),e.jsxs("div",{children:[e.jsx("b",{children:"Dropzone User Avatar 1 (overwrite)"}),e.jsx(M.Dropzone,{entity:{name:"models",id:38,field:"outputs"},maxItems:6,autoUpload:!1,children:e.jsx(Lt,{})})]})]})})}function Lt(){const{wrapperRef:t,inputProps:n,showPlaceholder:s,actions:{openFileInput:r}}=M.useDropzone(),{isOver:a,isOverAccepted:i,files:l}=M.useDropzoneState();return e.jsxs("div",{ref:t,className:"size-32 rounded-full border border-gray-200 flex justify-center items-center leading-none overflow-hidden",children:[e.jsx("div",{className:"hidden",children:e.jsx("input",{...n})}),e.jsx("span",{children:"asdf"}),s&&e.jsx(e.Fragment,{children:a&&i?"let it drop":"drop here"}),l.map(o=>e.jsx(M.Preview,{file:o,className:"object-cover w-full h-full",onClick:r},o.path))]})}function Jt(){return e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col justify-center p-4 w-full h-full items-center gap-10",children:[e.jsx(Vt,{}),e.jsx(Bt,{}),e.jsx(Pt,{})]})})}const _=({Icon:t,iconProps:n,rightSection:s,initialValue:r,onChange:a})=>e.jsxs(k.Header,{className:"justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-row flex-grow gap-1 items-center",children:[e.jsx(t,{width:16,height:16,...n??{}}),e.jsx("input",{type:"text",value:r,onChange:a||(()=>{}),className:"font-mono font-semibold bg-transparent w-full rounded-lg outline-none pl-1.5 hover:bg-background/30 transition-colors focus:bg-background/60"})]}),e.jsx("div",{children:e.jsx(Y,{Icon:Re,size:"sm"})})]}),Vt=()=>e.jsxs(k,{className:"w-96",children:[e.jsx(_,{Icon:qe,initialValue:"test_flow"}),e.jsxs(k.Content,{className:"gap-3",children:[e.jsxs("div",{className:"flex flex-row justify-between items-center",children:[e.jsx(z,{label:"Trigger Type",defaultValue:"manual",data:[{label:"Manual",value:"manual"},{label:"HTTP",value:"http"},{label:"Event",value:"event",disabled:!0}]}),e.jsx(z,{label:"Execution Mode",defaultValue:"async",data:[{label:"Async",value:"async"},{label:"Sync",value:"sync"}]})]}),e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsx($,{className:"w-36",label:"Method",defaultValue:"GET",data:["GET","POST","PATCH","PUT","DEL"]}),e.jsx(q,{className:"w-full",label:"Mapping Path",placeholder:"/trigger_http",classNames:{wrapper:"font-mono pt-px"}})]}),e.jsx("div",{className:"flex flex-row gap-2 items-center",children:e.jsx(z,{className:"w-full",label:"Response Type",defaultValue:"json",data:[{label:"JSON",value:"json"},{label:"HTML",value:"html"},{label:"Text",value:"text"}]})})]})]}),Pt=()=>{const[t,n]=Ve([!0,!1]);return e.jsxs(k,{className:"w-[400px]",children:[e.jsx(_,{Icon:Pe,initialValue:"fetch_something"}),e.jsxs(k.Content,{className:"gap-3",children:[e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsx($,{className:"w-36",label:"Method",defaultValue:"GET",data:["GET","POST","PATCH","PUT","DEL"]}),e.jsx(q,{className:"w-full",label:"Mapping Path",placeholder:"/trigger_http",classNames:{wrapper:"font-mono pt-px"}})]}),e.jsx(v,{onClick:n,className:"justify-center",size:"small",variant:"ghost",iconSize:14,IconLeft:t?Be:ze,children:"More options"}),t&&e.jsxs(e.Fragment,{children:[e.jsx(U,{label:"URL query"}),e.jsx(U,{label:"Headers"}),e.jsx("div",{className:"flex flex-row gap-2 items-center",children:e.jsxs(R.Wrapper,{className:"w-full",children:[e.jsx(R.Label,{children:"Body"}),e.jsx(z,{data:["None","Form","JSON"],defaultValue:"JSON"}),e.jsx(U,{label:""})]})})]})]})]})},Bt=()=>e.jsxs(k,{className:"w-[400px]",children:[e.jsx(_,{Icon:Le,initialValue:"query_multiple"}),e.jsxs(k.Content,{className:"gap-3",children:[e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsx($,{className:"w-6/12",label:"Entity",placeholder:"Select entity",data:["users","posts","comments"]}),e.jsx($,{className:"w-4/12",label:"Sort by",data:["id","title","username"],defaultValue:"id"}),e.jsx($,{className:"w-2/12",label:"Sort dir",data:["asc","desc"],defaultValue:"asc"})]}),e.jsx(ee,{label:"Select properties",data:["id","title","username"],placeholder:"All selected"}),e.jsx(ee,{label:"Embed relations",data:["posts","comments"],placeholder:"None selected"}),e.jsxs(R.Wrapper,{className:"w-full",children:[e.jsx(R.Label,{children:"Where object"}),e.jsx("div",{className:"text-sm placeholder:text-slate-400 placeholder:opacity-80",children:e.jsx(Je,{basicSetup:{lineNumbers:!1,foldGutter:!1}})})]})]})]}),zt={debug:!0};function Rt(){const{schema:t,config:n}=oe(),s=JSON.parse(JSON.stringify(t));return n.media.storage.body_max_size=1,s.media.properties.storage.properties.body_max_size.minimum=0,s.media.if={properties:{enabled:{const:!0}}},s.media.then={required:["adapter"]},e.jsx(N,{children:e.jsx("div",{className:"flex flex-col p-3",children:e.jsx(He,{schema:t.auth,options:zt})})})}function Ht(){const t={type:"object",properties:{name:{type:"string",title:"Name",minLength:3},variants:{anyOf:[{type:"string"},{type:"number"}]}}},n=m.useRef(null);function s(){var r,a;console.log("submit",(r=n.current)==null?void 0:r.formData()),console.log("isvalid",(a=n.current)==null?void 0:a.validateForm())}return e.jsxs(e.Fragment,{children:[e.jsx(K,{right:e.jsx(v,{type:"button",variant:"primary",onClick:s,children:"Submit"}),children:"JSON Schema"}),e.jsx("div",{children:e.jsxs("div",{className:"flex flex-grow flex-col gap-3 p-3",children:[e.jsxs(T,{children:[e.jsx(E,{htmlFor:"name",children:"Name"}),e.jsx(S,{id:"name",name:"name"})]}),e.jsx(T,{children:e.jsx(L,{ref:n,schema:t})}),e.jsxs(T,{children:[e.jsx(E,{htmlFor:"name",children:"Options"}),e.jsx(ce,{id:"options",name:"options"})]})]})})]})}function Ut(){return e.jsxs("div",{className:"flex flex-col p-4 gap-3",children:[e.jsx("h1",{children:"LiquidJsTest"}),e.jsx(Ue,{}),e.jsx(q,{}),e.jsx(S,{})]})}function Wt(){return e.jsxs("div",{className:"p-4 flex flex-col gap-2 items-start",children:[e.jsx("h1",{children:"mantine"}),e.jsxs("div",{className:"flex flex-row gap-2 justify-center content-center items-center",children:[e.jsx(W,{color:"blue",children:"Mantine"}),e.jsx(v,{children:"Button"}),e.jsx(v,{variant:"primary",children:"Button"}),e.jsx(W,{onClick:()=>{We.show({title:"Notification",message:"This is a notification",autoClose:!1,color:"blue"})},children:"Notification"})]}),e.jsx(Gt,{}),e.jsx(Qt,{}),e.jsx(Ge,{defaultChecked:!0,label:"I agree to sell my privacy"})]})}function Gt(){const[t,{open:n,close:s}]=le(!1);return e.jsxs(e.Fragment,{children:[e.jsx(Qe,{opened:t,onClose:s,title:"Authentication",children:e.jsx("div",{children:"Modal content"})}),e.jsx(W,{onClick:n,children:"Open modal"})]})}function Qt(){const{colorScheme:t}=ut();return e.jsx(Ke,{label:"Tooltip",children:e.jsxs("span",{children:["Hover me (",t,")"]})})}const Kt=A.Object({example:A.Optional(A.String()),exampleRequired:A.String({minLength:2})});function Yt(){var i;const{register:t,handleSubmit:n,watch:s,formState:{errors:r}}=Ye({resolver:_e(Kt)}),a=l=>console.log(l);return console.log(s("example")),console.log("errors",r),e.jsxs("form",{onSubmit:n(a),children:[e.jsx(q,{defaultValue:"test",...t("example")}),e.jsx(q,{...t("exampleRequired"),error:(i=r.exampleRequired)==null?void 0:i.message}),e.jsx("div",{children:e.jsx("input",{type:"submit"})}),e.jsx("div",{children:Object.entries(r).map(([l,o])=>e.jsxs("p",{children:[l,": ",o.message]},l))})]})}const _t=[{id:"1",position:{x:0,y:0},data:{label:"1"}},{id:"2",position:{x:0,y:100},data:{label:"2"}}],Xt=[{id:"e1-2",source:"1",target:"2"}];function Zt(){return e.jsx("div",{style:{width:"100vw",height:"100vh"},children:e.jsx(Xe,{nodes:_t,edges:Xt})})}const en={auth:{jwt:{basepath:{"ui:options":{label:!1}},fields:{"ui:options":{label:!1,orderable:!1}}},strategies:{additionalProperties:{"ui:widget":"select",type:{"ui:widget":"hidden"}},type:{"ui:widget":"hidden"}}},server:{cors:{allow_methods:{"ui:widget":"checkboxes"},allow_headers:{"ui:options":{orderable:!1}}}},media:{adapter:{"ui:options":{label:!1},type:{"ui:widget":"hidden"}}}};function tn(){const{app:t,schema:n}=oe(),s=["auth","server","media","data"],[r,a]=m.useState(s[0]);if(console.log("schema",n,t.config),!n)return;const i={key:r,schema:n[r],uiSchema:en[r]||{},config:t.config[r]};return console.log("current",i),e.jsx(N,{children:e.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[e.jsx("div",{className:"flex flex-row gap-2",children:s.map(l=>e.jsx("button",{role:"button",className:B("flex py-2 px-3",l===r&&"bg-primary/5"),onClick:()=>a(l),children:l},l))}),e.jsx(L,{schema:i.schema,formData:i.config,uiSchema:i.uiSchema,onChange:console.log,className:"legacy"})]})})}function nn(){return e.jsxs("div",{children:["sortable",e.jsx("div",{className:"p-4",children:e.jsx(sn,{data:[{id:"C",name:"Carbon"},{id:"N",name:"Nitrogen"},{id:"Y",name:"Yttrium"},{id:"Ba",name:"Barium"},{id:"Ce",name:"Cerium"}],onReordered:(...t)=>console.log("reordered",t),onChange:t=>console.log("changed",t)})})]})}function sn({data:t=[],extractId:n,renderItem:s,dndProps:r={droppableId:"sortable-list",direction:"vertical"},onReordered:a,onChange:i}){const[l,o]=dt(t);function y({destination:p,source:h}){const b={from:h.index,to:(p==null?void 0:p.index)||0};o.reorder(b),a==null||a(b.from,b.to)}m.useEffect(()=>{i==null||i(l)},[l]);const O=l.map((p,h)=>{const b=n?n(p):m.useId();return e.jsx(Ze,{index:h,draggableId:b,children:(C,D,F)=>s?s({...p,dnd:{provided:C,snapshot:D,rubic:F}}):e.jsxs("div",{className:"flex flex-row gap-2 p-2 border border-gray-200 rounded-md mb-3 bg-white items-center",ref:C.innerRef,...C.draggableProps,children:[e.jsx("div",{...C.dragHandleProps,children:e.jsx(et,{className:"size-5",stroke:1.5})}),e.jsx("p",{children:JSON.stringify(p)})]})},b)});return e.jsx(tt,{onDragEnd:y,children:e.jsx(nt,{...r,children:p=>e.jsxs("div",{...p.droppableProps,ref:p.innerRef,children:[O,p.placeholder]})})})}function rn(){const[t,n]=m.useState([]),[s,r]=m.useState(!1);async function a(){if(s)return;n([]),r(!0);const i=new EventSource("/api/system/test/sql");i.onmessage=l=>{if(l.data==="[DONE]"){r(!1),i.close();return}const o=JSON.parse(l.data);n(y=>[...y,o]),console.log("data",o)}}return e.jsxs("div",{className:"flex flex-col gap-2 p-4",children:[e.jsx("h1",{children:"ai sql test"}),e.jsx("button",{onClick:a,children:s?"...":"start"}),e.jsx("div",{children:t.map((i,l)=>e.jsx("span",{children:i.response},l))})]})}function an(){return e.jsxs("div",{className:"flex flex-col p-3 gap-4",children:[e.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[e.jsx(v,{size:"small",children:"Small"}),e.jsx(v,{children:"Default"}),e.jsx(v,{variant:"primary",children:"Primary"}),e.jsx(v,{variant:"ghost",children:"Ghost"}),e.jsx(v,{variant:"outline",children:"Outline"}),e.jsx(v,{variant:"red",children:"Red"}),e.jsx(v,{variant:"subtlered",children:"Subtlered"}),e.jsx(v,{size:"large",children:"Large"})]}),e.jsxs("div",{className:"flex flex-row gap-1",children:[e.jsx(V.Exception,{title:"Exception",children:"Alert.Exception"}),e.jsx(V.Info,{title:"Info",children:"Alert.Info"}),e.jsx(V.Success,{title:"Success",children:"Alert.Success"}),e.jsx(V.Warning,{title:"Warning",children:"Alert.Warning"})]}),e.jsxs("div",{className:"flex flex-row gap-3 items-start",children:[e.jsxs(T,{children:[e.jsx(E,{children:"Input"}),e.jsx(S,{placeholder:"Input"})]}),e.jsxs(T,{children:[e.jsx(E,{children:"Checkbox"}),e.jsx(st,{})]}),e.jsxs(T,{children:[e.jsx(E,{children:"Switch"}),e.jsx(re,{})]}),e.jsxs(T,{children:[e.jsx(E,{children:"Select"}),e.jsxs(ce,{children:[e.jsx("option",{value:""}),e.jsx("option",{value:"1",children:"Option 1"}),e.jsx("option",{value:"2",children:"Option 2"})]})]})]})]})}const Q={DropdownTest:$t,Themes:an,ModalTest:Dt,JsonFormTest:Ht,FlowFormTest:kt,QueryJsonFormTest:Mt,FlowCreateSchemaTest:Et,ReactFlowTest:Zt,SchemaTest:tn,MantineTest:Wt,LiquidJsTest:Ut,SqlAiTest:rn,SortableTest:nn,ReactHookErrors:Yt,FlowsTest:Jt,AppShellAccordionsTest:ft,SwaggerTest:Nt,SWRAndAPI:St,SwrAndDataApi:Tt,DropzoneElementTest:qt,JsonSchemaFormReactTest:yt,JsonSchemaForm3:Rt,FormyTest:vt,HtmlFormTest:wt};function un(){return e.jsxs(on,{children:[e.jsx(te,{path:"/",component:()=>e.jsx(de,{title:"Test",description:"Select one."})}),e.jsx(te,{path:"/:test",component:ln})]})}function ln(){const t=ot();if(!t.test||!(t.test in Q))return e.jsx(de,{title:"Test not found"});const n=Q[t.test];return e.jsx(n,{})}function on({children:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(rt,{children:[e.jsx(K,{children:"Tests"}),e.jsx(N,{initialOffset:96,children:e.jsx("div",{className:"flex flex-col flex-grow p-3 gap-3",children:e.jsx("nav",{className:"flex flex-col flex-1 gap-1",children:Object.entries(Q).map(([n,s])=>e.jsx(at,{as:it,href:`/${n}`,children:n},n))})})})]}),e.jsx(lt,{children:t})]})}export{un as default};