react-luna-form 0.0.89 → 0.0.91

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.
@@ -1 +1 @@
1
- import{jsx as Uo}from"react/jsx-runtime";function Xe(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return Uo("div",{"data-slot":"field-control",className:"w-full",children:t})}var $="input",Ke="input/date",Ze="input/email",je="input/number",qe="input/time";var Je="textarea",Qe="radio",et="checkbox",ue="list",tt="select",nt="select/active",ot="select/day",rt="select/month",it="select/timezone",at="select/year";var st="chips",lt="chips/day",ct="chips/month",E="column",dt="description",fe="fields",ut="label",me="value",B="options",ft=["yyyy-MM-dd","MM/dd/yyyy","dd/MM/yyyy","MMMM d, yyyy"],V="data-format",ge="data-mode",pe="data-reserved",ye="email",mt="number",gt="password",pt="tel",k="text",yt="aria-errormessage",bt="aria-invalid",xt="data-invalid",Tt="data-readonly",ht="aria",Rt="data",U="max",At="maxLength",Y="min",St="minLength",I="$ref";var Ft="type",Lt={Africa:"Africa",America:"Americas",Asia:"Asia / Pacific",Atlantic:"Atlantic",Australia:"Asia / Pacific",Europe:"Europe",Indian:"Asia / Pacific",Pacific:"Asia / Pacific"};import{format as Fr,formatDuration as Lr,intervalToDuration as Nr,isValid as j,parseISO as wr}from"date-fns";function d(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function p(e){return c(e)||typeof e=="number"||Yo(e)}function Nt(e){return Array.isArray(e)&&e.every(p)}function c(e){return typeof e=="string"}function Yo(e){return typeof e=="boolean"}var T={error:(...e)=>{be()&&!xe()&&G().error("[Luna Form]",...e)},warn:(...e)=>{be()&&!xe()&&G().warn("[Luna Form]",...e)},info:(...e)=>{be()&&!xe()&&G().info("[Luna Form]",...e)}},be=()=>typeof G()<"u",xe=()=>typeof process<"u"&&process.env.NODE_ENV==="production",G=()=>globalThis.console;function Te(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O={found:!1,value:void 0};function Go(e,t){if(!Array.isArray(t)&&Te(t,e))return{found:!0,value:t[e]};if(!e.includes("."))return O;let n=t;for(let o of e.split(".")){if(n==null)return O;if(Array.isArray(n)){let r=Number(o);if(!Number.isInteger(r)||!Te(n,o))return O;n=n[r]}else if(d(n)){if(!Te(n,o))return O;n=n[o]}else return O}return{found:!0,value:n}}function wt(e,t=me){if(e!=null){if(Nt(e)||p(e))return e;if(d(e)){let n=Ho(e,t);if(p(n))return n}}}function Ho(e,t){let n=m(e,t);if(p(n))return n}function m(e,t){if(!t||!e||typeof e!="object")return null;let n=Go(t,e);return n.found?n.value:null}function Dt(e,t={description:dt,label:ut,value:me}){return e.map(n=>{if(d(n)){let o=m(n,t.label),r=m(n,t.value);if(p(o)&&p(r)){let i=m(n,t.description);return{label:`${o}`,value:`${r}`,...p(i)&&{description:`${i}`}}}}return n})}function Ct(e=k){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);return n&&n!==$?n.trim().toLowerCase():k}var Wo=/^#\/(definition|context)\//,Et={};function Xo(e){return{cache:new Map,readsContext:!1,roots:e,visited:new WeakSet}}var kt=new WeakMap;function W(e=[],t,n){let o=Zo(t,n);if(!o)return It(e);let r=kt.get(e);r||(r=new WeakMap,kt.set(e,r));let i=o.definition??Et,a=r.get(i);if(a||(a={byContext:new WeakMap},r.set(i,a)),a.free!==void 0)return a.free;let s=o.context??Et,l=a.byContext.get(s);if(l!==void 0)return l;let u=Xo(o),g=It(H(e,u));return u.readsContext?a.byContext.set(s,g):a.free=g,g}function It(e){return Array.isArray(e)?e.filter(jo).sort((t,n)=>Ot(t)-Ot(n)):[]}function H(e,t){if(!e||typeof e!="object")return e;if(t.cache.has(e))return t.cache.get(e);if(t.visited.has(e))return e;if(t.visited.add(e),Array.isArray(e)){let i=!1,a=e.map(s=>{let l=H(s,t);return i||=l!==s,l});return t.visited.delete(e),t.cache.set(e,i?a:e),t.cache.get(e)}let n=F(e);if(n!==void 0){let i=Ko(n,t);return i!=null?H(i,t):e}let o={},r=!1;for(let[i,a]of Object.entries(e))o[i]=H(a,t),r||=o[i]!==a;return t.visited.delete(e),t.cache.set(e,r?o:e),t.cache.get(e)}function F(e){return d(e)&&c(e[I])?e[I]:void 0}function Ko(e,t){let n=Wo.exec(e);if(!n)return t.roots.definition?m(t.roots.definition,e):null;n[1]==="context"&&(t.readsContext=!0);let o=n[1]==="context"?t.roots.context:t.roots.definition;return o?m(o,e.slice(n[0].length)):null}function Mt(e){return Object.entries(e??{})}function Ot(e){return e.order??Number.MAX_VALUE}function Zo(e,t){let n={context:vt(t)?t:void 0,definition:vt(e)?e:void 0};return n.context||n.definition?n:null}function vt(e){return d(e)&&Object.keys(e).length>0}function jo(e){return Ft in e?!0:Array.isArray(e[fe])?e[fe].length>0:!0}import{isValid as Ae,parse as Yt,parseISO as qo,format as Gt}from"date-fns";import{enUS as Jo,es as Qo}from"date-fns/locale";var Ht=new Date(2e3,0,1),Wt=/^\d{4}-\d{2}-\d{2}$/,Se="yyyy-MM-dd",er="MMMM d, yyyy",tr=1e3,nr=()=>"supportedValuesOf"in Intl?Intl.supportedValuesOf("timeZone"):[],he="en",or=32,rr=new Map;function b(e){return e?L(rr,e,()=>ir(e),or):he}function ir(e){try{let t=Intl.getCanonicalLocales(e)[0];return t&&Intl.DateTimeFormat.supportedLocalesOf(t).length>0?t:he}catch{return he}}function Fe(e){return b(e).split("-")[0]}function Le(e){let t=b(e);return Array.from({length:12},(n,o)=>({value:(o+1).toString(),label:new Date(0,o).toLocaleString(t,{month:"long"})}))}function Ne(e){let t=b(e);return Array.from({length:7},(n,o)=>({value:o.toString(),label:new Date(2e3,0,2+o).toLocaleString(t,{weekday:"long"})}))}function Xt(e,t){return t>=e?Array.from({length:t-e+1},(n,o)=>{let r=e+o;return{value:r.toString(),label:r.toString()}}):[]}var zt=new WeakMap;function Kt(e){let t=d(e.advanced)?e.advanced:void 0,n=t??e,o=zt.get(n);if(o)return o;let r=t?.length,i={max:_t(r?.max),min:_t(r?.min)};zt.set(n,i);let a=Z(e.name,r,i,ar);for(let s of a)T.warn(s);return i}function _t(e){return typeof e=="number"&&Number.isInteger(e)?e:void 0}var Pt="the field offers no year",ar={beyond:"after",disordered:Pt,kind:"whole year",lost:Pt,needsBoth:!0};function sr(e){let t=e.indexOf("/"),n=t===-1?e:e.slice(0,t);return Lt[n]??"Other"}function lr(e,t){return(e.find(o=>o.type==="timeZoneName")?.value??t).replace(/\s+(?:Standard|Daylight(?: Saving)?|Summer|Winter)\s+Time$/,"")}var $t=new Map;function cr(e){let t=$t.get(e);if(t)return t;let n=[new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"longOffset"}),new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"long"})];return $t.set(e,n),n}function dr(e,t){let[n,o]=cr(e),r=n.formatToParts(t),i=o.formatToParts(t),s=(r.find(u=>u.type==="timeZoneName")?.value??"GMT+00:00").replace("GMT","UTC"),l=lr(i,e);return{offset:s,longName:l}}function ur(e){return e.slice(e.lastIndexOf("/")+1).replace(/_/g," ")}var Bt=new WeakMap;function Zt(e){let t=e.advanced;if(!d(t)||t.suggested==null)return;let n=Bt.get(t);if(n)return n.zone;let o=t.suggested,r=c(o)?fr(o):void 0;return Bt.set(t,{zone:r}),r===void 0&&T.warn(ke(`${e.name}: advanced.suggested`,o,"time zone","no zone is suggested")),r}function fr(e){if(/^[A-Za-z]/.test(e))try{return new Intl.DateTimeFormat("en",{timeZone:e}).resolvedOptions().timeZone}catch{return}}var mr=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:?\d{2})$/;function K(e){if(e===void 0||!mr.test(e))return;let t=qo(e);return Ae(t)?t:void 0}var gr=8,pr=new Map;function jt(e,t){let n=K(t);return L(pr,`${e??""}|${n?.getTime()??""}`,()=>yr(e,n),gr)}function yr(e,t){let n=i=>{let a=ur(i);if(!t)return Object.freeze({value:i,label:a});let{offset:s,longName:l}=dr(i,t);return Object.freeze({value:i,label:`${a} - ${l} (${s})`})},o=new Map;for(let i of nr()){let a=sr(i);if(i===e||a==="Other")continue;let s=o.get(a);s?s.push(n(i)):o.set(a,[n(i)])}let r=Array.from(o.entries()).sort(([i],[a])=>i.localeCompare(a,"en")).map(([i,a])=>Object.freeze({label:i,items:Object.freeze(a.sort((s,l)=>s.label.localeCompare(l.label,"en")))}));return Object.freeze(e?[Object.freeze({label:"Suggested",items:Object.freeze([n(e)])}),...r]:r)}function br(e,t){let n=e.trim();if(n){if(Wt.test(n))return Vt(n,Se);for(let o of Object.values(Jt)){let r=Vt(n,t,o);if(r)return r}}}function Vt(e,t,n){try{let o=Yt(e,t,Ht,{locale:n});return Ae(o)&&o.getFullYear()>=tr?o:void 0}catch{return}}function we(e,t){let n=e?br(e,t):void 0;return n?Gt(n,Se):""}function qt(e,t){if(!e)return"";try{let n=Yt(e,t,Ht);return Ae(n)?Gt(n,"HH:mm:ss"):""}catch{return""}}var Jt={en:Jo,es:Qo};function De(e){return Jt[Fe(e)]}function Ce(e){return e.advanced?.format??"HH:mm"}function xr(e){return ft.find(t=>t===e)??er}function Qt(e){return xr(e.advanced?.format)}function Re(e){return c(e)&&Wt.test(e)&&we(e,Se)||void 0}function Tr(e){let t=new Set,n=[];return e.forEach((o,r)=>{let i=Re(o);i===void 0?n.push(r):t.add(i)}),{days:[...t].sort(),rejected:n}}var en={days:[],rejected:[]},hr={reserved:en.days,unreadable:!1},Ut=new WeakMap;function tn(e){let t=e.advanced;if(!d(t))return hr;let n=Ut.get(t);if(n)return n;let o=Array.isArray(t.reserved)?Tr(t.reserved):en,r={max:Re(t.length?.max),min:Re(t.length?.min)},i={...r,reserved:o.days,unreadable:Ee(t.length,r)||t.reserved!=null&&(!Array.isArray(t.reserved)||o.rejected.length>0)};Ut.set(t,i);let a=Rr(e.name,t,i,o.rejected);for(let s of a)T.warn(s);return i}function Ee(e,t){return e==null?!1:!d(e)||F(e)!==void 0?!0:on.some(n=>e[n]!=null&&t[n]===void 0)}function nn(e){return c(e)?[e,""]:Array.isArray(e)&&e.length<=2&&e.every(c)?[e[0]??"",e[1]??""]:void 0}var on=["min","max"];function Rr(e,t,n,o){return[...Z(e,t.length,n,Ar),...Sr(e,t.reserved,o)]}var X="the field takes no day",Ar={beyond:"after",disordered:"no day passes",kind:"yyyy-MM-dd day",lost:X,needsBoth:!1};function Z(e,t,n,o){let r=F(t);if(r!==void 0)return[`${e}: advanced.length points at ${r}, which nothing resolved, so ${o.lost}`];let i=d(t)?t:{};if(o.needsBoth&&i.min==null&&i.max==null)return[`${e}: advanced.length.min and .max are missing, so ${o.lost}`];let a=[];for(let s of on){let l=i[s];if(n[s]!==void 0||l==null&&!o.needsBoth)continue;let u=`${e}: advanced.length.${s}`;a.push(l==null?`${u} is missing, so ${o.lost}`:ke(u,l,o.kind,o.lost))}return n.min!==void 0&&n.max!==void 0&&n.min>n.max&&a.push(`${e}: advanced.length.min is ${o.beyond} advanced.length.max, so ${o.disordered}`),a}function Sr(e,t,n){if(t==null)return[];let o=`${e}: advanced.reserved`;if(!Array.isArray(t)){let r=F(t);return[r!==void 0?`${o} points at ${r}, which nothing resolved, so ${X}`:`${o} is ${JSON.stringify(t)}, which is no list of days, so ${X}`]}return n.map(r=>ke(`${o}[${r}]`,t[r],"yyyy-MM-dd day",X))}function ke(e,t,n,o){let r=F(t);return r!==void 0?`${e} points at ${r}, which nothing resolved, so ${o}`:`${e} is ${JSON.stringify(t)}, which is no ${n}, so ${o}`}function L(e,t,n,o){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let i=e.keys().next().value;e.size>=o&&i!==void 0&&e.delete(i);let a=n();return e.set(t,a),a}var Dr=["short","medium","long","full"],Cr=e=>Dr.some(t=>t===e),Er={ms:1,s:1e3,min:6e4,h:36e5,d:864e5};function q(e){if(typeof e=="number"&&!Number.isNaN(e))return e;if(c(e)&&e.trim()!==""){let t=Number(e);return Number.isNaN(t)?null:t}return null}function rn(e,t,n){let o=Er[t];if(o===void 0)return String(e);let r=e*o,i=Nr({start:0,end:r});return Lr(i,{locale:De(n)})}function an(e){if(e instanceof Date)return j(e)?e:null;if(c(e)){let t=wr(e);if(j(t))return t;let n=new Date(e);return j(n)?n:null}if(typeof e=="number"){let t=new Date(e);return j(t)?t:null}return null}var sn=new WeakSet;function J(e){let t=e?.now;if(t!=null){if(c(t)&&K(t))return t;e&&!sn.has(e)&&(sn.add(e),T.warn(`context.now is ${kr(t)}, which is no ISO date, time and offset such as "2026-10-05T19:30:00-05:00", so nothing is measured from it`))}}function kr(e){return e instanceof Date?"a Date (pass its toISOString())":c(e)?JSON.stringify(e):`a ${typeof e}`}var Oe=64,Ir=new Map,Or=new Map,vr=new Map;function cn(e,t,n){let o=b(n);return L(Ir,`${o}|${t}`,()=>new Intl.DateTimeFormat(o,{dateStyle:t}),Oe).format(e)}function Ie(e,t,n={}){let o=b(t);return L(Or,`${o}|${n.style??""}|${n.currency??""}`,()=>new Intl.NumberFormat(o,n),Oe).format(e)}function ln(e,t){let n=K(t.now);return n?_r(e,n,t.locale):cn(e,"medium",t.locale)}var dn=1e3,un=60*dn,fn=60*un,mn=24*fn,gn=30.4375*mn,Mr=12*gn,zr=[["second",dn,60],["minute",un,60],["hour",fn,24],["day",mn,31],["month",gn,12]];function _r(e,t,n){let o=e.getTime()-t.getTime(),r=Math.abs(o),i=(a,s)=>{let l=b(n),u=a===0?"auto":"always";return L(vr,`${l}|${u}`,()=>new Intl.RelativeTimeFormat(l,{numeric:u}),Oe).format(o<0?-a:a,s)};for(let[a,s,l]of zr){let u=Math.round(r/s);if(u<l)return i(u,a)}return i(Math.round(r/Mr),"year")}var Pr={currency:(e,t,n)=>{let o=q(e);if(o===null)return String(e);let r=t[0]??"USD";return Ie(o,n.locale,{style:"currency",currency:r})},percent:(e,t,n)=>{let o=q(e);return o===null?String(e):Ie(o,n.locale,{style:"percent"})},number:(e,t,n)=>{let o=q(e);return o===null?String(e):Ie(o,n.locale)},date:(e,t,n)=>{let o=an(e);if(!o)return String(e);let r=t[0]??"short";return r==="relative"?ln(o,n):Cr(r)?cn(o,r,n.locale):Fr(o,r,{locale:De(n.locale)})},duration:(e,t,n)=>{if(typeof e=="number")return rn(e,t[0]??"ms",n.locale);if(c(e)){let r=q(e);if(r!==null)return rn(r,t[0]??"ms",n.locale)}let o=an(e);return o?ln(o,n):String(e)}};function pn(e,t,n){let o=t.split(":").map(s=>s.trim()).filter(s=>s.length>0);if(o.length===0)return;let[r,...i]=o,a=Pr[r];if(a)return a(e,i,n)}var $r=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g,Br=/{([^}]{1,200})}/,Vr=/{([^}]{1,200})}/g;function Q(e,t){return{locale:e,now:J(t)}}function ve(e,t={},n={}){if(c(e))return Yr(e,t,n);if(Array.isArray(e))return e.map(o=>ve(o,t,n));if(d(e)){let o={};for(let r in e)o[r]=ve(e[r],t,n);return o}return e}function ee(e,t={},n={}){return Me(e)?ve(e,t,n):e}function Me(e){return c(e)?Br.test(e):Array.isArray(e)?e.some(t=>Me(t)):d(e)?Object.values(e).some(t=>Me(t)):!1}function Ur(e,t){return t.includes(".")?m(e,t):e[t]}function Yr(e,t={},n={}){return e.replace(Vr,(o,r)=>{let i=String(r).split("|").map(g=>g.trim()),[a,...s]=i;if(!a)return o;let l=Ur(t,a);if(s.length===0)return p(l)?String(l):o;if(l==null)return o;let u=l;for(let g of s){let We=pn(u,g,{locale:n.locale,now:n.now});if(We===void 0)return o;u=We}return String(u)})}function yn(e,t){if(!c(e)||!e||e.trim().length===0)return null;let n,o=0,r=!1,i=[];for(;(n=$r.exec(e))!==null;){let[a,s,l]=n,u=n.index;r=!0,u>o&&i.push(e.substring(o,u));let g=t?t(u,l,s):a;i.push(g),o=u+a.length}return r?(o<e.length&&i.push(e.substring(o)),i):e}var bn=e=>f(nt)(e),xn=e=>f(ot)(e),Tn=e=>f(rt)(e),hn=e=>f(at)(e),Rn=e=>f(it)(e),An=e=>f(lt)(e),Sn=e=>f(ct)(e),te=f(Ke),ze=f(qe);function _e(e){return te(e)&&e.advanced?.mode==="range"}var y=f(et),N=f(st),A=f(Qe),Fn=f($),h=f(tt),Ln=f(Je),Nn=f(k,ye,gt,pt),Na=f(Ze,ye),Pe=f(je,mt);function wn(e){return A(e)||y(e)}function w(e){return e.type===ue}function S(e){return e.type===E}function ne(e){return e.type!==E&&e.type!==ue}function $e(e){return h(e)||A(e)||N(e)}function v(e){return e!=null&&e!==""}function f(...e){return t=>{let n=c(t.type)?t.type:void 0;return n?e.some(o=>n===o||n?.startsWith(`${o}/`)):!1}}function En(e,t={}){if(h(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&d(n))return[n]}}function kn(e){return A(e)||y(e)?!0:e.advanced?.horizontal}function In(e){return y(e)?e.advanced?.reverse!==!1:!1}function On(e,t){return!!(t||e.disabled||e.readonly)}function vn(e,t){return!!e.readonly&&!t&&!e.disabled}function Mn(e){let t=e.advanced?.step;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}var Gr={unreadable:!1},Dn=new WeakMap;function oe(e){let t=e.advanced;if(!d(t))return Gr;let n=Dn.get(t);if(n)return n;let o=t.length,r=d(o)?o:void 0,i={max:Cn(r?.max),min:Cn(r?.min)},a={...i,unreadable:Ee(o,i)};Dn.set(t,a);let s=w(e)?Wr:Hr;for(let l of Z(e.name,o,a,s))T.warn(l);return a}function Cn(e){return typeof e=="number"&&!Number.isNaN(e)?e:void 0}var Hr={beyond:"above",disordered:"no value passes",kind:"number",lost:"the field takes no value",needsBoth:!1},Wr={beyond:"above",disordered:"no list passes",kind:"number",lost:"no list passes",needsBoth:!1};function Be(e){if(Xr(e)){let t=e.source;if(Array.isArray(t)||d(t)&&!(I in t))return t}}function zn(e){return Array.isArray(Be(e))}function Xr(e){return h(e)?!e.disabled||Array.isArray(e.source):A(e)||N(e)}var Kr={es:{"(Optional)":"(Opcional)","Add item":"A\xF1adir elemento","An unexpected error occurred submitting the form.":"Ocurri\xF3 un error inesperado al enviar el formulario.","Collapse {label} {index}":"Contraer {label} {index}","Expand {label} {index}":"Expandir {label} {index}","Please correct the errors and try again.":"Corrige los errores e int\xE9ntalo de nuevo.","Remove {label} item {index}":"Eliminar {label} {index}","There were validation errors submitting the form.":"Se encontraron errores de validaci\xF3n al enviar el formulario.","Unknown error":"Error desconocido",No:"No",Yes:"S\xED"}};function Pn(e,t){return x(e,t)}function $n(e,t){if(!e)return;let n=b(e),o=Fe(n),r=[Kr[o],t?.[o],o===n?void 0:t?.[n]].filter(i=>i!==void 0);return r.length<=1?r[0]:Object.assign({},...r)}function x(e,t){return e?t?t[e]??e:e:""}function D(e,t){return e?x(e,t):void 0}function re(e,t){if(!t)return e;let n=!1,o=e.map(r=>{let i=Zr(r,t);return i!==r&&(n=!0),i});return n?o:e}function Zr(e,t){if(!d(e))return e;let n=_n(e.label,t),o=e.items;if(Array.isArray(o)){let i=re(o,t);return i===o&&n===e.label?e:{...e,...n!==void 0&&{label:n},items:i}}let r=_n(e.description,t);return n===e.label&&r===e.description?e:{...e,...n!==void 0&&{label:n},...r!==void 0&&{description:r}}}function _n(e,t){return c(e)?x(e,t):e}function jr(e,t){if(N(e))return qr(e,t?.lang)}function qr(e,t){if(An(e))return Ne(t);if(Sn(e))return Le(t)}function Jr(e,t,n){if(h(e))return Qr(e,t,n)}function Qr(e,t,n){let{lang:o,translations:r}=t??{};if(xn(e))return Ne(o);if(Tn(e))return Le(o);if(hn(e)){let{max:i,min:a}=Kt(e);return a!==void 0&&i!==void 0?Xt(a,i):[]}if(Rn(e))return jt(Zt(e),n);if(bn(e))return re([{value:"true",label:"Yes"},{value:"false",label:"No"}],r)}function Bn(e,t=!1,n,o){let r={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Fn(e)?{...r,...ei(e,n?.lang)}:h(e)?{...r,...Vn(Jr(e,n,o))}:Ln(e)?{...r,...oi(e)}:N(e)?{...r,...ni(e,n)}:r}function ei(e,t){let n=Ct(e.type),o={...e,type:n};return{...ii(e),...ai(e,t),...Un(e),...ri(o),...ti(o),...Nn(o)?Yn(o):{},type:n}}function ti(e){let t=Mn(e);return Pe(e)&&t!==void 0?{step:t}:{}}function Vn(e){return e?{options:e}:{}}function ni(e,t){let n=Vn(jr(e,t)),o=e.advanced?.multiple??!0;return{...n,multiple:o}}function oi(e){return{...Un(e),...Yn(e)}}function Un(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function ri(e){return Pe(e)?si(e):{}}function ii(e){if(ze(e)){let t=Ce(e),n=t==="HH:mm:ss"||t==="hh:mm:ss a";return{[V]:t,step:n?"1":"60"}}return{}}function ai(e,t){let n=Kn(e);if(!n)return{};let{max:o,min:r,reserved:i}=tn(e);return{[V]:n,...t&&{lang:t},...r!==void 0&&{[Y]:r},...o!==void 0&&{[U]:o},...i.length>0&&{[pe]:i.join(",")},..._e(e)&&{[ge]:"range"}}}function Yn(e){return Gn(e,{min:St,max:At})}function si(e){return Gn(e,{min:Y,max:U})}function Gn(e,t){let{max:n,min:o}=oe(e),r={};return o!==void 0&&(r[t.min]=o),n!==void 0&&(r[t.max]=n),r}function Hn(e,t){let n=Be(e);return n||En(e,t)}function li(e,t){let n=d(t)&&e.name in t?t[e.name]:t,o=wt(n,e.advanced?.entity),r=v(o)?o:e.defaultValue;return ze(e)&&v(r)?ci(e,r):te(e)&&v(r)?mi(e,r):r}function ci(e,t){let n=Ce(e);return c(t)?qt(t,n):t}function di(e,t,n){return $e(e)&&Array.isArray(n)?{...t,[B]:n}:t}function ui(e,t,n){if(e.required&&!v(n)&&h(e)&&e.advanced?.preselected!==!1&&B in t){let o=t[B];if(Array.isArray(o)&&o.length===1)return o[0]}return n}function fi(e,t,n){if($e(e)&&Array.isArray(t)){let o=Dt(t,e.advanced?.options);return zn(e)?re(o,n):o}return t}function Wn(e,t,n,o,r){let i=li(e,o),a=Array.isArray(n)?fi(e,n,r):n,s=di(e,t,a),l=ui(e,s,i);return{commonPropsWithOptions:s,defaultValue:l}}function Xn(e,t){return y(e)?{defaultChecked:!!t}:{defaultValue:t}}function mi(e,t){let n=Kn(e);if(!n)return t;if(_e(e)){let o=t==null||t===""?void 0:nn(t);if(!o)return t;let r=Ve(o[0],n),i=Ve(o[1],n);return Array.isArray(t)&&t[0]===r&&t[1]===i?t:[r,i]}return c(t)?Ve(t,n):t}function Ve(e,t){return we(e,t)||e}function Kn(e){return e&&te(e)?Qt(e):void 0}function Zn(e,t){let n={};for(let[o,r]of Mt(t))n[`${e}-${o}`]=r;return n}function gi(e){return Zn(ht,e)}function pi(e){return Zn(Rt,e)}function jn(e,t){let n=gi(e.advanced?.aria);return t&&t.length>0&&(n[bt]="true",n[yt]=`${e.name}-error`),n}function qn(e){return pi(e.advanced?.data)}var Jn={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Qn={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function eo(e,t=2){return Jn[e&&e in Jn?e:t]}function to(e){if(e&&e in Qn)return Qn[e]}function yi(e){let{max:t,min:n}=oe(e);return{min:n??1,max:t??1/0}}function bi(e,t){let n=t?m(t,e.name):null;return xi(e,Array.isArray(n)?n.length:0)}function no(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===E}function oo(e,t){let n=bi(e,t);return Array.from({length:n},(o,r)=>r)}function ro(e){return e.advanced?.title??e.label??e.name}function xi(e,t){let{min:n,max:o}=yi(e);return Math.min(Math.max(t,n),o)}function ie(e,t){let n={...e};for(let o of Object.keys(t??{})){let r=t?.[o];r!==void 0&&(n[o]=r)}return n}import{jsx as Ti}from"react/jsx-runtime";function R(e){return yn(e,(t,n,o)=>Ti("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:o},`${n}-${t}`))}import{jsx as ae,jsxs as io}from"react/jsx-runtime";function ao(e){let t=io("div",{className:"flex flex-col",children:[e.title&&ae("legend",{className:"mb-3 font-medium text-zinc-800 dark:text-zinc-200",children:R(e.title)}),e.description&&ae("p",{className:"-mt-2 text-sm leading-normal font-normal text-zinc-600 dark:text-zinc-400",children:R(e.description)})]});return e.step?io("div",{className:"flex flex-row items-start gap-4",children:[ae("div",{className:"bg-primary text-primary-foreground flex size-6 shrink-0 items-center justify-center rounded-full",children:ae("span",{className:"text-sm font-bold",children:e.step})}),t]}):t}import{jsx as so,jsxs as hi}from"react/jsx-runtime";function se(e){return hi("fieldset",{className:"flex w-full min-w-0 flex-col data-[empty=false]:gap-6","data-empty":e.empty,"data-slot":"field-set",id:e.id,children:[so(ao,{description:e.description,step:e.step,title:e.title}),so("div",{className:"w-full min-w-0",children:e.children})]})}import{jsx as Ri}from"react/jsx-runtime";function C(e){return Ri("div",{"data-slot":"field-group","data-compact":e.compact,className:"flex w-full flex-col gap-8 data-[compact=true]:gap-3",children:e.children})}import{jsx as M,jsxs as lo}from"react/jsx-runtime";function co(e){let{fields:t=[]}=e.section,n=e.advanced?.step?e.step:void 0,{compact:o}=ie(e.style,{compact:e.section.advanced?.compact}),r=M(C,{compact:o,children:e.children});if(!e.section.title&&!e.section.description)return r;let i=D(e.section.title,e.translations),a=D(e.section.description,e.translations);return e.section.advanced?.collapsible?lo("fieldset",{"data-slot":"field-set","data-advanced":"true","data-expanded":!0,"data-empty":t.length===0,className:"flex flex-col",id:e.section.id?.toString(),children:[M("legend",{children:M("span",{className:"flex items-center gap-2 text-base font-medium text-zinc-600 dark:text-zinc-400",children:R(i)})}),lo("div",{className:"mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-zinc-300 pl-4 dark:border-zinc-600","data-slot":"field-set-content",children:[a&&M("p",{className:"text-sm leading-normal font-normal text-zinc-600 dark:text-zinc-400",children:R(a)}),r]})]}):M(se,{description:a,empty:t.length===0,id:e.section.id?.toString(),step:n,title:i,children:r})}import{jsx as uo}from"react/jsx-runtime";function fo(){return uo("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:uo("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-zinc-200 dark:bg-zinc-800"})})}function Ai(e,t){return e.fields.every(n=>mo(n,t))}function mo(e,t){return t[e.name]?.hidden??e.hidden??!1}function Si(e,t){return S(e)?Ai(e,t):mo(e,t)}function go(e,t,n){return n&&(e[n.name]?.hidden??n.hidden??!1)||t.length===0?!0:t.every(o=>Si(o,e))}import{jsx as z,jsxs as po}from"react/jsx-runtime";function Fi(e){return go({},e.fields)?null:e.children}function yo(e){let t=W(e.sections,e.definition,e.context),n=e.guard??Fi,o=e.fieldSet??co;return z("div",{className:"h-full w-full",children:z("form",{noValidate:e.noValidate,action:e.action,onSubmit:e.onSubmit,children:po(C,{children:[t.map((r,i)=>po(n,{fields:r.fields??[],children:[z(o,{advanced:e.advanced,section:r,step:i+1,style:e.config.style,translations:e.translations,children:e.children({disabled:e.readOnly,fields:r.fields})}),r.advanced?.separator&&z(fo,{})]},`key-${r.id}-${i}`)),e.control&&z(Xe,{isPending:e.isPending,children:e.control})]})})})}import{twMerge as Li}from"tailwind-merge";import{jsx as bo,jsxs as Ni}from"react/jsx-runtime";function xo(e){let t=e.style?.showOptionalLabel??!0,n=A(e.field)||y(e.field);return Ni("label",{"data-slot":"field-label","data-normal":n,className:Li("flex w-fit items-center text-sm leading-snug font-medium select-none","data-[normal=true]:font-normal [[data-slot=column]_&]:md:w-full","group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"),htmlFor:e.field.name,title:c(e.children)?e.children:void 0,children:[bo("span",{className:"[[data-slot=column]_&]:md:truncate",children:e.children}),t&&!e.field.required&&bo("span",{className:"ml-2 flex-shrink-0 text-sm text-zinc-600 dark:text-zinc-400",children:Pn("(Optional)",e.translations)})]})}import{jsx as To}from"react/jsx-runtime";function wi(e){return To("p",{className:"-mt-2 text-xs leading-normal font-normal text-zinc-600 dark:text-zinc-400 [[data-slot=column]_&]:md:line-clamp-2",title:e.title,children:e.children})}function le(e){let t=c(e.text)?e.text:e.text?.message;if(!t)return null;let n=ee(t,{context:e.context,env:e.config?.env},Q(e.localization?.lang,e.context));return To(wi,{title:c(e.text)?void 0:e.text?.title,children:R(x(n,e.localization?.translations))})}import{jsx as Di}from"react/jsx-runtime";function ce(e){return Di(le,{config:e.config,context:e.context,localization:e.localization,text:e.field.description})}import{jsx as ho,jsxs as Ci}from"react/jsx-runtime";function Ro(e){let t=e.description??ce,n={context:e.context,env:e.config?.env},o=ee(e.field.label,n,Q(e.localization?.lang,e.context));return Ci("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[ho(xo,{field:e.field,style:e.config?.style,translations:e.localization?.translations,children:x(o,e.localization?.translations)}),e.horizontal===!0&&ho(t,{config:e.config,context:e.context,field:e.field,localization:e.localization})]})}import{Fragment as Ei,jsx as Ao,jsxs as ki}from"react/jsx-runtime";function So(e){let t=e.description??ce;return ki(Ei,{children:[e.field.name&&e.field.label&&Ao(Ro,{config:e.config,context:e.context,description:e.description,field:e.field,horizontal:e.horizontal,localization:e.localization}),e.children,e.horizontal===!1&&Ao(t,{config:e.config,context:e.context,field:e.field,localization:e.localization})]})}function Fo(e,t){return e?t(e):null}import{jsx as Lo}from"react/jsx-runtime";function No(e){let t=Hn(e.field,e.value),{commonPropsWithOptions:n,defaultValue:o}=Wn(e.field,e.commonProps,t,e.value,e.localization?.translations),r=Xn(e.field,o);return Fo(e.config.inputs[e.field.type],i=>Lo(So,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,localization:e.localization,children:Lo(i,{...e.dataAttributes,...n,...e.ariaAttributes,...r})}))}import{twMerge as Ii}from"tailwind-merge";import{jsx as Oi}from"react/jsx-runtime";function de(e){let t=e.errors&&e.errors.length>0;return Oi("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[xt]:"true"},...e.disabled&&{[Tt]:"true"},"data-orientation":e.orientation,className:Ii("group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500","data-[clickable=true]:items-start",e.isCheckbox&&(e.isReversed?"flex-row-reverse!":"flex-row!"),"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",e.className),children:e.children})}import{twMerge as vi}from"tailwind-merge";import{jsx as Mi}from"react/jsx-runtime";function wo(e){return Mi(de,{...e,orientation:"vertical",className:vi("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as zi}from"tailwind-merge";import{jsx as _i}from"react/jsx-runtime";function Do(e){return _i(de,{...e,orientation:"horizontal",className:zi("gap-2 md:flex-row md:gap-4","[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start","[&_[role=checkbox]]:mt-[1.5px]",e.isClickable&&"md:flex-col",!e.isClickable&&["md:justify-between","[&>*:not([data-slot=field-content])]:w-full","[&>*:not([data-slot=field-content])]:md:w-1/2","[&>*:not([data-slot=field-content])]:xl:w-2/5"]),children:e.children})}import{jsx as Co}from"react/jsx-runtime";function Eo(e){let t=wn(e.field),n=y(e.field),o=In(e.field);return e.horizontal?Co(Do,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children}):Co(wo,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children})}function ko(e){if(!e.field.type)return null;let t=Bn(e.field,e.disabled,e.localization,e.now),n=qn(e.field),o=jn(e.field,e.errors),r=!!e.field.disabled===t.disabled?e.field:{...e.field,disabled:t.disabled};return e.children({ariaAttributes:o,commonProps:t,dataAttributes:n,field:r,horizontal:e.horizontal,localization:e.localization,readOnly:e.readOnly})}import{twMerge as Pi}from"tailwind-merge";import{jsx as Ue}from"react/jsx-runtime";function Io(e){let t=e.field.advanced?.cols,{horizontal:n=!1}=ie(e.style,{horizontal:kn(e.field)}),o=On(e.field,e.disabled),r=vn(e.field,e.disabled);return Ue("div",{className:Pi("flex flex-col gap-3",to(t)),children:Ue(Eo,{disabled:o,field:e.field,horizontal:n,children:Ue(ko,{disabled:o,field:e.field,horizontal:n,localization:e.localization,now:e.now,readOnly:r,children:e.children})})})}import{jsx as $i}from"react/jsx-runtime";function Oo(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0,n=D(e.field.label,e.translations),o=D(e.field.description,e.translations);return $i(se,{description:o,empty:t,id:e.field.name,title:n,children:e.children})}import{jsx as Ye,jsxs as vo}from"react/jsx-runtime";function Mo(e){let t=e.localization?.translations,n=x(ro(e.field),t),o=no(e.field);return Ye(Oo,{field:e.field,translations:t,children:oo(e.field,e.value).map(r=>vo("div",{"data-slot":o?"list-item-card":void 0,className:o?"box-border w-full min-w-0 rounded-lg border border-zinc-100 p-4 dark:border-zinc-900":"box-border flex w-full min-w-0 flex-col gap-2",children:[o&&Ye("div",{className:"flex min-w-0 flex-col font-medium text-zinc-700 dark:text-zinc-400",children:vo("span",{className:"text-base",children:[n," ",r+1]})}),Ye(C,{children:e.children(r)})]},r))})}import{twMerge as Bi}from"tailwind-merge";import{jsx as zo,jsxs as Vi}from"react/jsx-runtime";function _o(e){let t=e.description??le,n=eo(e.column?.advanced?.cols);return Vi("div",{className:"flex w-full flex-col gap-4",children:[zo("div",{"data-slot":"column",className:Bi("grid grid-cols-1 gap-3 sm:gap-4",n),children:e.children}),e.column?.description&&zo(t,{config:e.config,context:e.context,localization:e.localization,text:e.column.description})]})}import{Fragment as Gi}from"react";import{useMemo as Ui}from"react";import{jsx as Yi}from"react/jsx-runtime";function Po(e){let{fields:t,name:n}=e.field,{index:o}=e,r=Ui(()=>Array.isArray(t)?t.map(i=>ne(i)||w(i)?{...i,name:`${n}.${o}.${i.name}`}:S(i)?{...i,fields:i.fields.map(a=>({...a,name:`${n}.${o}.${a.name}`}))}:i):[],[o,n,t]);return Yi(_,{components:e.components,config:e.config,context:e.context,disabled:e.disabled,fields:r,onValueChange:e.onValueChange,style:e.style,localization:e.localization,value:e.value,children:e.children})}import{jsx as P,jsxs as Wi}from"react/jsx-runtime";function Hi(e,t){return S(e)?`column:${e.fields.map(o=>o.name).join("|")||t}`:e.name||`slot:${t}`}function _(e){let{field:t,list:n}=e.components,o=J(e.context);return W(e.fields).map((r,i)=>Wi(Gi,{children:[S(r)&&P(_o,{column:r,config:e.config,context:e.context,description:e.components.description,localization:e.localization,children:P(_,{...e,fields:r.fields})}),ne(r)&&P(t,{disabled:e.disabled,field:r,now:o,style:e.style,localization:e.localization,children:e.children}),w(r)&&P(n,{field:r,onValueChange:e.onValueChange,localization:e.localization,value:e.value,children:a=>P(Po,{components:e.components,config:e.config,context:e.context,disabled:e.disabled,field:r,index:a,onValueChange:e.onValueChange,style:e.style,localization:e.localization,value:e.value,children:e.children})})]},Hi(r,i)))}import{jsx as Xi}from"react/jsx-runtime";function $o(e){return n=>Xi(_,{...n,components:e})}var Bo=$o({field:Io,list:Mo});import{jsx as Ge}from"react/jsx-runtime";function He(e){let t=$n(e.lang,e.translations),n={lang:e.lang,translations:t};return Ge(yo,{advanced:e.advanced,config:e.config,context:e.context,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,translations:t,children:({disabled:o,fields:r})=>Ge(Bo,{config:e.config,context:e.context,disabled:o,fields:r,localization:n,style:e.config.style,value:e.value,children:i=>Ge(No,{...i,config:e.config,context:e.context,value:e.value})})})}import{Suspense as Ki}from"react";import{jsx as Vo}from"react/jsx-runtime";function Zi(e){return Vo(Ki,{fallback:Vo(He,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{Zi as Fallback,He as Form};
1
+ import{jsx as Uo}from"react/jsx-runtime";function Xe(e){let t=typeof e.children=="function"?e.children({isPending:e.isPending}):e.children;return Uo("div",{"data-slot":"field-control",className:"w-full",children:t})}var $="input",Ke="input/date",Ze="input/email",je="input/number",qe="input/time";var Je="textarea",Qe="radio",et="checkbox",ue="list",tt="select",nt="select/active",ot="select/day",rt="select/month",it="select/timezone",at="select/year";var st="chips",lt="chips/day",ct="chips/month",E="column",dt="description",fe="fields",ut="label",me="value",B="options",ft=["yyyy-MM-dd","MM/dd/yyyy","dd/MM/yyyy","MMMM d, yyyy"],V="data-format",ge="data-mode",pe="data-reserved",ye="email",mt="number",gt="password",pt="tel",k="text",yt="aria-errormessage",bt="aria-invalid",xt="data-invalid",Tt="data-readonly",ht="aria",Rt="data",U="max",At="maxLength",Y="min",St="minLength",I="$ref";var Ft="type",Lt={Africa:"Africa",America:"Americas",Asia:"Asia / Pacific",Atlantic:"Atlantic",Australia:"Asia / Pacific",Europe:"Europe",Indian:"Asia / Pacific",Pacific:"Asia / Pacific"};import{format as Fr,formatDuration as Lr,intervalToDuration as Nr,isValid as j,parseISO as wr}from"date-fns";function d(e){return e!==null&&Object.prototype.toString.call(e)==="[object Object]"}function p(e){return c(e)||typeof e=="number"||Yo(e)}function Nt(e){return Array.isArray(e)&&e.every(p)}function c(e){return typeof e=="string"}function Yo(e){return typeof e=="boolean"}var T={error:(...e)=>{be()&&!xe()&&G().error("[Luna Form]",...e)},warn:(...e)=>{be()&&!xe()&&G().warn("[Luna Form]",...e)},info:(...e)=>{be()&&!xe()&&G().info("[Luna Form]",...e)}},be=()=>typeof G()<"u",xe=()=>typeof process<"u"&&process.env.NODE_ENV==="production",G=()=>globalThis.console;function Te(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var O={found:!1,value:void 0};function Go(e,t){if(!Array.isArray(t)&&Te(t,e))return{found:!0,value:t[e]};if(!e.includes("."))return O;let n=t;for(let o of e.split(".")){if(n==null)return O;if(Array.isArray(n)){let r=Number(o);if(!Number.isInteger(r)||!Te(n,o))return O;n=n[r]}else if(d(n)){if(!Te(n,o))return O;n=n[o]}else return O}return{found:!0,value:n}}function wt(e,t=me){if(e!=null){if(Nt(e)||p(e))return e;if(d(e)){let n=Ho(e,t);if(p(n))return n}}}function Ho(e,t){let n=m(e,t);if(p(n))return n}function m(e,t){if(!t||!e||typeof e!="object")return null;let n=Go(t,e);return n.found?n.value:null}function Dt(e,t={description:dt,label:ut,value:me}){return e.map(n=>{if(d(n)){let o=m(n,t.label),r=m(n,t.value);if(p(o)&&p(r)){let i=m(n,t.description);return{label:`${o}`,value:`${r}`,...p(i)&&{description:`${i}`}}}}return n})}function Ct(e=k){let t=e.lastIndexOf("/"),n=t===-1?e:e.slice(t+1);return n&&n!==$?n.trim().toLowerCase():k}var Wo=/^#\/(definition|context)\//,Et={};function Xo(e){return{cache:new Map,readsContext:!1,roots:e,visited:new WeakSet}}var kt=new WeakMap;function W(e=[],t,n){let o=Zo(t,n);if(!o)return It(e);let r=kt.get(e);r||(r=new WeakMap,kt.set(e,r));let i=o.definition??Et,a=r.get(i);if(a||(a={byContext:new WeakMap},r.set(i,a)),a.free!==void 0)return a.free;let s=o.context??Et,l=a.byContext.get(s);if(l!==void 0)return l;let u=Xo(o),g=It(H(e,u));return u.readsContext?a.byContext.set(s,g):a.free=g,g}function It(e){return Array.isArray(e)?e.filter(jo).sort((t,n)=>Ot(t)-Ot(n)):[]}function H(e,t){if(!e||typeof e!="object")return e;if(t.cache.has(e))return t.cache.get(e);if(t.visited.has(e))return e;if(t.visited.add(e),Array.isArray(e)){let i=!1,a=e.map(s=>{let l=H(s,t);return i||=l!==s,l});return t.visited.delete(e),t.cache.set(e,i?a:e),t.cache.get(e)}let n=F(e);if(n!==void 0){let i=Ko(n,t);return i!=null?H(i,t):e}let o={},r=!1;for(let[i,a]of Object.entries(e))o[i]=H(a,t),r||=o[i]!==a;return t.visited.delete(e),t.cache.set(e,r?o:e),t.cache.get(e)}function F(e){return d(e)&&c(e[I])?e[I]:void 0}function Ko(e,t){let n=Wo.exec(e);if(!n)return t.roots.definition?m(t.roots.definition,e):null;n[1]==="context"&&(t.readsContext=!0);let o=n[1]==="context"?t.roots.context:t.roots.definition;return o?m(o,e.slice(n[0].length)):null}function Mt(e){return Object.entries(e??{})}function Ot(e){return e.order??Number.MAX_VALUE}function Zo(e,t){let n={context:vt(t)?t:void 0,definition:vt(e)?e:void 0};return n.context||n.definition?n:null}function vt(e){return d(e)&&Object.keys(e).length>0}function jo(e){return Ft in e?!0:Array.isArray(e[fe])?e[fe].length>0:!0}import{isValid as Ae,parse as Yt,parseISO as qo,format as Gt}from"date-fns";import{enUS as Jo,es as Qo}from"date-fns/locale";var Ht=new Date(2e3,0,1),Wt=/^\d{4}-\d{2}-\d{2}$/,Se="yyyy-MM-dd",er="MMMM d, yyyy",tr=1e3,nr=()=>"supportedValuesOf"in Intl?Intl.supportedValuesOf("timeZone"):[],he="en",or=32,rr=new Map;function b(e){return e?L(rr,e,()=>ir(e),or):he}function ir(e){try{let t=Intl.getCanonicalLocales(e)[0];return t&&Intl.DateTimeFormat.supportedLocalesOf(t).length>0?t:he}catch{return he}}function Fe(e){return b(e).split("-")[0]}function Le(e){let t=b(e);return Array.from({length:12},(n,o)=>({value:(o+1).toString(),label:new Date(0,o).toLocaleString(t,{month:"long"})}))}function Ne(e){let t=b(e);return Array.from({length:7},(n,o)=>({value:o.toString(),label:new Date(2e3,0,2+o).toLocaleString(t,{weekday:"long"})}))}function Xt(e,t){return t>=e?Array.from({length:t-e+1},(n,o)=>{let r=e+o;return{value:r.toString(),label:r.toString()}}):[]}var zt=new WeakMap;function Kt(e){let t=d(e.advanced)?e.advanced:void 0,n=t??e,o=zt.get(n);if(o)return o;let r=t?.length,i={max:_t(r?.max),min:_t(r?.min)};zt.set(n,i);let a=Z(e.name,r,i,ar);for(let s of a)T.warn(s);return i}function _t(e){return typeof e=="number"&&Number.isInteger(e)?e:void 0}var Pt="the field offers no year",ar={beyond:"after",disordered:Pt,kind:"whole year",lost:Pt,needsBoth:!0};function sr(e){let t=e.indexOf("/"),n=t===-1?e:e.slice(0,t);return Lt[n]??"Other"}function lr(e,t){return(e.find(o=>o.type==="timeZoneName")?.value??t).replace(/\s+(?:Standard|Daylight(?: Saving)?|Summer|Winter)\s+Time$/,"")}var $t=new Map;function cr(e){let t=$t.get(e);if(t)return t;let n=[new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"longOffset"}),new Intl.DateTimeFormat("en",{timeZone:e,timeZoneName:"long"})];return $t.set(e,n),n}function dr(e,t){let[n,o]=cr(e),r=n.formatToParts(t),i=o.formatToParts(t),s=(r.find(u=>u.type==="timeZoneName")?.value??"GMT+00:00").replace("GMT","UTC"),l=lr(i,e);return{offset:s,longName:l}}function ur(e){return e.slice(e.lastIndexOf("/")+1).replace(/_/g," ")}var Bt=new WeakMap;function Zt(e){let t=e.advanced;if(!d(t)||t.suggested==null)return;let n=Bt.get(t);if(n)return n.zone;let o=t.suggested,r=c(o)?fr(o):void 0;return Bt.set(t,{zone:r}),r===void 0&&T.warn(ke(`${e.name}: advanced.suggested`,o,"time zone","no zone is suggested")),r}function fr(e){if(/^[A-Za-z]/.test(e))try{return new Intl.DateTimeFormat("en",{timeZone:e}).resolvedOptions().timeZone}catch{return}}var mr=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:?\d{2})$/;function K(e){if(e===void 0||!mr.test(e))return;let t=qo(e);return Ae(t)?t:void 0}var gr=8,pr=new Map;function jt(e,t){let n=K(t);return L(pr,`${e??""}|${n?.getTime()??""}`,()=>yr(e,n),gr)}function yr(e,t){let n=i=>{let a=ur(i);if(!t)return Object.freeze({value:i,label:a});let{offset:s,longName:l}=dr(i,t);return Object.freeze({value:i,label:`${a} - ${l} (${s})`})},o=new Map;for(let i of nr()){let a=sr(i);if(i===e||a==="Other")continue;let s=o.get(a);s?s.push(n(i)):o.set(a,[n(i)])}let r=Array.from(o.entries()).sort(([i],[a])=>i.localeCompare(a,"en")).map(([i,a])=>Object.freeze({label:i,items:Object.freeze(a.sort((s,l)=>s.label.localeCompare(l.label,"en")))}));return Object.freeze(e?[Object.freeze({label:"Suggested",items:Object.freeze([n(e)])}),...r]:r)}function br(e,t){let n=e.trim();if(n){if(Wt.test(n))return Vt(n,Se);for(let o of Object.values(Jt)){let r=Vt(n,t,o);if(r)return r}}}function Vt(e,t,n){try{let o=Yt(e,t,Ht,{locale:n});return Ae(o)&&o.getFullYear()>=tr?o:void 0}catch{return}}function we(e,t){let n=e?br(e,t):void 0;return n?Gt(n,Se):""}function qt(e,t){if(!e)return"";try{let n=Yt(e,t,Ht);return Ae(n)?Gt(n,"HH:mm:ss"):""}catch{return""}}var Jt={en:Jo,es:Qo};function De(e){return Jt[Fe(e)]}function Ce(e){return e.advanced?.format??"HH:mm"}function xr(e){return ft.find(t=>t===e)??er}function Qt(e){return xr(e.advanced?.format)}function Re(e){return c(e)&&Wt.test(e)&&we(e,Se)||void 0}function Tr(e){let t=new Set,n=[];return e.forEach((o,r)=>{let i=Re(o);i===void 0?n.push(r):t.add(i)}),{days:[...t].sort(),rejected:n}}var en={days:[],rejected:[]},hr={reserved:en.days,unreadable:!1},Ut=new WeakMap;function tn(e){let t=e.advanced;if(!d(t))return hr;let n=Ut.get(t);if(n)return n;let o=Array.isArray(t.reserved)?Tr(t.reserved):en,r={max:Re(t.length?.max),min:Re(t.length?.min)},i={...r,reserved:o.days,unreadable:Ee(t.length,r)||t.reserved!=null&&(!Array.isArray(t.reserved)||o.rejected.length>0)};Ut.set(t,i);let a=Rr(e.name,t,i,o.rejected);for(let s of a)T.warn(s);return i}function Ee(e,t){return e==null?!1:!d(e)||F(e)!==void 0?!0:on.some(n=>e[n]!=null&&t[n]===void 0)}function nn(e){return c(e)?[e,""]:Array.isArray(e)&&e.length<=2&&e.every(c)?[e[0]??"",e[1]??""]:void 0}var on=["min","max"];function Rr(e,t,n,o){return[...Z(e,t.length,n,Ar),...Sr(e,t.reserved,o)]}var X="the field takes no day",Ar={beyond:"after",disordered:"no day passes",kind:"yyyy-MM-dd day",lost:X,needsBoth:!1};function Z(e,t,n,o){let r=F(t);if(r!==void 0)return[`${e}: advanced.length points at ${r}, which nothing resolved, so ${o.lost}`];let i=d(t)?t:{};if(o.needsBoth&&i.min==null&&i.max==null)return[`${e}: advanced.length.min and .max are missing, so ${o.lost}`];let a=[];for(let s of on){let l=i[s];if(n[s]!==void 0||l==null&&!o.needsBoth)continue;let u=`${e}: advanced.length.${s}`;a.push(l==null?`${u} is missing, so ${o.lost}`:ke(u,l,o.kind,o.lost))}return n.min!==void 0&&n.max!==void 0&&n.min>n.max&&a.push(`${e}: advanced.length.min is ${o.beyond} advanced.length.max, so ${o.disordered}`),a}function Sr(e,t,n){if(t==null)return[];let o=`${e}: advanced.reserved`;if(!Array.isArray(t)){let r=F(t);return[r!==void 0?`${o} points at ${r}, which nothing resolved, so ${X}`:`${o} is ${JSON.stringify(t)}, which is no list of days, so ${X}`]}return n.map(r=>ke(`${o}[${r}]`,t[r],"yyyy-MM-dd day",X))}function ke(e,t,n,o){let r=F(t);return r!==void 0?`${e} points at ${r}, which nothing resolved, so ${o}`:`${e} is ${JSON.stringify(t)}, which is no ${n}, so ${o}`}function L(e,t,n,o){let r=e.get(t);if(r!==void 0)return e.delete(t),e.set(t,r),r;let i=e.keys().next().value;e.size>=o&&i!==void 0&&e.delete(i);let a=n();return e.set(t,a),a}var Dr=["short","medium","long","full"],Cr=e=>Dr.some(t=>t===e),Er={ms:1,s:1e3,min:6e4,h:36e5,d:864e5};function q(e){if(typeof e=="number"&&!Number.isNaN(e))return e;if(c(e)&&e.trim()!==""){let t=Number(e);return Number.isNaN(t)?null:t}return null}function rn(e,t,n){let o=Er[t];if(o===void 0)return String(e);let r=e*o,i=Nr({start:0,end:r});return Lr(i,{locale:De(n)})}function an(e){if(e instanceof Date)return j(e)?e:null;if(c(e)){let t=wr(e);if(j(t))return t;let n=new Date(e);return j(n)?n:null}if(typeof e=="number"){let t=new Date(e);return j(t)?t:null}return null}var sn=new WeakSet;function J(e){let t=e?.now;if(t!=null){if(c(t)&&K(t))return t;e&&!sn.has(e)&&(sn.add(e),T.warn(`context.now is ${kr(t)}, which is no ISO date, time and offset such as "2026-10-05T19:30:00-05:00", so nothing is measured from it`))}}function kr(e){return e instanceof Date?"a Date (pass its toISOString())":c(e)?JSON.stringify(e):`a ${typeof e}`}var Oe=64,Ir=new Map,Or=new Map,vr=new Map;function cn(e,t,n){let o=b(n);return L(Ir,`${o}|${t}`,()=>new Intl.DateTimeFormat(o,{dateStyle:t}),Oe).format(e)}function Ie(e,t,n={}){let o=b(t);return L(Or,`${o}|${n.style??""}|${n.currency??""}`,()=>new Intl.NumberFormat(o,n),Oe).format(e)}function ln(e,t){let n=K(t.now);return n?_r(e,n,t.locale):cn(e,"medium",t.locale)}var dn=1e3,un=60*dn,fn=60*un,mn=24*fn,gn=30.4375*mn,Mr=12*gn,zr=[["second",dn,60],["minute",un,60],["hour",fn,24],["day",mn,31],["month",gn,12]];function _r(e,t,n){let o=e.getTime()-t.getTime(),r=Math.abs(o),i=(a,s)=>{let l=b(n),u=a===0?"auto":"always";return L(vr,`${l}|${u}`,()=>new Intl.RelativeTimeFormat(l,{numeric:u}),Oe).format(o<0?-a:a,s)};for(let[a,s,l]of zr){let u=Math.round(r/s);if(u<l)return i(u,a)}return i(Math.round(r/Mr),"year")}var Pr={currency:(e,t,n)=>{let o=q(e);if(o===null)return String(e);let r=t[0]??"USD";return Ie(o,n.locale,{style:"currency",currency:r})},percent:(e,t,n)=>{let o=q(e);return o===null?String(e):Ie(o,n.locale,{style:"percent"})},number:(e,t,n)=>{let o=q(e);return o===null?String(e):Ie(o,n.locale)},date:(e,t,n)=>{let o=an(e);if(!o)return String(e);let r=t[0]??"short";return r==="relative"?ln(o,n):Cr(r)?cn(o,r,n.locale):Fr(o,r,{locale:De(n.locale)})},duration:(e,t,n)=>{if(typeof e=="number")return rn(e,t[0]??"ms",n.locale);if(c(e)){let r=q(e);if(r!==null)return rn(r,t[0]??"ms",n.locale)}let o=an(e);return o?ln(o,n):String(e)}};function pn(e,t,n){let o=t.split(":").map(s=>s.trim()).filter(s=>s.length>0);if(o.length===0)return;let[r,...i]=o,a=Pr[r];if(a)return a(e,i,n)}var $r=/\[([^\]]{1,500})\]\(([^)]{1,2000})\)/g,Br=/{([^}]{1,200})}/,Vr=/{([^}]{1,200})}/g;function Q(e,t){return{locale:e,now:J(t)}}function ve(e,t={},n={}){if(c(e))return Yr(e,t,n);if(Array.isArray(e))return e.map(o=>ve(o,t,n));if(d(e)){let o={};for(let r in e)o[r]=ve(e[r],t,n);return o}return e}function ee(e,t={},n={}){return Me(e)?ve(e,t,n):e}function Me(e){return c(e)?Br.test(e):Array.isArray(e)?e.some(t=>Me(t)):d(e)?Object.values(e).some(t=>Me(t)):!1}function Ur(e,t){return t.includes(".")?m(e,t):e[t]}function Yr(e,t={},n={}){return e.replace(Vr,(o,r)=>{let i=String(r).split("|").map(g=>g.trim()),[a,...s]=i;if(!a)return o;let l=Ur(t,a);if(s.length===0)return p(l)?String(l):o;if(l==null)return o;let u=l;for(let g of s){let We=pn(u,g,{locale:n.locale,now:n.now});if(We===void 0)return o;u=We}return String(u)})}function yn(e,t){if(!c(e)||!e||e.trim().length===0)return null;let n,o=0,r=!1,i=[];for(;(n=$r.exec(e))!==null;){let[a,s,l]=n,u=n.index;r=!0,u>o&&i.push(e.substring(o,u));let g=t?t(u,l,s):a;i.push(g),o=u+a.length}return r?(o<e.length&&i.push(e.substring(o)),i):e}var bn=e=>f(nt)(e),xn=e=>f(ot)(e),Tn=e=>f(rt)(e),hn=e=>f(at)(e),Rn=e=>f(it)(e),An=e=>f(lt)(e),Sn=e=>f(ct)(e),te=f(Ke),ze=f(qe);function _e(e){return te(e)&&e.advanced?.mode==="range"}var y=f(et),N=f(st),A=f(Qe),Fn=f($),h=f(tt),Ln=f(Je),Nn=f(k,ye,gt,pt),Na=f(Ze,ye),Pe=f(je,mt);function wn(e){return A(e)||y(e)}function w(e){return e.type===ue}function S(e){return e.type===E}function ne(e){return e.type!==E&&e.type!==ue}function $e(e){return h(e)||A(e)||N(e)}function v(e){return e!=null&&e!==""}function f(...e){return t=>{let n=c(t.type)?t.type:void 0;return n?e.some(o=>n===o||n?.startsWith(`${o}/`)):!1}}function En(e,t={}){if(h(e)&&e.disabled){let n=e.name?t?.[e.name]:void 0;if(n&&d(n))return[n]}}function kn(e){return A(e)||y(e)?!0:e.advanced?.horizontal}function In(e){return y(e)?e.advanced?.reverse!==!1:!1}function On(e,t){return!!(t||e.disabled||e.readonly)}function vn(e,t){return!!e.readonly&&!t&&!e.disabled}function Mn(e){let t=e.advanced?.step;if(typeof t=="number"&&Number.isFinite(t)&&t>0)return t}var Gr={unreadable:!1},Dn=new WeakMap;function oe(e){let t=e.advanced;if(!d(t))return Gr;let n=Dn.get(t);if(n)return n;let o=t.length,r=d(o)?o:void 0,i={max:Cn(r?.max),min:Cn(r?.min)},a={...i,unreadable:Ee(o,i)};Dn.set(t,a);let s=w(e)?Wr:Hr;for(let l of Z(e.name,o,a,s))T.warn(l);return a}function Cn(e){return typeof e=="number"&&!Number.isNaN(e)?e:void 0}var Hr={beyond:"above",disordered:"no value passes",kind:"number",lost:"the field takes no value",needsBoth:!1},Wr={beyond:"above",disordered:"no list passes",kind:"number",lost:"no list passes",needsBoth:!1};function Be(e){if(Xr(e)){let t=e.source;if(Array.isArray(t)||d(t)&&!(I in t))return t}}function zn(e){return Array.isArray(Be(e))}function Xr(e){return h(e)?!e.disabled||Array.isArray(e.source):A(e)||N(e)}var Kr={es:{"(Optional)":"(Opcional)","Add item":"A\xF1adir elemento","An unexpected error occurred submitting the form.":"Ocurri\xF3 un error inesperado al enviar el formulario.","Collapse {label} {index}":"Contraer {label} {index}","Expand {label} {index}":"Expandir {label} {index}","Please correct the errors and try again.":"Corrige los errores e int\xE9ntalo de nuevo.","Remove {label} item {index}":"Eliminar {label} {index}","There were validation errors submitting the form.":"Se encontraron errores de validaci\xF3n al enviar el formulario.","Unknown error":"Error desconocido",No:"No",Yes:"S\xED"}};function Pn(e,t){return x(e,t)}function $n(e,t){if(!e)return;let n=b(e),o=Fe(n),r=[Kr[o],t?.[o],o===n?void 0:t?.[n]].filter(i=>i!==void 0);return r.length<=1?r[0]:Object.assign({},...r)}function x(e,t){return e?t?t[e]??e:e:""}function D(e,t){return e?x(e,t):void 0}function re(e,t){if(!t)return e;let n=!1,o=e.map(r=>{let i=Zr(r,t);return i!==r&&(n=!0),i});return n?o:e}function Zr(e,t){if(!d(e))return e;let n=_n(e.label,t),o=e.items;if(Array.isArray(o)){let i=re(o,t);return i===o&&n===e.label?e:{...e,...n!==void 0&&{label:n},items:i}}let r=_n(e.description,t);return n===e.label&&r===e.description?e:{...e,...n!==void 0&&{label:n},...r!==void 0&&{description:r}}}function _n(e,t){return c(e)?x(e,t):e}function jr(e,t){if(N(e))return qr(e,t?.lang)}function qr(e,t){if(An(e))return Ne(t);if(Sn(e))return Le(t)}function Jr(e,t,n){if(h(e))return Qr(e,t,n)}function Qr(e,t,n){let{lang:o,translations:r}=t??{};if(xn(e))return Ne(o);if(Tn(e))return Le(o);if(hn(e)){let{max:i,min:a}=Kt(e);return a!==void 0&&i!==void 0?Xt(a,i):[]}if(Rn(e))return jt(Zt(e),n);if(bn(e))return re([{value:"true",label:"Yes"},{value:"false",label:"No"}],r)}function Bn(e,t=!1,n,o){let r={disabled:t,id:e.name,name:e.name,placeholder:e.placeholder,required:e.required};return Fn(e)?{...r,...ei(e,n?.lang)}:h(e)?{...r,...Vn(Jr(e,n,o))}:Ln(e)?{...r,...oi(e)}:N(e)?{...r,...ni(e,n)}:r}function ei(e,t){let n=Ct(e.type),o={...e,type:n};return{...ii(e),...ai(e,t),...Un(e),...ri(o),...ti(o),...Nn(o)?Yn(o):{},type:n}}function ti(e){let t=Mn(e);return Pe(e)&&t!==void 0?{step:t}:{}}function Vn(e){return e?{options:e}:{}}function ni(e,t){let n=Vn(jr(e,t)),o=e.advanced?.multiple??!0;return{...n,multiple:o}}function oi(e){return{...Un(e),...Yn(e)}}function Un(e){let t=e.advanced?.autocomplete;return t?{autoComplete:t}:{}}function ri(e){return Pe(e)?si(e):{}}function ii(e){if(ze(e)){let t=Ce(e),n=t==="HH:mm:ss"||t==="hh:mm:ss a";return{[V]:t,step:n?"1":"60"}}return{}}function ai(e,t){let n=Kn(e);if(!n)return{};let{max:o,min:r,reserved:i}=tn(e);return{[V]:n,...t&&{lang:t},...r!==void 0&&{[Y]:r},...o!==void 0&&{[U]:o},...i.length>0&&{[pe]:i.join(",")},..._e(e)&&{[ge]:"range"}}}function Yn(e){return Gn(e,{min:St,max:At})}function si(e){return Gn(e,{min:Y,max:U})}function Gn(e,t){let{max:n,min:o}=oe(e),r={};return o!==void 0&&(r[t.min]=o),n!==void 0&&(r[t.max]=n),r}function Hn(e,t){let n=Be(e);return n||En(e,t)}function li(e,t){let n=d(t)&&e.name in t?t[e.name]:t,o=wt(n,e.advanced?.entity),r=v(o)?o:e.defaultValue;return ze(e)&&v(r)?ci(e,r):te(e)&&v(r)?mi(e,r):r}function ci(e,t){let n=Ce(e);return c(t)?qt(t,n):t}function di(e,t,n){return $e(e)&&Array.isArray(n)?{...t,[B]:n}:t}function ui(e,t,n){if(e.required&&!v(n)&&h(e)&&e.advanced?.preselected!==!1&&B in t){let o=t[B];if(Array.isArray(o)&&o.length===1)return o[0]}return n}function fi(e,t,n){if($e(e)&&Array.isArray(t)){let o=Dt(t,e.advanced?.options);return zn(e)?re(o,n):o}return t}function Wn(e,t,n,o,r){let i=li(e,o),a=Array.isArray(n)?fi(e,n,r):n,s=di(e,t,a),l=ui(e,s,i);return{commonPropsWithOptions:s,defaultValue:l}}function Xn(e,t){return y(e)?{defaultChecked:!!t}:{defaultValue:t}}function mi(e,t){let n=Kn(e);if(!n)return t;if(_e(e)){let o=t==null||t===""?void 0:nn(t);if(!o)return t;let r=Ve(o[0],n),i=Ve(o[1],n);return Array.isArray(t)&&t[0]===r&&t[1]===i?t:[r,i]}return c(t)?Ve(t,n):t}function Ve(e,t){return we(e,t)||e}function Kn(e){return e&&te(e)?Qt(e):void 0}function Zn(e,t){let n={};for(let[o,r]of Mt(t))n[`${e}-${o}`]=r;return n}function gi(e){return Zn(ht,e)}function pi(e){return Zn(Rt,e)}function jn(e,t){let n=gi(e.advanced?.aria);return t&&t.length>0&&(n[bt]="true",n[yt]=`${e.name}-error`),n}function qn(e){return pi(e.advanced?.data)}var Jn={1:"md:grid-cols-1",2:"md:grid-cols-2",3:"md:grid-cols-3"},Qn={1:"md:col-span-1",2:"md:col-span-2",3:"md:col-span-3"};function eo(e,t=2){return Jn[e&&e in Jn?e:t]}function to(e){if(e&&e in Qn)return Qn[e]}function yi(e){let{max:t,min:n}=oe(e);return{min:n??1,max:t??1/0}}function bi(e,t){let n=t?m(t,e.name):null;return xi(e,Array.isArray(n)?n.length:0)}function no(e){return!Array.isArray(e.fields)||e.fields.length===0?!1:e.fields.length>1||e.fields[0].type===E}function oo(e,t){let n=bi(e,t);return Array.from({length:n},(o,r)=>r)}function ro(e){return e.advanced?.title??e.label??e.name}function xi(e,t){let{min:n,max:o}=yi(e);return Math.min(Math.max(t,n),o)}function ie(e,t){let n={...e};for(let o of Object.keys(t??{})){let r=t?.[o];r!==void 0&&(n[o]=r)}return n}import{jsx as Ti}from"react/jsx-runtime";function R(e){return yn(e,(t,n,o)=>Ti("a",{className:"underline",href:n,rel:"noopener noreferrer",target:"_blank",children:o},`${n}-${t}`))}import{jsx as ae,jsxs as io}from"react/jsx-runtime";function ao(e){let t=io("div",{className:"flex flex-col",children:[e.title&&ae("legend",{className:"mb-3 font-medium text-zinc-800 dark:text-zinc-200",children:R(e.title)}),e.description&&ae("p",{className:"-mt-2 text-sm leading-normal font-normal text-zinc-600 dark:text-zinc-400",children:R(e.description)})]});return e.step?io("div",{className:"flex flex-row items-start gap-4",children:[ae("div",{className:"bg-primary text-primary-foreground flex size-6 shrink-0 items-center justify-center rounded-full",children:ae("span",{className:"text-sm font-bold",children:e.step})}),t]}):t}import{jsx as so,jsxs as hi}from"react/jsx-runtime";function se(e){let t=!!(e.title||e.description||e.step);return hi("fieldset",{className:"flex w-full min-w-0 flex-col data-[empty=false]:gap-6","data-empty":e.empty,"data-slot":"field-set",id:e.id,children:[t&&so(ao,{description:e.description,step:e.step,title:e.title}),so("div",{className:"w-full min-w-0",children:e.children})]})}import{jsx as Ri}from"react/jsx-runtime";function C(e){return Ri("div",{"data-slot":"field-group","data-compact":e.compact,className:"flex w-full flex-col gap-8 data-[compact=true]:gap-3",children:e.children})}import{jsx as M,jsxs as lo}from"react/jsx-runtime";function co(e){let{fields:t=[]}=e.section,n=e.advanced?.step?e.step:void 0,{compact:o}=ie(e.style,{compact:e.section.advanced?.compact}),r=M(C,{compact:o,children:e.children});if(!e.section.title&&!e.section.description)return r;let i=D(e.section.title,e.translations),a=D(e.section.description,e.translations);return e.section.advanced?.collapsible?lo("fieldset",{"data-slot":"field-set","data-advanced":"true","data-expanded":!0,"data-empty":t.length===0,className:"flex flex-col",id:e.section.id?.toString(),children:[M("legend",{children:M("span",{className:"flex items-center gap-2 text-base font-medium text-zinc-600 dark:text-zinc-400",children:R(i)})}),lo("div",{className:"mt-3 ml-1.5 flex flex-col gap-4 border-l-2 border-zinc-300 pl-4 dark:border-zinc-600","data-slot":"field-set-content",children:[a&&M("p",{className:"text-sm leading-normal font-normal text-zinc-600 dark:text-zinc-400",children:R(a)}),r]})]}):M(se,{description:a,empty:t.length===0,id:e.section.id?.toString(),step:n,title:i,children:r})}import{jsx as uo}from"react/jsx-runtime";function fo(){return uo("div",{"data-slot":"field-separator",className:"relative -my-2 h-5 text-sm",children:uo("div",{className:"absolute inset-0 top-1/2 h-px w-full bg-zinc-200 dark:bg-zinc-800"})})}function Ai(e,t){return e.fields.every(n=>mo(n,t))}function mo(e,t){return t[e.name]?.hidden??e.hidden??!1}function Si(e,t){return S(e)?Ai(e,t):mo(e,t)}function go(e,t,n){return n&&(e[n.name]?.hidden??n.hidden??!1)||t.length===0?!0:t.every(o=>Si(o,e))}import{jsx as z,jsxs as po}from"react/jsx-runtime";function Fi(e){return go({},e.fields)?null:e.children}function yo(e){let t=W(e.sections,e.definition,e.context),n=e.guard??Fi,o=e.fieldSet??co;return z("div",{className:"h-full w-full",children:z("form",{noValidate:e.noValidate,action:e.action,onSubmit:e.onSubmit,children:po(C,{children:[t.map((r,i)=>po(n,{fields:r.fields??[],children:[z(o,{advanced:e.advanced,section:r,step:i+1,style:e.config.style,translations:e.translations,children:e.children({disabled:e.readOnly,fields:r.fields})}),r.advanced?.separator&&z(fo,{})]},`key-${r.id}-${i}`)),e.control&&z(Xe,{isPending:e.isPending,children:e.control})]})})})}import{twMerge as Li}from"tailwind-merge";import{jsx as bo,jsxs as Ni}from"react/jsx-runtime";function xo(e){let t=e.style?.showOptionalLabel??!0,n=A(e.field)||y(e.field);return Ni("label",{"data-slot":"field-label","data-normal":n,className:Li("flex w-fit items-center text-sm leading-snug font-medium select-none","data-[normal=true]:font-normal [[data-slot=column]_&]:md:w-full","group-data-[readonly=true]:cursor-not-allowed group-data-[readonly=true]:opacity-50"),htmlFor:e.field.name,title:c(e.children)?e.children:void 0,children:[bo("span",{className:"[[data-slot=column]_&]:md:truncate",children:e.children}),t&&!e.field.required&&bo("span",{className:"ml-2 flex-shrink-0 text-sm text-zinc-600 dark:text-zinc-400",children:Pn("(Optional)",e.translations)})]})}import{jsx as To}from"react/jsx-runtime";function wi(e){return To("p",{className:"-mt-2 text-xs leading-normal font-normal text-zinc-600 dark:text-zinc-400 [[data-slot=column]_&]:md:line-clamp-2",title:e.title,children:e.children})}function le(e){let t=c(e.text)?e.text:e.text?.message;if(!t)return null;let n=ee(t,{context:e.context,env:e.config?.env},Q(e.localization?.lang,e.context));return To(wi,{title:c(e.text)?void 0:e.text?.title,children:R(x(n,e.localization?.translations))})}import{jsx as Di}from"react/jsx-runtime";function ce(e){return Di(le,{config:e.config,context:e.context,localization:e.localization,text:e.field.description})}import{jsx as ho,jsxs as Ci}from"react/jsx-runtime";function Ro(e){let t=e.description??ce,n={context:e.context,env:e.config?.env},o=ee(e.field.label,n,Q(e.localization?.lang,e.context));return Ci("div",{"data-slot":"field-content",className:"flex w-full flex-1 flex-col gap-1.5 leading-snug",children:[ho(xo,{field:e.field,style:e.config?.style,translations:e.localization?.translations,children:x(o,e.localization?.translations)}),e.horizontal===!0&&ho(t,{config:e.config,context:e.context,field:e.field,localization:e.localization})]})}import{Fragment as Ei,jsx as Ao,jsxs as ki}from"react/jsx-runtime";function So(e){let t=e.description??ce;return ki(Ei,{children:[e.field.name&&e.field.label&&Ao(Ro,{config:e.config,context:e.context,description:e.description,field:e.field,horizontal:e.horizontal,localization:e.localization}),e.children,e.horizontal===!1&&Ao(t,{config:e.config,context:e.context,field:e.field,localization:e.localization})]})}function Fo(e,t){return e?t(e):null}import{jsx as Lo}from"react/jsx-runtime";function No(e){let t=Hn(e.field,e.value),{commonPropsWithOptions:n,defaultValue:o}=Wn(e.field,e.commonProps,t,e.value,e.localization?.translations),r=Xn(e.field,o);return Fo(e.config.inputs[e.field.type],i=>Lo(So,{config:e.config,context:e.context,field:e.field,horizontal:e.horizontal,localization:e.localization,children:Lo(i,{...e.dataAttributes,...n,...e.ariaAttributes,...r})}))}import{twMerge as Ii}from"tailwind-merge";import{jsx as Oi}from"react/jsx-runtime";function de(e){let t=e.errors&&e.errors.length>0;return Oi("div",{"data-slot":"field","data-clickable":e.isClickable?"true":"false",...t&&{[xt]:"true"},...e.disabled&&{[Tt]:"true"},"data-orientation":e.orientation,className:Ii("group flex w-full flex-col items-center data-[invalid=true]:text-red-600 data-[invalid=true]:dark:text-red-500","data-[clickable=true]:items-start",e.isCheckbox&&(e.isReversed?"flex-row-reverse!":"flex-row!"),"data-[clickable=true]:has-[>[data-slot=field-content]]:[&>:first-child]:mt-px",e.className),children:e.children})}import{twMerge as vi}from"tailwind-merge";import{jsx as Mi}from"react/jsx-runtime";function wo(e){return Mi(de,{...e,orientation:"vertical",className:vi("gap-3 has-[>[data-slot=field-content]]:items-start",!e.isClickable&&"[&>*]:w-full"),children:e.children})}import{twMerge as zi}from"tailwind-merge";import{jsx as _i}from"react/jsx-runtime";function Do(e){return _i(de,{...e,orientation:"horizontal",className:zi("gap-2 md:flex-row md:gap-4","[&>[data-slot=field-content]]:min-w-0 [&>[data-slot=field-content]]:flex-grow [&>[data-slot=field-content]]:self-start","[&_[role=checkbox]]:mt-[1.5px]",e.isClickable&&"md:flex-col",!e.isClickable&&["md:justify-between","[&>*:not([data-slot=field-content])]:w-full","[&>*:not([data-slot=field-content])]:md:w-1/2","[&>*:not([data-slot=field-content])]:xl:w-2/5"]),children:e.children})}import{jsx as Co}from"react/jsx-runtime";function Eo(e){let t=wn(e.field),n=y(e.field),o=In(e.field);return e.horizontal?Co(Do,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children}):Co(wo,{disabled:e.disabled,errors:e.errors,isCheckbox:n,isReversed:o,isClickable:t,children:e.children})}function ko(e){if(!e.field.type)return null;let t=Bn(e.field,e.disabled,e.localization,e.now),n=qn(e.field),o=jn(e.field,e.errors),r=!!e.field.disabled===t.disabled?e.field:{...e.field,disabled:t.disabled};return e.children({ariaAttributes:o,commonProps:t,dataAttributes:n,field:r,horizontal:e.horizontal,localization:e.localization,readOnly:e.readOnly})}import{twMerge as Pi}from"tailwind-merge";import{jsx as Ue}from"react/jsx-runtime";function Io(e){let t=e.field.advanced?.cols,{horizontal:n=!1}=ie(e.style,{horizontal:kn(e.field)}),o=On(e.field,e.disabled),r=vn(e.field,e.disabled);return Ue("div",{className:Pi("flex flex-col gap-3",to(t)),children:Ue(Eo,{disabled:o,field:e.field,horizontal:n,children:Ue(ko,{disabled:o,field:e.field,horizontal:n,localization:e.localization,now:e.now,readOnly:r,children:e.children})})})}import{jsx as $i}from"react/jsx-runtime";function Oo(e){let t=Array.isArray(e.field.fields)&&e.field.fields.length===0,n=D(e.field.label,e.translations),o=D(e.field.description,e.translations);return $i(se,{description:o,empty:t,id:e.field.name,title:n,children:e.children})}import{jsx as Ye,jsxs as vo}from"react/jsx-runtime";function Mo(e){let t=e.localization?.translations,n=x(ro(e.field),t),o=no(e.field);return Ye(Oo,{field:e.field,translations:t,children:oo(e.field,e.value).map(r=>vo("div",{"data-slot":o?"list-item-card":void 0,className:o?"box-border w-full min-w-0 rounded-lg border border-zinc-100 p-4 dark:border-zinc-900":"box-border flex w-full min-w-0 flex-col gap-2",children:[o&&Ye("div",{className:"flex min-w-0 flex-col font-medium text-zinc-700 dark:text-zinc-400",children:vo("span",{className:"text-base",children:[n," ",r+1]})}),Ye(C,{children:e.children(r)})]},r))})}import{twMerge as Bi}from"tailwind-merge";import{jsx as zo,jsxs as Vi}from"react/jsx-runtime";function _o(e){let t=e.description??le,n=eo(e.column?.advanced?.cols);return Vi("div",{className:"flex w-full flex-col gap-4 has-[>[data-slot=column]:empty]:hidden",children:[zo("div",{"data-slot":"column",className:Bi("grid grid-cols-1 gap-3 sm:gap-4",n),children:e.children}),e.column?.description&&zo(t,{config:e.config,context:e.context,localization:e.localization,text:e.column.description})]})}import{Fragment as Gi}from"react";import{useMemo as Ui}from"react";import{jsx as Yi}from"react/jsx-runtime";function Po(e){let{fields:t,name:n}=e.field,{index:o}=e,r=Ui(()=>Array.isArray(t)?t.map(i=>ne(i)||w(i)?{...i,name:`${n}.${o}.${i.name}`}:S(i)?{...i,fields:i.fields.map(a=>({...a,name:`${n}.${o}.${a.name}`}))}:i):[],[o,n,t]);return Yi(_,{components:e.components,config:e.config,context:e.context,disabled:e.disabled,fields:r,onValueChange:e.onValueChange,style:e.style,localization:e.localization,value:e.value,children:e.children})}import{jsx as P,jsxs as Wi}from"react/jsx-runtime";function Hi(e,t){return S(e)?`column:${e.fields.map(o=>o.name).join("|")||t}`:e.name||`slot:${t}`}function _(e){let{field:t,list:n}=e.components,o=J(e.context);return W(e.fields).map((r,i)=>Wi(Gi,{children:[S(r)&&P(_o,{column:r,config:e.config,context:e.context,description:e.components.description,localization:e.localization,children:P(_,{...e,fields:r.fields})}),ne(r)&&P(t,{disabled:e.disabled,field:r,now:o,style:e.style,localization:e.localization,children:e.children}),w(r)&&P(n,{field:r,onValueChange:e.onValueChange,localization:e.localization,value:e.value,children:a=>P(Po,{components:e.components,config:e.config,context:e.context,disabled:e.disabled,field:r,index:a,onValueChange:e.onValueChange,style:e.style,localization:e.localization,value:e.value,children:e.children})})]},Hi(r,i)))}import{jsx as Xi}from"react/jsx-runtime";function $o(e){return n=>Xi(_,{...n,components:e})}var Bo=$o({field:Io,list:Mo});import{jsx as Ge}from"react/jsx-runtime";function He(e){let t=$n(e.lang,e.translations),n={lang:e.lang,translations:t};return Ge(yo,{advanced:e.advanced,config:e.config,context:e.context,control:e.children,definition:e.definition,readOnly:e.readOnly,sections:e.sections,translations:t,children:({disabled:o,fields:r})=>Ge(Bo,{config:e.config,context:e.context,disabled:o,fields:r,localization:n,style:e.config.style,value:e.value,children:i=>Ge(No,{...i,config:e.config,context:e.context,value:e.value})})})}import{Suspense as Ki}from"react";import{jsx as Vo}from"react/jsx-runtime";function Zi(e){return Vo(Ki,{fallback:Vo(He,{config:e.config,sections:e.sections,readOnly:!0}),children:e.children})}export{Zi as Fallback,He as Form};
@@ -44,6 +44,14 @@ export type Option = {
44
44
  export type PreviewItem = string | {
45
45
  field?: string;
46
46
  label?: string;
47
+ /**
48
+ * Where `field` is read from. Left out, it names a leaf of the row being
49
+ * previewed. `parent` reads it from the row that holds the list instead,
50
+ * one level up: a nested list's rows can then say which outer row they
51
+ * belong to, such as the section a question sits in. A top-level list has
52
+ * no row above it, so the entry is left out of the preview.
53
+ */
54
+ scope?: 'parent';
47
55
  when?: string | string[] | Condition;
48
56
  };
49
57
  export type List = {
@@ -51,6 +59,14 @@ export type List = {
51
59
  title?: string;
52
60
  action?: string;
53
61
  collapsed?: boolean;
62
+ /**
63
+ * Whether the list keeps the rows it has: no add button and no remove
64
+ * control, while every row stays editable. For a list whose rows are
65
+ * created somewhere else and only corrected here. It says nothing about
66
+ * how many rows are valid -- that is still `length`, read the same way by
67
+ * the schema -- so the rows a list opens with are still clamped to `min`.
68
+ */
69
+ fixed?: boolean;
54
70
  /**
55
71
  * Whether hiding this list leaves the values behind instead of taking
56
72
  * them. See `Field`'s, which this one is a statement about: a list holds
@@ -23,6 +23,7 @@ export declare function useInputCore(props: InputCoreProps, deps: Readonly<{
23
23
  value: unknown;
24
24
  }>): {
25
25
  readonly applyChangeEventsRef: import("react").RefObject<(selected: unknown) => void>;
26
+ readonly applyStateEventsRef: import("react").RefObject<(selected: unknown) => void>;
26
27
  readonly commonProps: {
27
28
  placeholder: string;
28
29
  disabled?: boolean;
@@ -1,6 +1,9 @@
1
- import { type Field } from '../../../../luna-core/index';
1
+ import { type Field, type Nullable } from '../../../../luna-core/index';
2
2
  export declare function useValue(field: Field): {
3
3
  readonly setValue: (next: unknown) => void;
4
4
  readonly shouldSkipOnChange: () => boolean;
5
+ readonly takeHostChange: () => Nullable<{
6
+ value: unknown;
7
+ }>;
5
8
  readonly value: {} | undefined;
6
9
  };
@@ -421,6 +421,25 @@ Two details:
421
421
  A field that mounts empty and has no `defaultValue` does not run anything until
422
422
  it is edited.
423
423
 
424
+ ## When the host changes a value
425
+
426
+ A host that holds the values can change one after mount without the user
427
+ touching the field: an undo, a reset, a record swapped underneath the form.
428
+ The field shows the new value, and its **`state` rules run again** on it, so
429
+ what they reveal, hide, disable or describe follows the value whoever wrote it.
430
+ Undoing a switch from one choice to another brings back the fields of the first
431
+ choice, not those of the second.
432
+
433
+ - **Only `state`.** A `value` action would write into a host that has just said
434
+ what every field holds, and a `source` fetches for a choice the user made, so
435
+ neither runs.
436
+ - **Not for an echo.** A value the host hands back after the field reported it
437
+ is one the field already holds, and nothing runs again.
438
+ - **A value emptied from outside** undoes the rules as if the field held
439
+ nothing: what it revealed is hidden again. A hidden target is cleared and
440
+ reported as usual, but a target that holds nothing is not announced, so a
441
+ host putting back values it already holds is told nothing.
442
+
424
443
  ## Sequencing Actions
425
444
 
426
445
  Because `change` takes an array, multiple different events can be sequenced together to build complex logic flows.
@@ -28,6 +28,8 @@ The `advanced` property customizes structural interaction rules and layout rende
28
28
  Each bound is a number, or a `$ref` the host resolves to one. A bound that is not, such as a `$ref` the context does not hold, is a rule the form cannot read: the list is held back with `This list cannot be checked`, an empty one included, since a list has no `required` of its own and `length.min` is how it asks for rows. Meanwhile it shows its rows as if that bound were not declared, a `min` of one or no `max` at all, and a development build names the bound in the console, as it does [for a field](input.md#a-bound-that-is-no-number).
29
29
  - **`collapsed`** _(boolean)_: When enabled, list items default to a visually collapsed representation upon mounting or adding.
30
30
  Collapsing only hides a row: its fields keep their values, still validate and are still submitted, and a submit that fails on one of them opens the row so the error can be seen.
31
+ - **`fixed`** _(boolean)_: The list keeps the rows it has. It renders no add button and no remove control, and every row stays editable. Reach for it when the rows are created somewhere else and this form only corrects them.
32
+ It says nothing about how many rows are valid: that is still `length`, read the same way by the schema, and the rows a list opens with are still clamped to `min`. A fixed list that opens with no rows needs `"length": { "min": 0 }`, or it opens with an empty one it cannot remove.
31
33
  - **`keepValue`** _(boolean)_: If `true`, hiding the list leaves the values behind instead of taking them. A list holds nothing under its own name, so declaring it here is a statement about the rows: it covers every value they hold. See [Keeping a value through a hide](../events/change.md#keeping-a-value-through-a-hide).
32
34
 
33
35
  ### Collapsed Previews (`preview` object)
@@ -43,6 +45,7 @@ Previews can map seamlessly pointing out the desired child `name` simply as stri
43
45
 
44
46
  - **`field`** _(string)_: The child layout field name.
45
47
  - **`label`** _(string)_: Provides contextual prefix naming before mapping the preview value statically.
48
+ - **`scope`** _(`"parent"`)_: Reads `field` from the row that holds this list rather than from the row being previewed, one level up. A nested list's rows can then name the outer row they belong to, such as the section a question sits in. In a top-level list there is no row above, and the entry is left out of the preview.
46
49
  - **`when`** _(string | string[] | Condition)_: Standard complex logical operators dictating runtime evaluation rules. When an **array** is provided, it performs an **OR match** against the field's current value.
47
50
 
48
51
  ---
package/docs/setup.md CHANGED
@@ -17,7 +17,7 @@ dependency, so your application resolves one copy of React, Zod and the rest.
17
17
  | -------------------- | --------- | ------------------------------------------- |
18
18
  | `react`, `react-dom` | `^19.0.0` | rendering, and `useActionState` on submit |
19
19
  | `zod` | `^4.0.6` | the schema derived from `sections` |
20
- | `jotai` | `^2.0.0` | the value, error and source stores |
20
+ | `jotai` | `^3.0.0` | the value, error and source stores |
21
21
  | `swr` | `^2.0.0` | fetching a field's remote `source` |
22
22
  | `date-fns` | `^4.0.0` | date and time formatting, `duration` filter |
23
23
  | `fast-equals` | `^6.0.0` | change detection in the stores |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-luna-form",
3
- "version": "0.0.89",
3
+ "version": "0.0.91",
4
4
  "description": "A React library for building forms based on JSON",
5
5
  "main": "./dist/client/cjs/index.js",
6
6
  "module": "./dist/client/esm/index.js",
@@ -21,15 +21,15 @@
21
21
  "peerDependencies": {
22
22
  "date-fns": "^4.0.0",
23
23
  "fast-equals": "^6.0.0",
24
- "jotai": "^2.0.0",
24
+ "jotai": "^3.0.0",
25
25
  "react": "^19.0.0",
26
26
  "react-dom": "^19.0.0",
27
27
  "swr": "^2.0.0",
28
- "tailwind-merge": "^3.7.0",
29
- "zod": "^4.0.6"
28
+ "tailwind-merge": "^3.0.0",
29
+ "zod": "^4.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@luna-form/core": "0.0.89",
32
+ "@luna-form/core": "0.0.91",
33
33
  "@types/react": "19.3.0",
34
34
  "@types/react-dom": "19.3.0",
35
35
  "eslint-plugin-react": "7.37.5",
@@ -1,28 +0,0 @@
1
- /**
2
- * What an authored pattern can do to the thread that runs it.
3
- *
4
- * A pattern that can split the same text between its repetitions in more than
5
- * one way backtracks exponentially on a value that almost matches: `^(a+)+$`
6
- * holds the thread for seconds on thirty characters, a tab's or a server's.
7
- * Only the ambiguity is dangerous. `^[a-z]+(-[a-z]+)*$` repeats a group with a
8
- * quantifier inside it as well, and runs in linear time, because every
9
- * repetition opens with a `-` that the one before cannot close with.
10
- *
11
- * So the question asked of each repeated group is not whether it nests a
12
- * quantifier but whether its repetitions can overlap: whether the group can
13
- * open with a character it can also close with, and then either holds an
14
- * unbounded quantifier or offers alternatives that open alike. That is
15
- * `(a+)+`, `(\w+\s?)+` and `(a|a)+`, and not `(-[a-z]+)*`, `(,\d+)*` or
16
- * `(ab+c)+`.
17
- *
18
- * It is a reading of the source, not a proof. Characters are reasoned about as
19
- * ASCII, with everything beyond it counted as one more symbol, and what the
20
- * reader cannot tell apart it reads as any character: it would rather refuse
21
- * a safe pattern than run a catastrophic one. Quadratic patterns are not its
22
- * concern; they need very long values to hurt.
23
- *
24
- * Every term works out what it can open and close with as it is read, once,
25
- * so reading a pattern costs time in proportion to its length, however it
26
- * nests.
27
- */
28
- export declare function backtracksCatastrophically(source: string, flags?: string): boolean;