reactaform 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/reactaform.cjs.js +6 -6
- package/dist/reactaform.css +1 -1
- package/dist/reactaform.es.js +1568 -1445
- package/package.json +2 -1
package/dist/reactaform.cjs.js
CHANGED
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
line-height: 1.4;\r
|
|
139
139
|
min-width: 100px;\r
|
|
140
140
|
color: var(--reactaform-text-color);\r
|
|
141
|
-
font-weight:
|
|
141
|
+
font-weight: 600;\r
|
|
142
142
|
font-size: var(--reactaform-font-size);\r
|
|
143
143
|
user-select: none;\r
|
|
144
144
|
}\r
|
|
@@ -284,14 +284,14 @@
|
|
|
284
284
|
\r
|
|
285
285
|
\r
|
|
286
286
|
}\r
|
|
287
|
-
`;var me={exports:{}},ce={};var
|
|
287
|
+
`;var me={exports:{}},ce={};var Ve;function vr(){if(Ve)return ce;Ve=1;var e=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(a,t,o){var i=null;if(o!==void 0&&(i=""+o),t.key!==void 0&&(i=""+t.key),"key"in t){o={};for(var c in t)c!=="key"&&(o[c]=t[c])}else o=t;return t=o.ref,{$$typeof:e,type:a,key:i,ref:t!==void 0?t:null,props:o}}return ce.Fragment=r,ce.jsx=n,ce.jsxs=n,ce}var le={};var ze;function wr(){return ze||(ze=1,process.env.NODE_ENV!=="production"&&(function(){function e(b){if(b==null)return null;if(typeof b=="function")return b.$$typeof===M?null:b.displayName||b.name||null;if(typeof b=="string")return b;switch(b){case x:return"Fragment";case v:return"Profiler";case R:return"StrictMode";case S:return"Suspense";case N:return"SuspenseList";case F:return"Activity"}if(typeof b=="object")switch(typeof b.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),b.$$typeof){case p:return"Portal";case k:return b.displayName||"Context";case E:return(b._context.displayName||"Context")+".Consumer";case w:var C=b.render;return b=b.displayName,b||(b=C.displayName||C.name||"",b=b!==""?"ForwardRef("+b+")":"ForwardRef"),b;case I:return C=b.displayName||null,C!==null?C:e(b.type)||"Memo";case j:C=b._payload,b=b._init;try{return e(b(C))}catch{}}return null}function r(b){return""+b}function n(b){try{r(b);var C=!1}catch{C=!0}if(C){C=console;var O=C.error,H=typeof Symbol=="function"&&Symbol.toStringTag&&b[Symbol.toStringTag]||b.constructor.name||"Object";return O.call(C,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",H),r(b)}}function a(b){if(b===x)return"<>";if(typeof b=="object"&&b!==null&&b.$$typeof===j)return"<...>";try{var C=e(b);return C?"<"+C+">":"<...>"}catch{return"<...>"}}function t(){var b=z.A;return b===null?null:b.getOwner()}function o(){return Error("react-stack-top-frame")}function i(b){if(B.call(b,"key")){var C=Object.getOwnPropertyDescriptor(b,"key").get;if(C&&C.isReactWarning)return!1}return b.key!==void 0}function c(b,C){function O(){oe||(oe=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",C))}O.isReactWarning=!0,Object.defineProperty(b,"key",{get:O,configurable:!0})}function m(){var b=e(this.type);return J[b]||(J[b]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),b=this.props.ref,b!==void 0?b:null}function d(b,C,O,H,X,re){var L=O.ref;return b={$$typeof:y,type:b,key:C,props:O,_owner:H},(L!==void 0?L:null)!==null?Object.defineProperty(b,"ref",{enumerable:!1,get:m}):Object.defineProperty(b,"ref",{enumerable:!1,value:null}),b._store={},Object.defineProperty(b._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(b,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(b,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:X}),Object.defineProperty(b,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:re}),Object.freeze&&(Object.freeze(b.props),Object.freeze(b)),b}function u(b,C,O,H,X,re){var L=C.children;if(L!==void 0)if(H)if(Q(L)){for(H=0;H<L.length;H++)f(L[H]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(L);if(B.call(C,"key")){L=e(b);var $=Object.keys(C).filter(function(W){return W!=="key"});H=0<$.length?"{key: someKey, "+$.join(": ..., ")+": ...}":"{key: someKey}",V[L+H]||($=0<$.length?"{"+$.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
288
288
|
let props = %s;
|
|
289
289
|
<%s {...props} />
|
|
290
290
|
React keys must be passed directly to JSX without using spread:
|
|
291
291
|
let props = %s;
|
|
292
|
-
<%s key={someKey} {...props} />`,B,T,O,T),M[T+B]=!0)}if(T=null,P!==void 0&&(n(P),T=""+P),i(j)&&(n(j.key),T=""+j.key),"key"in j){P={};for(var L in j)L!=="key"&&(P[L]=j[L])}else P=j;return T&&c(P,typeof b=="function"?b.displayName||b.name||"Unknown":b),m(b,T,P,t(),Z,ee)}function g(b){l(b)?b._store&&(b._store.validated=1):typeof b=="object"&&b!==null&&b.$$typeof===N&&(b._payload.status==="fulfilled"?l(b._payload.value)&&b._payload.value._store&&(b._payload.value._store.validated=1):b._store&&(b._store.validated=1))}function l(b){return typeof b=="object"&&b!==null&&b.$$typeof===y}var p=s,y=Symbol.for("react.transitional.element"),d=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),E=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),k=Symbol.for("react.suspense_list"),C=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),A=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),D=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,U=Object.prototype.hasOwnProperty,ne=Array.isArray,K=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(b){return b()}};var ae,J={},Q=p.react_stack_bottom_frame.bind(p,a)(),z=K(o(a)),M={};le.Fragment=x,le.jsx=function(b,j,P){var B=1e4>D.recentlyCreatedOwnerStacks++;return u(b,j,P,!1,B?Error("react-stack-top-frame"):Q,B?K(o(b)):z)},le.jsxs=function(b,j,P){var B=1e4>D.recentlyCreatedOwnerStacks++;return u(b,j,P,!0,B?Error("react-stack-top-frame"):Q,B?K(o(b)):z)}})()),le}var Te;function Sr(){return Te||(Te=1,process.env.NODE_ENV==="production"?me.exports=vr():me.exports=wr()),me.exports}var h=Sr();const ke=s.createContext(void 0),V=()=>{const e=s.useContext(ke);if(!e)throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");return e};class ge{map={};register(r,n){this.map[r]=n}get(r){return this.map[r]}has(r){return r in this.map}list(){return Object.keys(this.map)}entries(){return Object.entries(this.map)}values(){return Object.values(this.map)}size(){return Object.keys(this.map).length}unregister(r){return r in this.map?(delete this.map[r],!0):!1}clear(){this.map={}}registerAll(r){Array.isArray(r)?r.forEach(([n,o])=>this.register(n,o)):Object.entries(r).forEach(([n,o])=>this.register(n,o))}getOrDefault(r,n){return this.get(r)??n}}function Je(e,r=300,n){const o=s.useRef(void 0),t=s.useRef(e),a=s.useRef(null),i=s.useRef(!1);s.useEffect(()=>{t.current=e},[e]),s.useEffect(()=>()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0)},[]);const c=s.useCallback(()=>{o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),a.current=null,i.current=!1},[]),f=s.useCallback(()=>{if(o.current!==void 0&&(window.clearTimeout(o.current),o.current=void 0),a.current)try{t.current(...a.current)}finally{a.current=null,i.current=!1}},[]);return{callback:s.useCallback((...u)=>{if(n?.leading===!0&&!i.current){i.current=!0,t.current(...u),window.clearTimeout(o.current),o.current=window.setTimeout(()=>{i.current=!1,o.current=void 0},r);return}a.current=u,window.clearTimeout(o.current),o.current=window.setTimeout(()=>{o.current=void 0,a.current&&(t.current(...a.current),a.current=null,i.current=!1)},r)},[r,n?.leading]),cancel:c,flush:f}}const F={field:"reactaform-field",label:"reactaform-label",input:"reactaform-input",textInput:"reactaform-input--text",inputNumber:"reactaform-input--number",inputSelect:"reactaform-select",rangeInput:"reactaform-input--range",button:"reactaform-button"},W=(...e)=>{const r=[];for(const n of e)n&&(typeof n=="string"?r.push(n):typeof n=="object"&&Object.entries(n).forEach(([o,t])=>{t&&r.push(o)}));return r.join(" ")},Ge=({content:e,size:r="medium",animation:n=!0})=>{const{t:o,darkMode:t,formStyle:a,fieldStyle:i}=V(),[c,f]=s.useState(!1),[m,u]=s.useState({x:0,y:0}),[g,l]=s.useState(!1),p=s.useRef(null),y=s.useRef(null),d=s.useRef(null),x=s.useMemo(()=>{const E={icon:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.2em",height:"1.2em",fontSize:"0.9em",fontWeight:"bold",borderRadius:"50%",backgroundColor:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.06)",color:t?"#f0f0f0":"#333",border:`1px solid ${t?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.1)"}`,cursor:"pointer",transition:n?"all 0.2s ease":void 0,marginLeft:"0.3em"},text:{...{small:{padding:"4px 8px",fontSize:"11px",maxWidth:"200px"},medium:{padding:"6px 10px",fontSize:"12px",maxWidth:"240px"},large:{padding:"8px 12px",fontSize:"13px",maxWidth:"280px"}}[r],position:"absolute",backgroundColor:`var(--reactaform-tooltip-color-bg, ${t?"rgba(45,45,45,0.95)":"rgba(60,60,60,0.92)"})`,color:`var(--reactaform-tooltip-color, ${t?"#f0f0f0":"#fff"})`,borderRadius:"6px",border:`1px solid ${t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"}`,boxShadow:t?"0 8px 16px rgba(0,0,0,0.4)":"0 6px 18px rgba(0,0,0,0.12)",zIndex:2147483647,opacity:0,visibility:"hidden",transition:n?"opacity 0.2s ease, visibility 0.2s ease":void 0,pointerEvents:"none",whiteSpace:"normal",wordBreak:"break-word",boxSizing:"border-box"},textVisible:{opacity:1,visibility:"visible"}},S=(k,C,N)=>{const $=k?.[C];return(N&&$?$[N]:void 0)??{}};return{icon:{...E.icon,...S(a,"tooltip","icon"),...S(i,"tooltip","icon")},text:{...E.text,...S(a,"tooltip","text"),...S(i,"tooltip","text")},textVisible:E.textVisible}},[t,r,n,a,i]);s.useEffect(()=>{if(c){const I=requestAnimationFrame(()=>l(!1)),E=requestAnimationFrame(()=>{if(p.current){const S=p.current.getBoundingClientRect(),R=8;d.current=S;const k=S.right+R,C=S.top;u({x:k,y:C}),l(!0)}});return()=>{cancelAnimationFrame(E),cancelAnimationFrame(I)}}else requestAnimationFrame(()=>l(!1))},[c]),s.useEffect(()=>{if(!g)return;const I=requestAnimationFrame(()=>{if(!y.current)return;const E=y.current.getBoundingClientRect(),S=8,R=typeof window<"u"?window.innerWidth:1024,k=typeof window<"u"?window.innerHeight:768;let C=m.x,N=m.y;const A=d.current;A&&(C=A.right+S,N=A.top+A.height/2-E.height/2+-4,C+E.width>R-S&&(C=A.left-S-E.width)),C+E.width>R-S&&(C=Math.max(S,R-E.width-S)),C<S&&(C=S),N+E.height>k-S&&(N=Math.max(S,k-E.height-S)),N<S&&(N=S),(C!==m.x||N!==m.y)&&u({x:C,y:N})});return()=>cancelAnimationFrame(I)},[g,m.x,m.y]);const v=typeof document<"u"?document.getElementById("popup-root"):null,w=h.jsx("div",{ref:y,style:{...x.text,transform:g?"translateY(0) scale(1)":"translateY(-4px) scale(0.98)",transition:"opacity 120ms ease, transform 120ms ease, visibility 120ms ease",width:240,...g?x.textVisible:{},top:m.y,left:m.x},"data-reactaform-theme":t?"dark":"light",children:o(e)});return h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-testid":"tooltip-icon",ref:p,onMouseEnter:()=>f(!0),onMouseLeave:()=>f(!1),style:{...x.icon},children:"?"}),c&&(v?je.createPortal(w,v):w)]})},ve=s.memo(({field:e,error:r,children:n,showLabel:o=!0})=>{const{t}=V(),a=e?.labelLayout==="column-center"?"center":"left";return h.jsxs("div",{className:`${F.field} column-layout`,style:{display:"flex",flexDirection:"column",gap:"var(--reactaform-label-gap, 4px)","--label-align":a},children:[o&&h.jsx("div",{style:{textAlign:a,width:"100%"},children:h.jsx("label",{className:F.label,htmlFor:e.name,style:{textAlign:a,width:"100%",minWidth:"unset",display:"block"},children:t(e.displayName)})}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)",width:"100%"},children:[h.jsx("div",{style:{flex:1,minWidth:0,maxWidth:"100%"},children:h.jsx("div",{style:{width:"100%"},children:n})}),e.tooltip&&h.jsx(Ge,{content:e.tooltip})]}),r&&h.jsx(Ne,{children:r})]})});ve.displayName="ColumnFieldLayout";const Ke=s.memo(({field:e,error:r,children:n,rightAlign:o=!1})=>{const{t}=V(),a=s.useMemo(()=>({display:"flex",flexDirection:"column",gap:0}),[]),i=s.useMemo(()=>({display:"flex",flexDirection:"row",alignItems:"center",gap:"3px"}),[]);return h.jsxs("div",{className:`${F.field} row-layout`,children:[h.jsx("label",{className:F.label,htmlFor:e.name,style:{textAlign:"left",justifyContent:"flex-start"},children:t(e.displayName)}),h.jsxs("div",{style:a,children:[h.jsxs("div",{style:i,children:[o?h.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)"},children:n}):n,e.tooltip&&h.jsx(Ge,{content:e.tooltip})]}),r&&h.jsx(Ne,{children:r})]})]})});Ke.displayName="RowFieldLayout";const q=({field:e,error:r,children:n,rightAlign:o=!1})=>e?.labelLayout==="column-left"||e?.labelLayout==="column-center"?h.jsx(ve,{field:e,error:r,showLabel:!0,children:n}):e?.type==="checkbox"||e?.type==="switch"?h.jsx(ve,{field:e,error:r,showLabel:!1,children:n}):h.jsx(Ke,{field:e,error:r,rightAlign:o,children:n}),Ne=s.memo(({children:e})=>{const r=s.useMemo(()=>({color:"var(--reactaform-error-color)",fontSize:"13px",marginTop:"4px",fontWeight:"var(--reactaform-font-weight)",display:"flex",flex:1,justifyContent:"flex-start",alignItems:"flex-start"}),[]);return h.jsx("div",{style:r,children:e})});Ne.displayName="ErrorDiv";const Xe=s.memo(({name:e,onChange:r})=>{const{t:n}=V();return h.jsxs("div",{style:{marginBottom:16},children:[h.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:12,alignItems:"center"},children:[h.jsx("label",{htmlFor:"instance-name-input",style:{margin:0,fontSize:"0.95em",fontWeight:500,color:"var(--reactaform-text-color, #333)"},children:n("Instance Name")}),h.jsx("input",{id:"instance-name-input",type:"text",value:e,onChange:o=>r(o.target.value),style:{width:"100%",padding:"var(--reactaform-input-padding, 8px 12px)",fontSize:"var(--reactaform-input-font-size, 14px)",border:"1px solid var(--reactaform-input-border, #ddd)",borderRadius:"var(--reactaform-border-radius, 4px)",backgroundColor:"var(--reactaform-input-bg, #fff)",color:"var(--reactaform-text-color, #333)",boxSizing:"border-box"},placeholder:n("Enter instance name")})]}),h.jsx("div",{style:{height:"1px",backgroundColor:"var(--reactaform-separator, #e6e6e6)",marginTop:12,marginBottom:12}})]})});Xe.displayName="InstanceName";class Cr extends ge{registerInCategory(r,n,o){this.get(r)||this.register(r,{});const t=this.get(r);t[n]=o}getFromCategory(r,n){return this.get(r)?.[n]}listFromCategory(r){return Object.keys(this.get(r)||{})}listCategories(){return this.list()}}const Ze=new ge,Qe=new Cr;function Rr(e,r){Ze.register(e,r)}function Er(e,r,n){Qe.registerInCategory(e,r,n)}function jr(e,r){return Qe.getFromCategory(e,r)||null}function kr(e){return Ze.get(e)||null}const be=new Map,ye=new Map;function H(e,r,n,o){if(r&&typeof r.validationHandlerName=="string"){const t=`${e}:${r.validationHandlerName}`;if(!be.has(t)){const i=jr(e,r.validationHandlerName);be.set(t,i)}const a=be.get(t);if(a)return a(n,o)||null}return null}function er(e,r,n){if(e&&typeof e.validationHandlerName=="string"){const o=e.validationHandlerName;if(!ye.has(o)){const a=kr(o);ye.set(o,a)}const t=ye.get(o);if(t)return t(r,n)||null}return null}function te(e){return typeof e=="object"&&e!==null}function Ie(e){if(!te(e))return!1;const r=e;return typeof r.name=="string"&&typeof r.displayName=="string"}function rr(e){if(!te(e))return!1;const r=e;return typeof r.name!="string"||typeof r.version!="string"||!Array.isArray(r.properties)?!1:r.properties.every(n=>Ie(n))}function we(e){try{return typeof File<"u"&&e instanceof File}catch{const r=te(e)?e:void 0;return!!r&&typeof r.name=="string"&&typeof r.size=="number"}}function Nr(e,r,n={}){try{const{includeMetadata:o=!1,dateFormat:t="iso",fileHandling:a="metadata",prettify:i=!1,excludeFields:c=[],includeOnlyFields:f=[]}=n;if(!e||typeof e!="object")return{success:!1,error:"Instance must be a valid object"};const m=[],u=[],g={},p=(rr(r)||te(r)&&Array.isArray(r.properties)?r.properties:[]).filter(Ie),y=new Map(p.map(x=>[x.name,x]));for(const[x,v]of Object.entries(e)){if(c.includes(x)){u.push(x);continue}if(f.length>0&&!f.includes(x)){u.push(x);continue}if(v===void 0)continue;const w=y.get(x);try{g[x]=Ir(v,w,{dateFormat:t,fileHandling:a})}catch(I){m.push(`Error serializing field '${x}': ${String(I)}`),g[x]=null}}return o&&(g._metadata={serializedAt:new Date().toISOString(),version:(te(r)?r.version:void 0)||"1.0.0",fieldCount:Object.keys(g).length-1}),{success:!0,data:i?JSON.stringify(g,null,2):JSON.stringify(g),metadata:{fieldCount:Object.keys(g).length,excludedFields:u,warnings:m}}}catch(o){return{success:!1,error:`Serialization failed: ${o instanceof Error?o.message:"Unknown error"}`}}}function Ir(e,r,n={}){const{dateFormat:o="iso",fileHandling:t="metadata"}=n;if(e==null)return null;if(r)switch(r.type){case"date":case"datetime":case"date-time":return Le(e,o);case"file":return Pe(e,t);case"int":case"integer":return typeof e=="string"?parseInt(e,10):e;case"float":case"number":return typeof e=="string"?parseFloat(e):e;case"boolean":return typeof e=="string"?e==="true":!!e;case"int-array":case"float-array":return Array.isArray(e)?e.map(a=>typeof a=="string"?Number(a):a):e;default:return e}return e instanceof Date?Le(e,o):we(e)||Array.isArray(e)&&we(e[0])?Pe(e,t):e}function Le(e,r){let n=null;if(e instanceof Date)n=e;else if(typeof e=="string"){const o=new Date(e);if(!isNaN(o.getTime()))n=o;else return e}else return e;switch(r){case"timestamp":return n.getTime();case"locale":return n.toLocaleString();case"iso":default:return n.toISOString()}}function Pe(e,r){return r==="skip"?null:Array.isArray(e)?e.map(n=>_e(n,r)):_e(e,r)}function _e(e,r){if(!we(e))return e;const n=e;return r==="metadata"?{name:n.name,size:n.size,type:n.type,lastModified:n.lastModified}:{name:n.name,size:n.size,type:n.type,lastModified:n.lastModified,_note:"Base64 encoding requires async implementation"}}function Fr(e,r,n={}){try{const{strict:o=!1,validateTypes:t=!0,preserveUnknownFields:a=!0,dateFormat:i="auto"}=n;if(!e||typeof e!="string")return{success:!1,error:"Serialized data must be a non-empty string"};let c;try{c=JSON.parse(e)}catch(d){return{success:!1,error:`Invalid JSON: ${d instanceof Error?d.message:"Unknown parsing error"}`}}if(!c||typeof c!="object")return{success:!1,error:"Parsed data must be an object"};const f=[],m=[],u={},l=(rr(r)||te(r)&&Array.isArray(r.properties)?r.properties:[]).filter(Ie),p=new Map(l.map(d=>[d.name,d]));for(const d of l){const x=d.name,v=c[x];if(v===void 0){o&&d.required&&m.push(`Required field '${x}' is missing`);continue}try{u[x]=Ar(v,d,{validateTypes:t,dateFormat:i})}catch(w){const I=`Error deserializing field '${x}': ${String(w)}`;o?m.push(I):(f.push(I),u[x]=v)}}if(a)for(const[d,x]of Object.entries(c))!p.has(d)&&d!=="_metadata"&&(o&&f.push(`Unknown field '${d}' preserved`),u[d]=x);const y=m.length>0;return{success:!y,data:u,warnings:f.length>0?f:void 0,validationErrors:y?m:void 0}}catch(o){return{success:!1,error:`Deserialization failed: ${o instanceof Error?o.message:"Unknown error"}`}}}function Ar(e,r,n={}){const{validateTypes:o=!0,dateFormat:t="auto"}=n;if(e==null)return e;try{switch(r.type){case"date":case"datetime":case"date-time":return $r(e,t,o);case"int":case"integer":return Se(e,o);case"float":case"number":return Ce(e,o);case"boolean":return Vr(e,o);case"int-array":return qe(e,"integer",o);case"float-array":return qe(e,"number",o);case"string":case"text":case"email":case"url":case"phone":return o?String(e):e;default:return e}}catch(a){if(o)throw new Error(`Type conversion failed: ${String(a)}`);return e}}function Mr(e,r={}){try{const{prettify:n=!0,includeMetadata:o=!0}=r;if(!e||typeof e!="object")return{success:!1,error:"Definition must be a valid object"};const t={...e};return o&&(t._metadata={serializedAt:new Date().toISOString(),version:t.version||"1.0.0",propertyCount:(Array.isArray(t.properties)?t.properties.length:0)||0}),{success:!0,data:n?JSON.stringify(t,null,2):JSON.stringify(t),metadata:{fieldCount:(Array.isArray(t.properties)?t.properties.length:0)||0,excludedFields:[],warnings:[]}}}catch(n){return{success:!1,error:`Definition serialization failed: ${n instanceof Error?n.message:"Unknown error"}`}}}function Or(e,r={}){try{const{strict:n=!1,validateTypes:o=!0}=r;let t;if(typeof e=="string")try{t=JSON.parse(e)}catch(u){return{success:!1,error:`Invalid JSON for definition: ${u instanceof Error?u.message:"Unknown parsing error"}`}}else if(e&&typeof e=="object")t={...e};else return{success:!1,error:"Input must be a string or object"};const a=[],i=[],c=["name","version","displayName"];for(const u of c)if(!t[u])if(n)i.push(`Required field '${u}' is missing`);else switch(a.push(`Missing field '${u}', using default`),u){case"name":t.name="unnamed-definition";break;case"version":t.version="1.0.0";break;case"displayName":t.displayName=t.name||"Unnamed Definition";break}const f=Array.isArray(t.properties)?t.properties:null;f?t.properties=f.map((u,g)=>{const l=te(u)?u:{},p={...l};if(!l.name){const y=`Property at index ${g} missing 'name'`;n?i.push(y):(a.push(`${y}, using 'field_${g}'`),p.name=`field_${g}`)}return l.displayName||(p.displayName=l.name||`Field ${g}`),l.type||(n&&o?i.push(`Property '${l.name||g}' missing 'type'`):(a.push(`Property '${l.name||g}' missing 'type', using 'string'`),p.type="string")),l.defaultValue===void 0&&(p.defaultValue=null),l.required===void 0&&(p.required=!1),p}):n?i.push("Properties must be an array"):(a.push("Properties not found or invalid, using empty array"),t.properties=[]);const m=i.length>0;return{success:!m,data:t,warnings:a.length>0?a:void 0,validationErrors:m?i:void 0}}catch(n){return{success:!1,error:`Definition deserialization failed: ${n instanceof Error?n.message:"Unknown error"}`}}}function $r(e,r,n){if(e instanceof Date)return e;if(typeof e=="number"){const o=new Date(e);if(n&&isNaN(o.getTime()))throw new Error(`Invalid timestamp: ${e}`);return o}if(typeof e=="string"){const o=new Date(e);if(n&&isNaN(o.getTime()))throw new Error(`Invalid date string: ${e}`);return o}if(n)throw new Error(`Cannot convert ${typeof e} to Date`);return e}function Se(e,r){if(typeof e=="number"&&Number.isInteger(e))return e;if(typeof e=="string"&&e.trim()!==""){const n=parseInt(e,10);if(r&&isNaN(n))throw new Error(`Cannot convert "${e}" to integer`);return n}if(r)throw new Error(`Cannot convert ${typeof e} to integer`);return e}function Ce(e,r){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim()!==""){const n=parseFloat(e);if(r&&isNaN(n))throw new Error(`Cannot convert "${e}" to number`);return n}if(r)throw new Error(`Cannot convert ${typeof e} to number`);return e}function Vr(e,r){if(typeof e=="boolean")return e;if(typeof e=="string"){const n=e.toLowerCase();if(n==="true"||n==="1")return!0;if(n==="false"||n==="0")return!1;if(r)throw new Error(`Cannot convert "${e}" to boolean`)}if(typeof e=="number")return!!e;if(r)throw new Error(`Cannot convert ${typeof e} to boolean`);return e}function qe(e,r,n){if(!Array.isArray(e)){if(typeof e=="string")return e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>r==="integer"?Se(t,n):Ce(t,n));if(n)throw new Error(`Expected array, got ${typeof e}`);return e}return e.map((o,t)=>{try{return r==="integer"?Se(o,n):Ce(o,n)}catch(a){if(n)throw new Error(`Array element ${t}: ${a}`);return o}})}const Dr=(e,r)=>{const n=new Map;let o=null,t=null,a=0;for(const i of e){const c=i.group;if(!c){o=null,t=null;continue}if(c===o)r[i.name].group=t??c;else{if(!n.has(c))n.set(c,1),t=null,r[i.name].group=c;else{const f=n.get(c),m=`${c}(${f})`;n.set(c,f+1),t=m,r[i.name].group=m,a++}o=c}}return a},zr=(e,r={})=>{const{includeEmpty:n=!0}=r,o=[];let t=null,a=[],i=0;for(const f of e){const m=f.group||null;m!==t?((a.length>0||n)&&(a.length===0&&i++,o.push({name:t,fields:a})),t=m,a=[f]):a.push(f)}(a.length>0||n)&&(a.length===0&&i++,o.push({name:t,fields:a}));const c=Math.max(0,...o.map(f=>f.fields.length));return{groups:o,metadata:{totalGroups:o.length,emptyGroups:i,largestGroup:c}}},xe=new Map,de=new Map,re=new Set,Re=new Map,Tr=async e=>{try{let r;switch(e.toLowerCase()){case"fr":r=(await Promise.resolve().then(()=>require("./common-DLr0UoG9.cjs"))).default;break;case"de":r=(await Promise.resolve().then(()=>require("./common-BgCI2TVb.cjs"))).default;break;case"es":r=(await Promise.resolve().then(()=>require("./common-DRIndE7S.cjs"))).default;break;case"zh-cn":r=(await Promise.resolve().then(()=>require("./common-BeJOG7Z0.cjs"))).default;break;case"en":r={};break;default:r={}}return{success:!0,translations:r,fromCache:!1}}catch(r){return{success:!1,translations:{},error:`Failed to load common translations for ${e}: ${r}`}}},Lr=async e=>{if(!e)return{success:!1,translations:{},error:"Language is required"};const r=e.toLowerCase();if(r==="en")return{success:!0,translations:{},fromCache:!1};if(xe.has(r))return{success:!0,translations:xe.get(r)||{},fromCache:!0};const n=await Tr(r);return n.success&&(xe.set(r,n.translations),Re.set(r,{loadedAt:new Date,size:Object.keys(n.translations).length,source:"common"})),n},Pr=async(e,r)=>{if(!e||!r)return{success:!1,translations:{},error:"Both language and localizeName are required"};const n=`${e.toLowerCase()}/${r}`;if(re.has(n))return{success:!1,translations:{},error:"Previously failed to load",fromCache:!0};if(de.has(n))return{success:!0,translations:de.get(n)||{},fromCache:!0};try{let o=r;!r.includes("/")&&!r.includes(".")&&(o=`/locales/${e}/${r}.json`);const t=await fetch(o);if(!t.ok){const m=`HTTP ${t.status}: ${t.statusText}`;return t.status===404?(de.set(n,{}),Re.set(n,{loadedAt:new Date,size:0,source:"user"}),{success:!0,translations:{},fromCache:!1}):(re.add(n),{success:!1,translations:{},error:m})}const a=t.headers.get("content-type")||"";!a.includes("application/json")&&!a.includes("text/json")&&tr()&&console.warn(`Translation file at ${o} has unexpected content-type: ${a}`);const i=await t.text();if(!i){const m="Empty translation file";return re.add(n),{success:!1,translations:{},error:m}}let c;try{c=JSON.parse(i)}catch(m){const u=`Invalid JSON in translation file: ${m instanceof Error?m.message:String(m)}`;return re.add(n),{success:!1,translations:{},error:u}}if(!c||typeof c!="object"){const m="Invalid translation file format";return re.add(n),{success:!1,translations:{},error:m}}const f=Object.fromEntries(Object.entries(c).map(([m,u])=>[m,typeof u=="string"?u:String(u)]));if(!f||typeof f!="object"){const m="Invalid translation file format";return re.add(n),{success:!1,translations:{},error:m}}return de.set(n,f),Re.set(n,{loadedAt:new Date,size:Object.keys(f).length,source:"user"}),{success:!0,translations:f,fromCache:!1}}catch(o){const t=`Failed to load user translations: ${o instanceof Error?o.message:"Unknown error"}`;return re.add(n),{success:!1,translations:{},error:t}}};function tr(){try{if(typeof process<"u"&&process?.env?.NODE_ENV==="development")return!0}catch{}return!1}function _r(e,r){return r.length===0?e:e.replace(/\{\{(\d+)\}\}/g,(n,o)=>{const t=parseInt(o,10)-1,a=r[t];if(a==null)return n;try{return String(a)}catch{return n}})}const qr=(e,r,n)=>(o,...t)=>{let a=o,i=!1;return!o||typeof o!="string"?String(o||""):(e.toLowerCase()==="en"?(a=o,i=!0):Object.prototype.hasOwnProperty.call(n,o)?(a=n[o],i=!0):Object.prototype.hasOwnProperty.call(r,o)?(a=r[o],i=!0):a=o,a=_r(a,t),!i&&tr()&&console.debug(`Missing translation for "${o}" in language "${e}"`),a)},Fe={length:["m","cm","mm","km","in","ft","yd","mi"],area:["m^2","cm^2","mm^2","in^2","ft^2","yd^2"],volume:["L","m^3","cm^3","mL","in^3","ft^3","yd^3"],weight:["kg","g","mg","t","lb","oz"],time:["min","s","h","ms","d"],temperature:["C","F","K"],angle:["deg","rad","rev"]},Ae={length:{m:"Meter (m)",mm:"Millimeter (mm)",cm:"Centimeter (cm)",km:"Kilometer (km)",in:"Inch (in)",ft:"Foot (ft)",yd:"Yard (yd)",mi:"Mile (mi)"},area:{"m^2":"Square meter (m^2)","mm^2":"Square millimeter (mm^2)","cm^2":"Square centimeter (cm^2)","in^2":"Square inch (in^2)","ft^2":"Square foot (ft^2)","yd^2":"Square yard (yd^2)"},volume:{L:"Liter (L)","cm^3":"Cubic centimeter (cm^3)","m^3":"Cubic meter (m^3)",mL:"Milliliter (mL)","in^3":"Cubic inch (in^3)","ft^3":"Cubic foot (ft^3)","yd^3":"Cubic yard (yd^3)"},weight:{kg:"Kilogram (kg)",g:"Gram (g)",mg:"Milligram (mg)",t:"Tonne (t)",lb:"Pound (lb)",oz:"Ounce (oz)"},time:{s:"Second (s)",min:"Minute (min)",h:"Hour (h)",ms:"Millisecond (ms)",d:"Day (d)",wk:"Week (wk)"},temperature:{C:"Celsius (C)",F:"Fahrenheit (F)",K:"Kelvin (K)"},angle:{deg:"Degree (deg)",rad:"Radian (rad)",rev:"Revolution (rev)"}},Me={length:{mm:1e3,cm:100,m:1,km:.001,in:100/2.54,ft:100/(2.54*12),yd:100/(2.54*36),mi:1/1609.344},area:{"m^2":1,"mm^2":1e6,"cm^2":1e4,"km^2":1/1e6,"in^2":(100/2.54)**2,"ft^2":(100/(2.54*12))**2,"yd^2":(100/(2.54*36))**2},volume:{"cm^3":1e6,"m^3":1,L:1,mL:1e6,"in^3":(100/2.54)**3,"ft^3":(100/(2.54*12))**3,"yd^3":(100/(2.54*36))**3},weight:{mg:1e6,g:1e3,kg:1,t:.001,lb:1/.45359237,oz:1/.028349523125},time:{ms:1e3,s:1,min:1/60,h:1/3600,d:1/86400,wk:1/604800},temperature:{C:1,F:33.8,K:274.15},angle:{deg:1,rad:Math.PI/180,rev:1/360}},Oe={},Br=new Set([...Object.keys(Fe),...Object.keys(Ae),...Object.keys(Me)]);for(const e of Br){const r={},n=Fe[e]??[],o=Ae[e]??{},t=Me[e]??{};for(const a of n){const i=o[a];r[a]={name:typeof i=="string"?i:String(a),shortName:a,factor:Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0}}for(const[a,i]of Object.entries(o))if(!r[a]){const c=typeof i=="string"?i:String(a);r[a]={name:c,shortName:a,factor:Object.prototype.hasOwnProperty.call(t,a)?t[a]:void 0}}for(const[a,i]of Object.entries(t))r[a]||(r[a]={name:String(a),shortName:String(a),factor:i});Oe[e]=r}const Hr=Object.freeze(Object.defineProperty({__proto__:null,dimensionUnitDisplayMap:Ae,dimensionUnitsMap:Fe,dimensonUnitFactorsMap:Me,unitsByDimension:Oe},Symbol.toStringTag,{value:"Module"})),Ur=({field:e,value:r,onChange:n,onError:o})=>{const{definitionName:t,t:a}=V(),i=s.useRef(o);s.useEffect(()=>{i.current=o},[o]),s.useEffect(()=>{const u=H(t,e,r??!1,a);i.current?.(u??null)},[r,e,t,a]);const c=u=>{const g=u.target.checked;n?.(g,null)},f=u=>{(u.key===" "||u.key==="Spacebar"||u.key==="Space"||u.key==="Enter")&&(u.preventDefault(),n?.(!r,null))},m=e.name;return h.jsx(q,{field:e,rightAlign:!1,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[h.jsx("label",{className:F.label,htmlFor:m,style:{textAlign:"left",justifyContent:"flex-start"},children:a(e.displayName)}),h.jsx("input",{id:m,"data-testid":"boolean-checkbox",type:"checkbox",checked:!!r,onChange:c,onKeyDown:f,"aria-checked":!!r,style:{cursor:"pointer",margin:"8px 0 8px 0",width:"1.2em",height:"1.2em",verticalAlign:"middle",color:"#FFFFFF",accentColor:"#0000FF",opacity:void 0}})]})})},Be=[{label:"Black",value:"#000000"},{label:"White",value:"#ffffff"},{label:"Red",value:"#ff0000"},{label:"Green",value:"#008000"},{label:"Blue",value:"#0000ff"},{label:"Yellow",value:"#ffff00"},{label:"Cyan",value:"#00ffff"},{label:"Magenta",value:"#ff00ff"},{label:"Orange",value:"#ffa500"},{label:"Purple",value:"#800080"},{label:"Brown",value:"#a52a2a"},{label:"Gray",value:"#808080"},{label:"Light Gray",value:"#d3d3d3"},{label:"Pink",value:"#ffc0cb"}];function nr(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}function Wr(e){if(!nr(e))return null;const r=or(e),n=parseInt(r.slice(1),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function or(e){return e?(e=e.toLowerCase(),/^#([a-f0-9]){3}$/i.test(e)?"#"+e.slice(1).split("").map(r=>r+r).join(""):e):"#000000"}const Yr=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[i,c]=s.useState("#000000"),f=s.useRef(null),m=s.useRef(null),u=s.useRef(o);s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const v=r&&nr(r)?r:"#000000",w=or(v);c(w)},[r]),s.useEffect(()=>{const v=H(a,e,r??"#000000",t);u.current?.(v??null)},[r,e,a,t]);const g=v=>{const w=v.target.value;c(w),n?.(w,null)},l=v=>{const w=v.target.value;c(w),n?.(w,null)},p=Be.find(v=>v.value===i),{r:y,g:d,b:x}=Wr(i)||{r:0,g:0,b:0};return h.jsx(q,{field:e,error:null,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[h.jsxs("select",{ref:f,id:e.name,value:i,onChange:g,style:{minWidth:"120px",flex:1},className:W(F.input,F.inputSelect),children:[Be.map(v=>h.jsx("option",{value:v.value,children:t(v.label)},v.value)),p?null:h.jsxs("option",{value:i,children:["(",y,", ",d,", ",x,")"]},i)]}),h.jsx("label",{style:{width:"2.5em",height:"1.8em",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:i,cursor:"pointer",overflow:"hidden",flexShrink:0},children:h.jsx("input",{ref:m,type:"color",value:i,onChange:l,style:{opacity:0,width:"100%",height:"100%",border:"none",padding:0,cursor:"pointer"}})})]})})},ue=e=>{if(!e)return null;const r=new Date(e);return isNaN(r.getTime())?null:r},Jr=e=>{if(!e)return"";if(/^\d{4}-\d{2}-\d{2}$/.test(e))return ue(e)?e:"";const n=ue(e);if(n){const o=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0");return`${o}-${t}-${a}`}return""},Gr=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),{name:i,required:c}=e,f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]);const u=s.useCallback(l=>{if(!l||l.trim()==="")return c?t("Value required"):null;if(l){const y=ue(l);if(!y)return t("Invalid date format");if(e.minDate){const d=ue(e.minDate);if(d&&y.getTime()<d.getTime())return t("Date must be on or after {{1}}",e.minDate)}if(e.maxDate){const d=ue(e.maxDate);if(d&&y.getTime()>d.getTime())return t("Date must be on or before {{1}}",e.maxDate)}}return H(a,e,l,t)??null},[e,a,t,c]),g=l=>{const p=l.target.value,y=u(p);n?.(p,y)};return s.useEffect(()=>{const l=u(r);l!==f.current&&(f.current=l,m.current?.(l??null))},[r,u]),h.jsx(q,{field:e,error:u(r),children:h.jsx("input",{id:i,type:"date",value:Jr(r),onChange:g,className:W(F.input,F.textInput),...e.minDate?{min:e.minDate}:{},...e.maxDate?{max:e.maxDate}:{},"aria-invalid":!!u(r),"aria-describedby":u(r)?`${i}-error`:void 0})})},Kr=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useRef(o);s.useEffect(()=>{c.current=o},[o]);const f=s.useCallback(u=>u===""||u===null||u===void 0?t("Value required"):!e.options||e.options.length===0?null:e.options.some(l=>l.value===u)?H(a,e,u,t)??null:t("Invalid option selected"),[e,t,a]);s.useEffect(()=>{const u=r!=null?String(r):"",g=f(u);if(g&&e.options&&e.options.length>0){const l=String(e.options[0].value);i.current&&(i.current.value=l),n?.(l,null),c.current?.(null)}else i.current&&(i.current.value=u),c.current?.(g??null)},[r,f,n,e.options]);const m=u=>{const g=u.target.value,l=f(g);n?.(g,l)};return h.jsx(q,{field:e,error:f(String(r??"")),children:h.jsx("select",{defaultValue:String(r??""),ref:i,onChange:m,className:W(F.input,F.inputSelect),children:(e.options??[]).map(u=>h.jsx("option",{value:String(u.value),children:t(u.label)},String(u.value)))})})};function Xr(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}const Zr=({field:e,value:r,onChange:n,onError:o})=>{const{definitionName:t,t:a}=V(),i=s.useRef(null),c=s.useCallback(g=>{const l=g.trim();return l===""?e.required?a("Value required"):null:Xr(l)?e.pattern&&!new RegExp(e.pattern).test(l)?a("Email does not match pattern: {{%1}}",{"%1":`${e.pattern}`}):H(t,e,g,a)??null:a("Must be valid email format")},[e,t,a]),f=g=>{const l=g.target.value,p=c(l);n?.(l,p)},m=s.useRef(null),u=s.useRef(o);return s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const g=r??"",l=c(g);i.current&&i.current.value!==String(g)&&(i.current.value=String(g)),l!==m.current&&(m.current=l,u.current?.(l??null))},[r,c]),h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"email",defaultValue:String(r??""),ref:i,onChange:f,className:W(F.input,F.textInput)})})},Qr=({field:e})=>{const{darkMode:r}=V(),{color:n=r?"#444444":"#CCCCCC",thickness:o=1,margin:t="8px 0"}=e;return h.jsx("div",{style:{width:"auto",height:"0",borderTop:`${o}px solid ${n}`,margin:t}})},et=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[i,c]=s.useState(!1),f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]);const u=s.useCallback(w=>e.required&&(!w||Array.isArray(w)&&w.length===0)?t("Value required"):H(a,e,w,t)??null,[e,a,t]),g=s.useMemo(()=>u(r),[r,u]);s.useEffect(()=>{const w=u(r);n?.(r,w),m.current?.(w??null)},[r,u]);const l=w=>{const I=w.target.files;let E=null;if(I&&I.length>0){const R=Array.from(I);e.multiple?E=[...Array.isArray(r)?r:[],...R]:E=R[0]}const S=u(E);n?.(E,S)},p=w=>{w.preventDefault(),w.stopPropagation(),c(!1);const I=w.dataTransfer.files;if(I&&I.length>0){const E=Array.from(I);let S=null;e.multiple?S=[...Array.isArray(r)?r:[],...E]:S=E[0];const R=u(S);n?.(S,R)}},y=w=>{w.preventDefault(),w.stopPropagation(),c(!0)},d=w=>{w.preventDefault(),w.stopPropagation(),c(!1)},x=w=>{if(Array.isArray(r)&&typeof w=="number"){const I=r.filter((R,k)=>k!==w),E=I.length>0?I:null,S=u(E);n?.(E,S)}else{const I=u(null);n?.(null,I)}},v=()=>{const w=Array.isArray(r)?r:r?[r]:[];return w.length===0?null:h.jsx("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:w.map((I,E)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",backgroundColor:"var(--reactaform-input-bg, #fff)",border:"1px solid var(--reactaform-border-color, #d1d5db)",borderRadius:"4px",fontSize:"0.875rem",gap:"8px"},children:[h.jsx("div",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:I.name}),h.jsx("button",{type:"button",onClick:()=>x(Array.isArray(r)?E:void 0),"aria-label":t("Remove file"),style:{background:"transparent",border:"none",color:"var(--reactaform-color-error, #ef4444)",cursor:"pointer",padding:"2px 6px",fontSize:"1.125rem",lineHeight:1,borderRadius:"4px",transition:"background-color 0.2s",flexShrink:0},onMouseEnter:S=>{S.currentTarget.style.backgroundColor="var(--reactaform-bg-hover, #fee)"},onMouseLeave:S=>{S.currentTarget.style.backgroundColor="transparent"},children:"×"})]},`${I.name}-${E}`))})};return h.jsx(q,{field:e,error:g,children:h.jsxs("div",{style:{width:"100%"},children:[h.jsxs("div",{onDrop:p,onDragOver:y,onDragLeave:d,style:{position:"relative",border:`1px dashed ${i?"var(--reactaform-color-primary, #2563eb)":g?"var(--reactaform-color-error, #ef4444)":"var(--reactaform-border-color, #d1d5db)"}`,borderRadius:"var(--reactaform-border-radius, 4px)",padding:"8px 12px",textAlign:"center",backgroundColor:i?"var(--reactaform-bg-hover, #f0f9ff)":"var(--reactaform-input-bg, #fff)",transition:"all 0.2s ease",cursor:"pointer",minHeight:"var(--reactaform-input-height, 34px)",width:"100%",maxWidth:"100%",alignSelf:"stretch",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},onClick:()=>f.current?.click(),children:[h.jsx("input",{id:e.name,ref:f,type:"file",accept:e.accept,multiple:e.multiple,style:{display:"none"},onChange:l}),h.jsx("div",{style:{fontSize:"1.25rem",opacity:.6,lineHeight:1,flexShrink:0},children:"📁"}),h.jsx("div",{style:{fontSize:"0.875rem",fontWeight:400,color:"var(--reactaform-text-color, #111827)",flex:1,textAlign:"left"},children:i?t("Drop files here"):e.multiple?t("Choose Files or Drag & Drop"):t("Choose File or Drag & Drop")}),e.accept&&h.jsx("div",{style:{fontSize:"0.75rem",color:"var(--reactaform-text-muted, #6b7280)",whiteSpace:"nowrap",opacity:i?0:1,transition:"opacity 0.15s ease",pointerEvents:i?"none":"auto"},children:e.accept})]}),v()]})})},rt=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function tt(e){return e.split(",").map(r=>r.trim()).every(r=>rt.test(r))}const nt=e=>!e||e.trim()===""?[]:e.split(",").map(r=>r.trim()).filter(Boolean).map(Number),ot=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[i,c]=s.useState(Array.isArray(r)?r.join(", "):String(r??"")),f=s.useCallback(l=>{if(l.trim()==="")return e.required?t("Value required"):null;if(!tt(l))return t("Each value must be a valid float");const p=nt(l);if(e.minCount!==void 0&&p.length<e.minCount)return t("Minimum number of values: {{1}}",e.minCount);if(e.maxCount!==void 0&&p.length>e.maxCount)return t("Maximum number of values: {{1}}",e.maxCount);for(const d of p){if(e.min!==void 0&&(e.minInclusive?d<e.min:d<=e.min))return t("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?d>e.max:d>=e.max))return t("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return H(a,e,p,t)??null},[a,e,t]),m=l=>{const p=l.target.value,y=f(p);c(p),n?.(p,y)},u=s.useRef(null),g=s.useRef(o);return s.useEffect(()=>{g.current=o},[o]),s.useEffect(()=>{const l=Array.isArray(r)?r.join(", "):String(r??""),p=f(l);p!==u.current&&(u.current=p,g.current?.(p??null))},[r,e.required,f,t]),h.jsx(q,{field:e,error:f(i),children:h.jsx("input",{type:"text",value:i,onChange:m,className:W(F.input,F.textInput),style:{flex:1}})})},at=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,st=e=>{const r=Number.parseFloat(e);return Number.isNaN(r)?null:r},it=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useCallback(g=>{if(g.trim()==="")return e.required?t("Value required"):null;if(!at.test(g))return t("Must be a valid float");const l=st(g);return l===null?t("Must be a valid float"):e.min!==void 0&&(e.minInclusive?l<e.min:l<=e.min)?t("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min):e.max!==void 0&&(e.maxInclusive?l>e.max:l>=e.max)?t("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max):H(a,e,l,t)??null},[e,a,t]),f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]),s.useEffect(()=>{const g=String(r??""),l=c(g);l!==f.current&&(f.current=l,m.current?.(l??null)),i.current&&document.activeElement!==i.current&&(i.current.value=g)},[r,e,c,t]);const u=g=>{const l=g.target.value,p=c(l);n?.(l,p)};return h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:i,onChange:u,className:W(F.input,F.inputNumber)})})};function ct(){try{return"/"}catch{}try{if(typeof process<"u"&&process?.env?.PUBLIC_URL)return process.env.PUBLIC_URL}catch{}return"/"}const lt=({field:e,value:r})=>{const{language:n,t:o}=V(),t=e.alignment||"center",a={left:"flex-start",center:"center",right:"flex-end"},i=typeof r=="string"?r:"";let c=i&&i.trim()!==""?i:typeof e.defaultValue=="string"?e.defaultValue:"";c&&!c.startsWith("/")&&(c=`${ct()}${c}`);const f=e.localized?.split(";").map(x=>x.trim()),[m,u]=s.useState(c||""),g=s.useRef(c||null);if(s.useEffect(()=>{if(!c)return;const x=c.split("/"),v=x.pop(),w=v.lastIndexOf(".");if(w===-1)return;const I=v.substring(0,w),E=v.substring(w);let S=null;f?.includes(n)&&(S=`${I}_${n}${E}`);const R=new AbortController;if(S){const k=[...x,S].join("/");fetch(k,{method:"HEAD",signal:R.signal}).then(C=>{const N=C.ok?k:c;N!==g.current&&(g.current=N,u(N))}).catch(()=>{c!==g.current&&(g.current=c,u(c))})}else{const k=c;k!==g.current&&(g.current=k,requestAnimationFrame(()=>u(k)))}return()=>{R.abort()}},[c,n,f]),!m)return null;const{width:l,height:p}=e,y={},d={borderRadius:"8px",objectFit:"contain",boxShadow:"0 2px 6px rgba(0,0,0,0.1)",margin:"0 0 8px 0"};return l&&p?(y.width=l,y.height=p,d.width=`${l}px`,d.height=`${p}px`):l&&!p?(y.width=l,d.width=`${l}px`,d.height="auto"):!l&&p&&(y.height=p,d.width="auto",d.height=`${p}px`),h.jsx(q,{field:e,children:h.jsx("div",{"data-testid":"image-wrapper",style:{display:"flex",justifyContent:a[t]||"center",margin:"0 0"},children:h.jsx("img",{src:m,alt:o?.(e.displayName||"Image")||e.displayName||"Image",...y,style:d})})})};function ut(e){const r=/^-?\d+$/;return e.split(",").map(n=>n.trim()).every(n=>r.test(n))}const ft=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=",",[c,f]=s.useState(Array.isArray(r)?r.join(i+" "):String(r??"")),m=y=>!y||y.trim()===""?[]:y.split(i).map(d=>d.trim()).filter(Boolean).map(d=>Number(d)),u=s.useCallback(y=>{if(y.trim()==="")return e.required?t("Value required"):null;if(!ut(y))return t("Each value must be a valid integer");const d=m(y);if(e.minCount!==void 0&&d.length<e.minCount)return t("Minimum number of values: {{1}}",`${e.minCount}`);if(e.maxCount!==void 0&&d.length>e.maxCount)return t("Maximum number of values: {{1}}",`${e.maxCount}`);for(const v of d){if(e.min!==void 0&&(e.minInclusive?v<e.min:v<=e.min))return t("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?v>e.max:v>=e.max))return t("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return H(a,e,d,t)??null},[a,e,t]),g=y=>{const d=y.target.value,x=u(d);f(d),n?.(d,x)},l=s.useRef(null),p=s.useRef(o);return s.useEffect(()=>{p.current=o},[o]),s.useEffect(()=>{const y=Array.isArray(r)?r.join(i+" "):String(r??""),d=u(y);d!==l.current&&(l.current=d,p.current?.(d??null))},[r,e.required,u,t]),h.jsx(q,{field:e,error:u(c),children:h.jsx("input",{type:"text",value:c,onChange:g,className:W(F.input,F.textInput),style:{flex:1}})})};function mt(e){return/^[-+]?\d*$/.test(e)}const dt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useCallback(l=>{const p=parseInt(l,10);return Number.isNaN(p)?null:p},[]),f=s.useCallback(l=>{if(l.trim()==="")return e.required?t("Value required"):null;if(!mt(l))return t("Must be a valid integer");const p=c(l);if(p===null)return t("Must be a valid integer");if(e.min!==void 0&&(e.minInclusive?p<e.min:p<=e.min))return t("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?p>e.max:p>=e.max))return t("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max);if(e.step!==void 0){const d=Number(e.step);if(!Number.isInteger(d))return t("Invalid step value");if(p%d!==0)return t("Must be a multiple of {{1}}",d)}return H(a,e,p,t)??null},[e,a,t,c]),m=s.useRef(null),u=s.useRef(o);s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const l=String(r??""),p=f(l);p!==m.current&&(m.current=p,u.current?.(p??null)),i.current&&document.activeElement!==i.current&&(i.current.value=l)},[r,e,f,t]);const g=l=>{const p=l.target.value,y=f(p);n?.(p,y)};return h.jsx(q,{field:e,error:f(String(r??"")),children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:i,onChange:g,className:W(F.input,F.inputNumber)})})},pt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=e.minHeight??"80px",c=s.useRef(null),f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]);const u=s.useCallback(p=>p.trim()===""?e.required?t("Value required"):null:e.minLength!==void 0&&p.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&p.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):H(a,e,p,t),[e,a,t]),g=p=>{const y=p.target.value,d=u(y);n?.(y,d)};s.useEffect(()=>{const p=u(r);p!==f.current&&(f.current=p,m.current?.(p??null)),c.current&&c.current.value!==String(r??"")&&(c.current.value=String(r??""))},[r,u]);const l={defaultValue:String(r??""),ref:c,onChange:g,style:{resize:"vertical",minHeight:i,width:"100%",boxSizing:"border-box"},className:W(F.input,F.textInput)};return h.jsx(q,{field:e,error:u(r),children:h.jsx("textarea",{...l})})},gt=({field:e,value:r,onChange:n,onError:o})=>{const t=s.useRef(o);s.useEffect(()=>{t.current=o},[o]);const{t:a,darkMode:i,formStyle:c,fieldStyle:f,definitionName:m}=V(),u=(C,N,A)=>{if(!N)return{};const D=C?.[N];return(A&&D?D[A]:void 0)??{}},g=s.useRef(null),[l,p]=s.useState(!1),[y,d]=s.useState(null),x=s.useMemo(()=>e.options.map(C=>({value:C.value,label:a(C.label)})),[e.options,a]),v=s.useMemo(()=>{const C=Array.isArray(r)?r:[],N=new Set(x.map(A=>A.value));return C.filter(A=>N.has(A))},[r,x]),w=C=>{const N=Array.isArray(C)?C:[];return e.required&&N.length===0?a("Value required"):H(m,e,N,a)??null},I=()=>{if(!g.current)return;const C=g.current.getBoundingClientRect();d({x:C.left,y:C.bottom}),p(N=>!N)},E=C=>{const N=v.includes(C)?v.filter($=>$!==C):[...v,C],A=w(N);t.current?.(A??null),n?.(N,A)},S=s.useMemo(()=>({height:"var(--reactaform-input-height, 2.5rem)",padding:"var(--reactaform-input-padding, 8px)",display:"flex",alignItems:"center",boxSizing:"border-box",cursor:"pointer",position:"relative",borderRadius:"var(--reactaform-border-radius, 4px)",border:"1px solid var(--reactaform-border-color, #ccc)",background:"var(--reactaform-secondary-bg, #fff)",color:"var(--reactaform-text-color, #000)",...u(c,"multiSelect","control"),...u(f,void 0,"control")}),[c,f]),R=s.useMemo(()=>({position:"absolute",right:"1.5em",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",padding:0,...u(c,"multiSelect","clearButton"),...u(f,void 0,"clearButton")}),[c,f]),k=s.useMemo(()=>({position:"absolute",right:"0.7em",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",...u(c,"multiSelect","arrow"),...u(f,void 0,"arrow")}),[c,f]);return h.jsxs("div",{children:[h.jsx(q,{field:e,error:null,children:h.jsx("div",{style:{width:"100%"},children:h.jsxs("div",{ref:g,className:"reactaform-multiselection-control",style:S,onClick:I,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":l,onKeyDown:C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),I())},children:[h.jsxs("span",{style:{flex:1,color:"var(--reactaform-text-muted, #888)"},children:[v.length," / ",x.length," selected"]}),v.length>0&&h.jsx("button",{type:"button","aria-label":"Clear selections",onClick:C=>{C.stopPropagation(),n?.([],null)},style:R,children:h.jsx("span",{style:R,"aria-hidden":!0,children:"✖"})}),h.jsx("span",{style:k,"aria-hidden":!0,children:"▼"})]})})}),l&&y&&h.jsx(ht,{position:y,options:x,selectedValues:v,onToggleOption:E,onClose:()=>p(!1),controlRef:g,darkMode:i})]})},ht=({position:e,options:r,selectedValues:n,onToggleOption:o,onClose:t,controlRef:a,darkMode:i})=>{const c=s.useRef(null),[f,m]=s.useState(-1),{formStyle:u,fieldStyle:g}=V(),l=(R,k,C)=>{if(!k)return{};const A=R?.[k];return(C&&A?A[C]:void 0)??{}},p=s.useMemo(()=>({maxHeight:200,overflowY:"auto",background:"var(--reactaform-secondary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:4,zIndex:2e3,boxShadow:"var(--reactaform-shadow, 0 2px 8px rgba(0,0,0,0.15))",pointerEvents:"auto",color:"var(--reactaform-text-color, #000)",fontSize:"var(--reactaform-popup-font-size, 0.875rem)",...l(u,"multiSelect","popup"),...l(g,void 0,"popup")}),[u,g]),y=s.useMemo(()=>({padding:"6px 8px",cursor:"pointer",display:"flex",alignItems:"center",background:"transparent",color:"var(--reactaform-text-color, #000)",...l(u,"multiSelect","option"),...l(g,void 0,"option")}),[u,g]);s.useEffect(()=>{const R=k=>{const C=k.target;!c.current?.contains(C)&&!a.current?.contains(C)&&t()};return document.addEventListener("mousedown",R),()=>document.removeEventListener("mousedown",R)},[t,a]),s.useEffect(()=>{c.current&&r.length>0&&requestAnimationFrame(()=>m(R=>R===-1?0:R))},[r.length]),s.useEffect(()=>{if(!c.current||f<0)return;const R=c.current.querySelector(`#multi-opt-${f}`);R&&requestAnimationFrame(()=>R.focus())},[f]);const d=250,x=200,[v,w]=s.useState(null),[I,E]=s.useState(null);if(s.useEffect(()=>{if(typeof window>"u")return;const R=()=>{let N=e.x,A=e.y,$=d;const D=a?.current;if(D){const U=D.getBoundingClientRect();N=U.left,A=U.bottom,$=Math.max(80,Math.round(U.width))}N=Math.min(N,window.innerWidth-$),A=Math.min(A,window.innerHeight-x),w({left:N,top:A}),E($)};R(),window.addEventListener("scroll",R,!0),window.addEventListener("resize",R);let k=null;const C=a?.current;return typeof ResizeObserver<"u"&&C&&(k=new ResizeObserver(()=>R()),k.observe(C)),()=>{window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R),k&&C&&k.unobserve(C)}},[a,e.x,e.y]),typeof window>"u")return null;let S=document.getElementById("popup-root");return S||(S=document.createElement("div"),S.id="popup-root",document.body.appendChild(S)),je.createPortal(h.jsx("div",{ref:c,role:"listbox","aria-activedescendant":f>=0?`multi-opt-${f}`:void 0,style:{position:"absolute",top:v?v.top:e.y,left:v?v.left:e.x,width:I??d,...p},"data-reactaform-theme":i?"dark":"light",children:r.map((R,k)=>{const C=n.includes(R.value),N=i?"var(--reactaform-hover-bg, rgba(255,255,255,0.01))":"var(--reactaform-hover-bg, #eee)",A={...y,background:k===f?N:y.background};return h.jsxs("div",{id:`multi-opt-${k}`,onMouseDown:$=>{$.stopPropagation(),o(R.value)},onKeyDown:$=>{const D=r.length;switch($.key){case"ArrowDown":$.preventDefault(),m(U=>(U+1)%D);break;case"ArrowUp":$.preventDefault(),m(U=>(U-1+D)%D);break;case"Home":$.preventDefault(),m(0);break;case"End":$.preventDefault(),m(D-1);break;case"Enter":case" ":$.preventDefault(),$.stopPropagation(),o(R.value);break;case"Escape":$.preventDefault(),t(),a?.current?.focus();break}},tabIndex:k===f?0:-1,role:"option","aria-selected":C,style:A,onMouseEnter:$=>{$.currentTarget.style.background=N,m(k)},onMouseLeave:$=>{$.currentTarget.style.background="transparent",m(D=>D===k?-1:D)},children:[h.jsx("input",{type:"checkbox",checked:C,readOnly:!0,style:{marginRight:8,width:"1.125em",height:"1.125em",verticalAlign:"middle",accentColor:i?"#10b981":"#22c55e",cursor:"pointer"}}),R.label]},R.value)})}),S)},bt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=e.min??void 0,f=e.max??void 0,m=Math.max(1,Math.round(e.step??1)),u=s.useCallback(d=>isNaN(d)?t("Must be a valid integer"):Number.isInteger(d)?c!==void 0&&d<c?t("Must be �?{{1}}",c):f!==void 0&&d>f?t("Must be �?{{1}}",f):H(a,e,d,t)??null:t("Must be an integer"),[a,e,t,c,f]),g=s.useRef(null),l=s.useRef(o);s.useEffect(()=>{l.current=o},[o]),s.useEffect(()=>{if(document.activeElement===i.current)return;const x=String(r),v=u(r);i.current&&(i.current.value=x),v!==g.current&&(g.current=v,l.current?.(v??null))},[r,u]);const p=d=>{if(d.trim()==="")return e.required?t("Value required"):null;const v=Number(d);return u(v)},y=d=>{const x=d.target.value,v=d.target.valueAsNumber,w=p(x);n?.(v,w)};return h.jsx(q,{field:e,error:p(String(r??"")),children:h.jsx("input",{ref:i,id:e.name,type:"number",defaultValue:String(r??""),min:c,max:f,step:m,onChange:y,style:{width:"100%",height:"100%"},className:F.input})})},yt=({field:e,value:r,onChange:n,onError:o})=>{const{t}=V(),a=s.useRef(null),{definitionName:i}=V(),c=s.useCallback(g=>{const l=String(g??"").trim();if(l==="")return e.required?t("Value required"):null;if(e.pattern)try{if(!new RegExp(e.pattern).test(l))return t("Phone number does not match pattern: {{1}}",`${e.pattern}`)}catch{}return H(i,e,l,t)},[i,e,t]),f=s.useRef(null),m=s.useRef(o);s.useEffect(()=>{m.current=o},[o]),s.useEffect(()=>{const g=String(r??""),l=c(g);a.current&&a.current.value!==String(g)&&(a.current.value=String(g)),l!==f.current&&(f.current=l,m.current?.(l??null))},[r,c]);const u=g=>{const l=g.target.value,p=l.trim();let y=null;if(p===""){y=e.required?t("Value required"):null,n?.(l,y);return}!y&&e.pattern&&!new RegExp(e.pattern).test(p)&&(y=t("Phone number does not match pattern: {{1}}",`${e.pattern}`)),n?.(l,y)};return h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{type:"tel",defaultValue:String(r??""),ref:a,onChange:u,className:W(F.input,F.textInput)})})},xt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=e.layout?.toLowerCase()==="horizontal"?"row":"column",c=s.useRef(null),f=s.useRef(o);s.useEffect(()=>{f.current=o},[o]);const m=s.useCallback(g=>g===""||g===null||g===void 0?t("Value required"):!e.options||e.options.length===0?null:e.options.some(p=>p.value===g)?H(a,e,g,t)??null:t("Invalid option selected"),[e,t,a]);s.useEffect(()=>{const g=r!=null?String(r):"",l=m(g);if(f.current?.(l??null),c.current){const p=Array.from(c.current.querySelectorAll("input[type=radio]"));if(l&&e.options&&e.options.length>0){const y=String(e.options[0].value);p.forEach(d=>d.checked=d.value===y),n?.(y,null)}else p.forEach(y=>y.checked=y.value===g)}},[r,m,n,e.options]);const u=g=>{const l=g.target.value,p=m(l);f.current?.(p??null),n?.(l,p)};return h.jsx(q,{field:e,error:m(String(r??"")),children:h.jsx("div",{style:{display:"flex",flexDirection:i,flexWrap:i==="row"?"wrap":"nowrap",gap:i==="row"?"12px":"4px",alignItems:i==="row"?"center":"flex-start",width:"100%"},ref:c,children:(e.options??[]).map(g=>h.jsxs("label",{style:{display:"flex",gap:"6px",alignItems:"center",whiteSpace:"nowrap"},children:[h.jsx("input",{type:"radio",name:e.name,value:String(g.value),defaultChecked:String(r??"")===String(g.value),onChange:u}),t(g.label)]},String(g.value)))})})},vt={display:"flex",gap:4},wt={cursor:"pointer",fontSize:"1.5rem",lineHeight:1,display:"inline-block",marginRight:"0.25rem",userSelect:"none",transition:"color 0.12s ease"},St=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),[i,c]=s.useState(null),f=e.max||5,m=s.useCallback(y=>e.required&&y===0?t("Value required"):H(a,e,y,t)??null,[e,t,a]),u=s.useRef(null),g=s.useRef(o);s.useEffect(()=>{g.current=o},[o]),s.useEffect(()=>{let y=r||0;r<0&&(y=0),r>f&&(y=f);const d=m(y);d!==u.current&&(u.current=d,g.current?.(d??null))},[r,m,f]);const l=y=>{const d=m(y);n?.(y,d)},p=(()=>{let y=r||0;return y<0&&(y=0),y>f&&(y=f),y})();return h.jsx(q,{field:e,error:m(p),children:h.jsx("div",{style:vt,children:(()=>{const y=e.icon,d=y&&String(y).trim()?String(y):"★";return[...Array(f)].map((x,v)=>{const w=v<p,E=i!==null&&v<=i||w?"gold":"lightgray";return h.jsx("span",{onClick:()=>l(v+1),onMouseEnter:()=>c(v),onMouseLeave:()=>c(null),style:{...wt,color:E},"aria-label":`Rating ${v+1}`,title:t(`${e.displayName} ${v+1}`),children:d},v)})})()})})},Ct=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useRef(null),f=s.useRef(o);s.useEffect(()=>{f.current=o},[o]);const m=s.useMemo(()=>e.pattern?new RegExp(e.pattern):null,[e.pattern]),u=s.useCallback(d=>d===""?e.required?t("Value required"):null:e.minLength!==void 0&&d.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&d.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):m&&!m.test(d)?t("Input does not match pattern: {{1}}",e.pattern):H(a,e,d,t),[e,a,t,m]),g=d=>{const x=d.target.value,v=u(x);n?.(x,v)};s.useEffect(()=>{const d=u(r??"");i.current&&i.current.value!==String(r??"")&&(i.current.value=String(r??"")),d!==c.current&&(c.current=d,f.current?.(d??null))},[r,u]);const[l,p]=s.useState(!1),y=()=>p(d=>!d);return h.jsx(q,{field:e,error:u(String(r??"")),children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,width:"100%"},children:[h.jsx("input",{id:e.name,type:l?"text":"password",defaultValue:String(r??""),ref:i,onChange:g,className:W(F.input,F.textInput),style:{flex:1,minWidth:0}}),h.jsx("button",{type:"button",onClick:y,"aria-label":t(l?"Hide password":"Show password"),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:16,lineHeight:1,padding:"4px 6px",flexShrink:0},children:l?"🙈":"👁️"})]})})},Rt=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function Et(e){return Rt.test(e)}const jt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useRef(null),f=s.useCallback(y=>{let d=null;if(y.trim()==="")return t("Value required");if(!Et(y))return t("Invalid number");const x=Number(y);return typeof e.min=="number"&&x<e.min?t("Value should be at least {{1}}",e.min):typeof e.max=="number"&&x>e.max?t("Value should be at most {{1}}",e.max):(d||(d=H(a,e,x,t)),d)},[a,e,t]),m=s.useRef(null),u=s.useRef(o);s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const y=String(r),d=f(y);c.current&&document.activeElement!==c.current&&(c.current.value=isNaN(Number(y))?String(e.min??0):String(Number(y))),i.current&&document.activeElement!==i.current&&(i.current.value=y),d!==m.current&&(m.current=d,u.current?.(d??null))},[r,f,e.min]);const g=e.min??0,l=e.max??100,p=y=>{const d=y.target.value,x=f(d);n?.(d,x)};return h.jsx(q,{field:e,error:f(String(r??"")),children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[h.jsx("input",{ref:c,type:"range",defaultValue:isNaN(Number(r))?String(g):String(Number(r)),onChange:p,min:g,max:l,style:{padding:"0px, 0px",flex:1},className:F.rangeInput}),h.jsx("input",{ref:i,type:"text",defaultValue:String(r??""),onChange:p,required:!0,style:{width:"40px",minWidth:"40px",height:"2.3em",textAlign:"center",flexShrink:0},className:W(F.input,F.textInput)})]})})},kt=({field:e,value:r,onChange:n,onError:o})=>{const{t,formStyle:a,fieldStyle:i,definitionName:c}=V(),f=a,m=i,u=(S,R,k)=>{if(!R)return{};const C=S?.[R];return(k&&C?C[k]:void 0)??{}},g=s.useMemo(()=>({display:"inline-block",position:"relative",width:44,height:24,...u(f,"switch","label"),...u(m,void 0,"label")}),[f,m]),l=s.useMemo(()=>({position:"absolute",opacity:0,top:0,left:0,width:"100%",height:"100%",margin:0,cursor:"pointer",pointerEvents:"none",...u(f,"switch","hiddenInput"),...u(m,void 0,"hiddenInput")}),[f,m]),p=s.useMemo(()=>({position:"absolute",cursor:"pointer",top:0,left:0,right:0,bottom:0,backgroundColor:"var(--reactaform-switch-off-bg, #ccc)",transition:"0.3s",borderRadius:24,borderWidth:2,borderStyle:"solid",borderColor:"transparent",...u(f,"switch","slider"),...u(m,void 0,"slider")}),[f,m]),y=s.useMemo(()=>({position:"absolute",height:16,width:16,left:2,bottom:2,backgroundColor:"white",transition:"0.3s",borderRadius:"50%",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",...u(f,"switch","knob"),...u(m,void 0,"knob")}),[f,m]),d=!!r,x=s.useRef(null),v=s.useRef(o),w=s.useCallback(S=>S?H(c,e,S,t)??null:e.required?t("Value required"):null,[e,t,c]),I=()=>{const S=!d,R=w(S);n?.(S,R)};s.useEffect(()=>{v.current=o},[o]),s.useEffect(()=>{const S=w(d);S!==x.current&&(x.current=S,v.current?.(S??null))},[d,e,w]);const E=e.name;return h.jsx(q,{field:e,error:w(d),rightAlign:!1,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[h.jsx("label",{className:F.label,htmlFor:E,style:{textAlign:"left",justifyContent:"flex-start"},children:t(e.displayName)}),h.jsxs("label",{style:g,children:[h.jsx("input",{id:e.name,type:"checkbox",checked:d,readOnly:!0,"aria-label":t(e.displayName),style:l,tabIndex:-1}),h.jsx("span",{role:"switch","data-testid":"switch",tabIndex:0,"aria-checked":d,onClick:I,onKeyDown:S=>{(S.key===" "||S.key==="Spacebar"||S.key==="Space"||S.key==="Enter")&&(S.preventDefault(),I())},className:`reactaform-switch ${d?"active checked on":""} `,style:d?{...p,backgroundColor:"var(--reactaform-switch-on-bg, #22c55e)",borderColor:"var(--reactaform-switch-on-border, #16a34a)"}:p,children:h.jsx("span",{style:{...y,transform:d?"translateX(20px)":void 0}})})]})]})})},He=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useRef(null),f=s.useRef(o);s.useEffect(()=>{f.current=o},[o]);const m=s.useMemo(()=>e.pattern?new RegExp(e.pattern):null,[e.pattern]),u=s.useCallback(l=>l.trim()===""?e.required?t("Value required"):null:e.minLength!==void 0&&l.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&l.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):m&&!m.test(l)?t("Input does not match pattern: {{1}}",e.pattern):H(a,e,l,t),[e,a,t,m]),g=l=>{const p=l.target.value,y=u(p);n?.(p,y)};return s.useEffect(()=>{const l=u(r);i.current&&i.current.value!==String(r??"")&&(i.current.value=String(r??"")),l!==c.current&&(c.current=l,f.current?.(l??null))},[r,u]),h.jsx(q,{field:e,error:u(String(r??"")),children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:i,onChange:g,className:W(F.input,F.textInput)})})},Nt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useRef(o),f=e.includeSeconds??!0;s.useEffect(()=>{c.current=o},[o]);const m=s.useCallback(g=>{if(!g||g.trim()==="")return e.required||e.min||e.max?t("Value required"):null;const l=d=>{const x=d.split(":").map(w=>parseInt(w,10));if(x.some(w=>Number.isNaN(w)))return NaN;let v=0;if(x.length===3)v=x[0]*3600+x[1]*60+x[2];else if(x.length===2)v=x[0]*3600+x[1]*60;else if(x.length===1)v=x[0]*3600;else return NaN;return v},p=l(g);if(Number.isNaN(p))return t("Invalid time format");if(e.min&&typeof e.min=="string"){const d=l(e.min);if(!Number.isNaN(d)&&p<d)return t("Time must be on or after {{1}}",e.min)}if(e.max&&typeof e.max=="string"){const d=l(e.max);if(!Number.isNaN(d)&&p>d)return t("Time must be on or before {{1}}",e.max)}return H(a,e,g,t)??null},[e,a,t]),u=g=>{const l=g.target.value,p=m(l);n?.(l,p)};return s.useEffect(()=>{const g=m(r);g!==i.current&&(i.current=g,c.current?.(g??null))},[r,m]),h.jsx(q,{field:e,error:m(r),children:h.jsx("input",{id:e.name,type:"time",value:r,step:f?1:60,onChange:u,min:typeof e.min=="string"?e.min:void 0,max:typeof e.max=="string"?e.max:void 0,className:W(F.input,F.textInput)})})};function It({pos:e,options:r,onClose:n,onClickOption:o}){const t=s.useRef(null),a=s.useRef(!1),i=typeof window<"u"?document.getElementById("popup-root")||document.body:null;if(s.useEffect(()=>{function p(y){a.current||y.target.dataset?.popupMenu==="item"||t.current&&y.target instanceof Node&&!t.current.contains(y.target)&&n()}return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[n]),!i||r===void 0||r.length===0||!e||e.x==null||e.y==null)return null;const c=e.x,f=e.y,m=typeof window<"u"?window.innerWidth:1024,u=Math.max(0,m-160),g=Math.max(0,Math.min(c,u)),l=Math.max(0,f);return je.createPortal(h.jsx("div",{ref:t,onMouseDown:p=>{p.stopPropagation()},style:{position:"fixed",top:l,left:g,backgroundColor:"var(--reactaform-primary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:"var(--reactaform-border-radius, 4px)",boxShadow:"var(--reactaform-shadow, 0 2px 10px rgba(0,0,0,0.2))",zIndex:9999,minWidth:"var(--reactaform-menu-min-width, 150px)",pointerEvents:"auto"},children:r.map((p,y)=>h.jsx("div",{"data-popup-menu":"item",onMouseDown:d=>{d.stopPropagation(),a.current=!0},onClick:d=>{d.stopPropagation(),d.preventDefault(),o(p),n(),setTimeout(()=>{a.current=!1},100)},style:{padding:"var(--reactaform-menu-item-padding, 8px 12px)",cursor:"pointer",fontSize:"var(--reactaform-menu-item-font-size, 0.8em)",borderBottom:y<r.length-1?"1px solid var(--reactaform-border-light, #eee)":void 0,transition:"background-color 0.15s ease"},onMouseEnter:d=>{d.currentTarget.style.backgroundColor="var(--reactaform-hover-bg, #e0e0e0)"},onMouseLeave:d=>{d.currentTarget.style.backgroundColor="transparent"},children:p.label},p.label??y))}),i)}const fe={};function Ft(e,r){if(e in fe)return;const n=Oe[e]??{},o={},t={},a={};for(const[c,f]of Object.entries(n))typeof f.factor=="number"&&(o[c]=f.factor),t[c]=r(c),a[r(c)]=c;const i=Object.keys(n)[0]??"";fe[e]={default:i,factors:o,labels:t,reverseLabels:a}}function At(e,r,n){if(e==="C"){if(r==="F")return n*(9/5)+32;if(r==="K")return n+273.15}else if(e==="F"){if(r==="C")return(n-32)*5/9;if(r==="K")return(n-32)*5/9+273.15}else if(e==="K"){if(r==="C")return n-273.15;if(r==="F")return(n-273.15)*9/5+32}return n}function Mt(e,r,n){if(!Number.isFinite(e))return[];if(n===fe.temperature)return Object.keys(n.labels).map(a=>{const i=At(r,a,e);return Number.isFinite(i)?{label:`${i.toFixed(6)} ${a}`,value:i.toString(),unit:a}:{label:`${String(i)} ${a}`,value:String(i),unit:a}});const t=n.factors[r];return t===void 0?[]:Object.entries(n.factors).map(([a,i])=>{const c=e/t*i;return Number.isFinite(c)?{label:`${c.toFixed(6)} ${a}`,value:c.toString(),unit:a}:{label:`${String(c)} ${a}`,value:String(c),unit:a}})}function pe(e,r){return e in r.labels?e:r.reverseLabels&&r.reverseLabels[e]?r.reverseLabels[e]:null}const Ot=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,$t=({unitFactors:e,field:r,value:n,onChange:o,onError:t})=>{const{t:a,definitionName:i}=V(),c=s.useRef(null),f=s.useRef(null),m=s.useRef(null),[u,g]=s.useState(null),[l,p]=s.useState(null),[y,d]=s.useState(!1),[x,v]=s.useState(null),[w,I]=s.useState([]),E=s.useCallback((z,M)=>{if(!z||z.trim()==="")return r.required?a("Value required"):null;if(!Ot.test(z))return a("Must be a valid number");const b=H(i,r,[z,M],a);return b||null},[i,r,a]),S=e.reverseLabels!==void 0?e.reverseLabels:Object.fromEntries(Object.entries(e.labels).map(([z,M])=>[M,z]));s.useEffect(()=>{const z=String(n[0]);let M=n[1]??e.default;M=pe(M,e)||M;const b=document.activeElement;b===c.current||b===f.current||(c.current&&(c.current.value=z),f.current&&(f.current.value=M),m.current!==null&&(cancelAnimationFrame(m.current),m.current=null),m.current=requestAnimationFrame(()=>{m.current=null,g(null),p(null)}))},[n,e]),s.useEffect(()=>()=>{m.current!==null&&(cancelAnimationFrame(m.current),m.current=null)},[]);const R=s.useRef(null),k=s.useRef(t);s.useEffect(()=>{k.current=t},[t]),s.useEffect(()=>{const z=String(n[0]);let M=n[1]??e.default;M=pe(M,e)||M;const b=E(z,M);b!==R.current&&(R.current=b,k.current?.(b??null))},[n,e,E]);const C=(z,M,b)=>{const j=S[M]||M;o?.([z,j],b)},N=z=>{const M=z.target.value,b=f.current?f.current.value:e.default,j=E(M,b);g(M),C(M,b,j)},A=z=>{const M=z.target.value,b=c.current?c.current.value:String(n[0]??""),j=E(b,M);p(M),f.current&&(f.current.value=M),C(b,M,j)},$=z=>{const M=c.current?c.current.value:String(n[0]??""),b=parseFloat(M),j=f.current?f.current.value:e.default;if(E(M,j)||!M.trim()||!Number.isFinite(b))return;const B=z.currentTarget.getBoundingClientRect(),Z=B.left,ee=B.bottom;v({x:Z,y:ee});const T=Mt(b,j,e);if(T.length===0){I([]),d(!1);return}I(T),d(O=>!O)},D=z=>{const{value:M,unit:b}=z;d(!1),v(null),c.current&&(c.current.value=M),f.current&&(f.current.value=b),g(M),p(b);const j=E(M,b);C(M,b,j)},U=String(n[0]??""),ne=pe(n[1]??e.default,e)||(n[1]??e.default),K=u??U,J=!!E(K,l??ne)||!K.trim(),Q={width:"var(--reactaform-unit-btn-width, 2.5em)",height:"var(--reactaform-unit-btn-height, 2.5em)",padding:"var(--reactaform-unit-btn-padding, 0)",border:"none",borderRadius:"var(--reactaform-button-border-radius, var(--reactaform-border-radius, 0.25em))",backgroundColor:J?"var(--reactaform-button-disabled-bg, #cccccc)":"var(--reactaform-button-bg, var(--reactaform-success-color))",color:"var(--reactaform-button-text, #ffffff)",cursor:J?"var(--reactaform-button-disabled-cursor, not-allowed)":"pointer",opacity:J?+"var(--reactaform-button-disabled-opacity, 0.6)":1,display:"flex",alignItems:"center",justifyContent:"center"};return h.jsx(q,{field:r,error:E(U,ne),children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-unit-gap, 8px)",width:"100%"},children:[h.jsx("input",{type:"text",ref:c,defaultValue:String(n[0]??""),onChange:N,style:{width:"var(--reactaform-unit-input-width, 100px)"},className:W(F.input,F.textInput)}),h.jsx("select",{ref:f,defaultValue:pe(n[1]??e.default,e)||(n[1]??e.default),onChange:A,className:W(F.input,F.inputSelect),children:Object.keys(e.labels).map(z=>h.jsx("option",{value:z,children:e.labels[z]??z},z))}),h.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[h.jsx("button",{onClick:$,"aria-disabled":J,disabled:J,style:Q,className:F.button,children:h.jsx("span",{style:{fontSize:"var(--reactaform-unit-btn-icon-size, 1em)",lineHeight:"1",transform:"translateY(-1px)",pointerEvents:"none"},children:"⟷"})}),y&&w&&h.jsx(It,{pos:x,options:w,onClose:()=>{v(null),d(!1)},onClickOption:D})]})]})})};function Vt({field:e,value:r,onChange:n}){const{t:o}=V(),t=e.dimension;if(!t)return null;fe[t]||Ft(t,o);const a=fe[t];return a?h.jsx($t,{unitFactors:a,field:e,value:r,onChange:n}):null}const Ue=/^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i,We=e=>{try{return new URL(e),!0}catch{return!1}},Dt=({field:e,value:r,onChange:n,onError:o})=>{const{t,definitionName:a}=V(),i=s.useRef(null),c=s.useCallback(g=>{const l=g.trim();if(l==="")return e.required?t("Value required"):null;if(!Ue.test(l)&&!We(l)){const y=e.allowRelative===!0;let d=!1;if(Ue.test(l)||We(l))d=!0;else if(y)try{new URL(l,"http://example.com"),d=!0}catch{d=!1}if(!d)return t("Must be a valid URL")}return H(a,e,l,t)??null},[a,e,t]),f=g=>{const l=g.target.value,p=c(l);n?.(l.trim(),p)},m=s.useRef(null),u=s.useRef(o);return s.useEffect(()=>{u.current=o},[o]),s.useEffect(()=>{const g=r??"",l=c(g);i.current&&i.current.value!==String(g)&&(i.current.value=String(g)),l!==m.current&&(m.current=l,u.current?.(l??null))},[r,c]),h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"url",defaultValue:String(r??""),ref:i,onChange:f,style:{alignItems:"left"},className:W(F.input,F.textInput),placeholder:"https://example.com"})})},Ee=new ge,zt=new Set(["checkbox","switch","dropdown","radio","multi-selection","slider","stepper","color","rating"]),ar={checkbox:Ur,color:Yr,date:Gr,dropdown:Kr,email:Zr,file:et,float:it,"float-array":ot,image:lt,int:dt,"int-array":ft,"multi-selection":gt,multiline:pt,password:Ct,phone:yt,radio:xt,rating:St,separator:Qr,slider:jt,string:He,stepper:bt,switch:kt,text:He,time:Nt,unit:Vt,url:Dt};function sr(e,r,n){if(!n&&e in ar){console.warn(`Can't Overwrite Base Component type "${e}".`);return}if(zt.has(e)){Ee.register(e,r);return}const o=t=>{const{callback:i,cancel:c}=Je((...f)=>{const m=t.onChange;typeof m=="function"&&m(...f)},200);return s.useEffect(()=>()=>{c()},[c]),s.createElement(r,{...t,onChange:i})};Ee.register(e,o)}function Tt(e,r){sr(e,r,!1)}function ir(e){return Ee.get(e)}let Ye=!1;function cr(){Ye||(Object.entries(ar).forEach(([e,r])=>{sr(e,r,!0)}),Ye=!0)}const lr=new ge;function ur(e,r){lr.register(e,r)}function Lt(e){return lr.get(e)}ur("Preset_AlertSubmitHandler",(e,r,n)=>{const o={name:r||"Unnamed Instance",version:e.version,definition:e.name,values:n},t=JSON.stringify(o,null,2);alert(t)});const fr=s.memo(({field:e,value:r,handleChange:n,handleError:o})=>{const t=ir(e.type),a=s.useCallback((c,f)=>n(e.name,c,f),[n,e.name]),i=s.useCallback(c=>o?.(e.name,c),[o,e.name]);return t?h.jsx(t,{field:e,value:r,onChange:a,onError:i}):null},(e,r)=>e.field===r.field&&e.value===r.value&&e.handleChange===r.handleChange&&e.handleError===r.handleError);fr.displayName="FieldWrapper";const mr=(e,r,n,o)=>h.jsx(fr,{field:e,value:r[e.name],handleChange:n,handleError:o},e.name),dr=s.memo(({groupName:e,isOpen:r,fields:n,valuesMap:o,handleChange:t,handleError:a,toggleGroup:i,t:c})=>{const f=s.useCallback(()=>i(e),[i,e]),{formStyle:m,fieldStyle:u}=V(),g=s.useMemo(()=>({border:"1px solid var(--reactaform-border-color, #bbb)",padding:"var(--reactaform-fieldset-padding, 0.5em)",borderRadius:"var(--reactaform-border-radius, 4px)",marginBottom:"var(--reactaform-space, 8px)",...m?.fieldset||{},...u?.fieldset||{}}),[m,u]),l=s.useMemo(()=>({fontWeight:"bold",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 var(--reactaform-space, 8px)",color:"var(--reactaform-text-color, inherit)",...m?.legend||{},...u?.legend||{}}),[m,u]);return h.jsxs("fieldset",{style:g,children:[h.jsxs("legend",{onClick:f,style:l,children:[h.jsx("span",{children:c(e)}),h.jsx("span",{children:r?"▼":"▶"})]}),r&&n.map(p=>h.jsx("div",{children:mr(p,o,t,a)},p.name))]})});dr.displayName="FieldGroup";const Pt=(e,r,n,o,t,a,i,c,f)=>{const m=r.slice(0,c).filter(p=>i[p.name]),g=zr(m).groups,l=[];return g.forEach(p=>{if(p.name){const y=e[p.name]??!0;l.push(h.jsx(dr,{groupName:p.name,isOpen:y,fields:p.fields,valuesMap:n,handleChange:t,handleError:a,toggleGroup:f,t:o},p.name))}else p.fields.forEach(y=>l.push(h.jsx("div",{children:mr(y,n,t,a)},y.name)))}),l},_t=e=>{const r={};return e.forEach(n=>{r[n.name]=!1}),r},$e=(e,r,n,o)=>{const t=r[e];if(!t?.children)return;const a=n[e],i=a!=null?String(a):"";(t.children[i]||[]).forEach(f=>{o[f]=!0,$e(f,r,n,o)})},pr=(e,r,n)=>{const o=r[e];o?.children&&Object.values(o.children).flat().forEach(t=>{n[t]=!1,pr(t,r,n)})},qt=(e,r,n,o)=>{const t={...n};return e.forEach(a=>{(!a.parents||Object.keys(a.parents).length===0)&&(t[a.name]=!0,$e(a.name,o,r,t))}),t},Bt=(e,r,n,o,t)=>{const a={...e};if(pr(o,r,a),t!=null){const i=r[o];if(i?.children){const c=String(t);(i.children[c]||[]).forEach(m=>{a[m]=!0,$e(m,r,n,a)})}}return a};function Ht(e,r,n,o,t){const a=Object.values(t).filter(Boolean);if(a.length>0)return{success:!1,message:o("Please fix validation errors before submitting."),errors:a};const i={...n},c=[];if(e&&Array.isArray(e.properties))for(const m of e.properties){const u=m.name,g=i[u];if(g==null)continue;const l=m.type;try{if(l==="int"||l==="number"||l==="float"){const p=Number(String(g).trim());isNaN(p)?c.push(o(`Invalid number format for field ${m.displayName||u}`)):i[u]=p}else if(l==="int-array"||l==="float-array"){const y=String(g).split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const x=Number(d);return isNaN(x)?(c.push(o(`Invalid number "${d}" in array for field ${m.displayName||u}`)),0):x});c.length===0&&(i[u]=y)}}catch(p){c.push(o(`Error processing field ${m.displayName||u}: ${p}`))}}if(c.length>0)return{success:!1,message:o("Data transformation errors occurred."),errors:c};const f=er(e,i,o);if(f&&f.length>0)return{success:!1,message:"Validation Fail",errors:f};if(e&&typeof e.submitHandlerName=="string"){const m=Lt(e.submitHandlerName);if(m)try{const u=m(e,r?.name??null,i,o);if(u&&u.length>0)return{success:!1,message:o("Submission failed."),errors:Array.isArray(u)?u:[u]}}catch(u){return{success:!1,message:o("Submission handler error occurred."),errors:[String(u)]}}}return{success:!0,message:o("Form submitted successfully."),data:i}}const gr=({definition:e,instance:r,chunkSize:n=50,chunkDelay:o=50})=>{const{properties:t,displayName:a}=e,i=V(),{t:c,formStyle:f,language:m}=i,u={...i,definitionName:e?.name??i.definitionName},[g,l]=s.useState("en"),[p,y]=s.useState([]),[d,x]=s.useState({}),[v,w]=s.useState({}),[I,E]=s.useState({}),[S,R]=s.useState({}),[k,C]=s.useState({}),[N,A]=s.useState(null),[$,D]=s.useState(null),[U,ne]=s.useState(0),[K,ae]=s.useState(!1),[J,Q]=s.useState(!1),[z,M]=s.useState(r.name||""),b=s.useRef(r),j=s.useRef(!1);s.useEffect(()=>{const O=Object.fromEntries(t.map(_=>[_.name,{..._,children:{}}]));t.forEach(_=>{_.parents&&Object.entries(_.parents).forEach(([se,he])=>{const ie=O[se];ie&&he.forEach(yr=>{ie.children||(ie.children={});const Ve=String(yr);ie.children[Ve]=[...ie.children[Ve]||[],_.name]})})}),Dr(t,O);const L=Object.values(O),Y={};L.forEach(_=>{if(_.type==="unit"){const se=typeof _.defaultValue=="number"?String(_.defaultValue):"",he=typeof _.defaultUnit=="string"?_.defaultUnit:String(_.defaultUnit??"m");Y[_.name]=[se,he]}else Y[_.name]=_.defaultValue}),b.current=r,Object.keys(r.values).forEach(_=>{O[_]!==void 0&&(Y[_]=r.values[_])});const G=_t(L),X={};L.forEach(_=>{_.group&&!(_.group in X)&&(X[_.group]=!0)});const oe=requestAnimationFrame(()=>{y(L),x(O),w(Y),E(qt(L,Y,G,O)),R(X),ae(!0),M(r.name)});return()=>cancelAnimationFrame(oe)},[t,r,e]),s.useEffect(()=>{if(!K||U>=p.length)return;const O=setTimeout(()=>{ne(L=>Math.min(L+n,p.length))},o);return()=>clearTimeout(O)},[K,U,p.length,n,o]);const P=s.useCallback((O,L,Y)=>{A(null),D(null),w(G=>{const X={...G,[O]:L},oe=d[O];return oe&&["checkbox","dropdown","multi-select","radio","switch"].includes(oe.type)&&E(se=>Bt(se,d,X,O,String(L))),X}),C(G=>Y?{...G,[O]:Y}:Object.fromEntries(Object.entries(G).filter(([oe])=>oe!==O)))},[d,A,D]);s.useEffect(()=>{let O=0;return O=requestAnimationFrame(()=>{m!==g&&(l(m||"en"),A(null),D(null))}),()=>cancelAnimationFrame(O)},[m,g]),s.useEffect(()=>{let O=0;return O=requestAnimationFrame(()=>{if(j.current){j.current=!1,b.current=r,M(r.name||"");return}b.current=r,A(null),D(null),M(r.name||"")}),()=>cancelAnimationFrame(O)},[r,r.name]);const B=s.useCallback((O,L)=>{C(Y=>L?{...Y,[O]:String(L)}:Object.fromEntries(Object.entries(Y).filter(([X])=>X!==O)))},[]),Z=()=>{j.current=!0;const O=b.current?.name;b.current.name=z;const L=Ht(e,b.current,v,c,k),Y=typeof L.message=="string"?L.message:String(L.message),G=Object.values(L.errors??{}).join(`
|
|
293
|
-
`);
|
|
294
|
-
`+G:
|
|
292
|
+
<%s key={someKey} {...props} />`,H,L,$,L),V[L+H]=!0)}if(L=null,O!==void 0&&(n(O),L=""+O),i(C)&&(n(C.key),L=""+C.key),"key"in C){O={};for(var T in C)T!=="key"&&(O[T]=C[T])}else O=C;return L&&c(O,typeof b=="function"?b.displayName||b.name||"Unknown":b),d(b,L,O,t(),X,re)}function f(b){l(b)?b._store&&(b._store.validated=1):typeof b=="object"&&b!==null&&b.$$typeof===j&&(b._payload.status==="fulfilled"?l(b._payload.value)&&b._payload.value._store&&(b._payload.value._store.validated=1):b._store&&(b._store.validated=1))}function l(b){return typeof b=="object"&&b!==null&&b.$$typeof===y}var g=s,y=Symbol.for("react.transitional.element"),p=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),R=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),E=Symbol.for("react.consumer"),k=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),I=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),M=Symbol.for("react.client.reference"),z=g.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,B=Object.prototype.hasOwnProperty,Q=Array.isArray,K=console.createTask?console.createTask:function(){return null};g={react_stack_bottom_frame:function(b){return b()}};var oe,J={},ee=g.react_stack_bottom_frame.bind(g,o)(),Y=K(a(o)),V={};le.Fragment=x,le.jsx=function(b,C,O){var H=1e4>z.recentlyCreatedOwnerStacks++;return u(b,C,O,!1,H?Error("react-stack-top-frame"):ee,H?K(a(b)):Y)},le.jsxs=function(b,C,O){var H=1e4>z.recentlyCreatedOwnerStacks++;return u(b,C,O,!0,H?Error("react-stack-top-frame"):ee,H?K(a(b)):Y)}})()),le}var Te;function Sr(){return Te||(Te=1,process.env.NODE_ENV==="production"?me.exports=vr():me.exports=wr()),me.exports}var h=Sr();const ke=s.createContext(void 0),D=()=>{const e=s.useContext(ke);if(!e)throw new Error("❌ useReactaFormContext must be used within a <ReactaFormProvider>");return e};class ge{map={};register(r,n){this.map[r]=n}get(r){return this.map[r]}has(r){return r in this.map}list(){return Object.keys(this.map)}entries(){return Object.entries(this.map)}values(){return Object.values(this.map)}size(){return Object.keys(this.map).length}unregister(r){return r in this.map?(delete this.map[r],!0):!1}clear(){this.map={}}registerAll(r){Array.isArray(r)?r.forEach(([n,a])=>this.register(n,a)):Object.entries(r).forEach(([n,a])=>this.register(n,a))}getOrDefault(r,n){return this.get(r)??n}}function Je(e,r=300,n){const a=s.useRef(void 0),t=s.useRef(e),o=s.useRef(null),i=s.useRef(!1);s.useEffect(()=>{t.current=e},[e]),s.useEffect(()=>()=>{a.current!==void 0&&(window.clearTimeout(a.current),a.current=void 0)},[]);const c=s.useCallback(()=>{a.current!==void 0&&(window.clearTimeout(a.current),a.current=void 0),o.current=null,i.current=!1},[]),m=s.useCallback(()=>{if(a.current!==void 0&&(window.clearTimeout(a.current),a.current=void 0),o.current)try{t.current(...o.current)}finally{o.current=null,i.current=!1}},[]);return{callback:s.useCallback((...u)=>{if(n?.leading===!0&&!i.current){i.current=!0,t.current(...u),window.clearTimeout(a.current),a.current=window.setTimeout(()=>{i.current=!1,a.current=void 0},r);return}o.current=u,window.clearTimeout(a.current),a.current=window.setTimeout(()=>{a.current=void 0,o.current&&(t.current(...o.current),o.current=null,i.current=!1)},r)},[r,n?.leading]),cancel:c,flush:m}}const A={field:"reactaform-field",label:"reactaform-label",input:"reactaform-input",textInput:"reactaform-input--text",inputNumber:"reactaform-input--number",inputSelect:"reactaform-select",rangeInput:"reactaform-input--range",button:"reactaform-button"},U=(...e)=>{const r=[];for(const n of e)n&&(typeof n=="string"?r.push(n):typeof n=="object"&&Object.entries(n).forEach(([a,t])=>{t&&r.push(a)}));return r.join(" ")},Ge=({content:e,size:r="medium",animation:n=!0})=>{const{t:a,darkMode:t,formStyle:o,fieldStyle:i}=D(),[c,m]=s.useState(!1),[d,u]=s.useState({x:0,y:0}),[f,l]=s.useState(!1),g=s.useRef(null),y=s.useRef(null),p=s.useRef(null),x=s.useMemo(()=>{const k={icon:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:"1.2em",height:"1.2em",fontSize:"0.9em",fontWeight:"bold",borderRadius:"50%",backgroundColor:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.06)",color:t?"#f0f0f0":"#333",border:`1px solid ${t?"rgba(255,255,255,0.2)":"rgba(0,0,0,0.1)"}`,cursor:"pointer",transition:n?"all 0.2s ease":void 0,marginLeft:"0.3em"},text:{...{small:{padding:"4px 8px",fontSize:"11px",maxWidth:"200px"},medium:{padding:"6px 10px",fontSize:"12px",maxWidth:"240px"},large:{padding:"8px 12px",fontSize:"13px",maxWidth:"280px"}}[r],position:"absolute",backgroundColor:`var(--reactaform-tooltip-color-bg, ${t?"rgba(45,45,45,0.95)":"rgba(60,60,60,0.92)"})`,color:`var(--reactaform-tooltip-color, ${t?"#f0f0f0":"#fff"})`,borderRadius:"6px",border:`1px solid ${t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)"}`,boxShadow:t?"0 8px 16px rgba(0,0,0,0.4)":"0 6px 18px rgba(0,0,0,0.12)",zIndex:2147483647,opacity:0,visibility:"hidden",transition:n?"opacity 0.2s ease, visibility 0.2s ease":void 0,pointerEvents:"none",whiteSpace:"normal",wordBreak:"break-word",boxSizing:"border-box"},textVisible:{opacity:1,visibility:"visible"}},w=(N,I,j)=>{const M=N?.[I];return(j&&M?M[j]:void 0)??{}};return{icon:{...k.icon,...w(o,"tooltip","icon"),...w(i,"tooltip","icon")},text:{...k.text,...w(o,"tooltip","text"),...w(i,"tooltip","text")},textVisible:k.textVisible}},[t,r,n,o,i]);s.useEffect(()=>{if(c){const E=requestAnimationFrame(()=>l(!1)),k=requestAnimationFrame(()=>{if(g.current){const w=g.current.getBoundingClientRect(),S=8;p.current=w;const N=w.right+S,I=w.top;u({x:N,y:I}),l(!0)}});return()=>{cancelAnimationFrame(k),cancelAnimationFrame(E)}}else requestAnimationFrame(()=>l(!1))},[c]),s.useEffect(()=>{if(!f)return;const E=requestAnimationFrame(()=>{if(!y.current)return;const k=y.current.getBoundingClientRect(),w=8,S=typeof window<"u"?window.innerWidth:1024,N=typeof window<"u"?window.innerHeight:768;let I=d.x,j=d.y;const F=p.current;F&&(I=F.right+w,j=F.top+F.height/2-k.height/2+-4,I+k.width>S-w&&(I=F.left-w-k.width)),I+k.width>S-w&&(I=Math.max(w,S-k.width-w)),I<w&&(I=w),j+k.height>N-w&&(j=Math.max(w,N-k.height-w)),j<w&&(j=w),(I!==d.x||j!==d.y)&&u({x:I,y:j})});return()=>cancelAnimationFrame(E)},[f,d.x,d.y]);const R=typeof document<"u"?document.getElementById("popup-root"):null,v=h.jsx("div",{ref:y,style:{...x.text,transform:f?"translateY(0) scale(1)":"translateY(-4px) scale(0.98)",transition:"opacity 120ms ease, transform 120ms ease, visibility 120ms ease",width:240,...f?x.textVisible:{},top:d.y,left:d.x},"data-reactaform-theme":t?"dark":"light",children:a(e)});return h.jsxs(h.Fragment,{children:[h.jsx("span",{"data-testid":"tooltip-icon",ref:g,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{...x.icon},children:"?"}),c&&(R?je.createPortal(v,R):v)]})},ve=s.memo(({field:e,error:r,children:n,showLabel:a=!0})=>{const{t}=D(),o=e?.labelLayout==="column-center"?"center":"left";return h.jsxs("div",{className:`${A.field} column-layout`,style:{display:"flex",flexDirection:"column",gap:"var(--reactaform-label-gap, 4px)","--label-align":o},children:[a&&h.jsx("div",{style:{textAlign:o,width:"100%"},children:h.jsx("label",{id:`${e.name}-label`,className:A.label,htmlFor:e.name,style:{textAlign:o,width:"100%",minWidth:"unset",display:"block",marginBottom:"10px"},children:t(e.displayName)})}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)",width:"100%"},children:[h.jsx("div",{style:{flex:1,minWidth:0,maxWidth:"100%"},children:h.jsx("div",{style:{width:"100%"},children:n})}),e.tooltip&&h.jsx(Ge,{content:e.tooltip})]}),r&&h.jsx(Ne,{id:`${e.name}-error`,children:r})]})});ve.displayName="ColumnFieldLayout";const Ke=s.memo(({field:e,error:r,children:n,rightAlign:a=!1})=>{const{t}=D(),o=s.useMemo(()=>({display:"flex",flexDirection:"column",gap:0}),[]),i=s.useMemo(()=>({display:"flex",flexDirection:"row",alignItems:"center",gap:"3px"}),[]);return h.jsxs("div",{className:`${A.field} row-layout`,children:[h.jsx("label",{id:`${e.name}-label`,className:A.label,htmlFor:e.name,style:{textAlign:"left",justifyContent:"flex-start"},children:t(e.displayName)}),h.jsxs("div",{style:o,children:[h.jsxs("div",{style:i,children:[a?h.jsx("div",{style:{display:"flex",flex:1,justifyContent:"flex-end",alignItems:"center",gap:"var(--reactaform-inline-gap, 8px)"},children:n}):n,e.tooltip&&h.jsx(Ge,{content:e.tooltip})]}),r&&h.jsx(Ne,{id:`${e.name}-error`,children:r})]})]})});Ke.displayName="RowFieldLayout";const q=({field:e,error:r,children:n,rightAlign:a=!1})=>e.labelLayout==="column-left"||e.labelLayout==="column-center"?h.jsx(ve,{field:e,error:r,showLabel:!0,children:n}):e.type==="checkbox"||e.type==="switch"?h.jsx(ve,{field:e,error:r,showLabel:!1,children:n}):h.jsx(Ke,{field:e,error:r,rightAlign:a,children:n}),Ne=s.memo(({children:e,id:r})=>{const n=s.useMemo(()=>({color:"var(--reactaform-error-color)",fontSize:"13px",marginTop:"4px",fontWeight:"var(--reactaform-font-weight)",display:"flex",flex:1,justifyContent:"flex-start",alignItems:"flex-start"}),[]);return h.jsx("div",{id:r,style:n,children:e})});Ne.displayName="ErrorDiv";const Xe=s.memo(({name:e,onChange:r})=>{const{t:n}=D();return h.jsxs("div",{style:{marginBottom:16},children:[h.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 2fr",gap:12,alignItems:"center"},children:[h.jsx("label",{htmlFor:"instance-name-input",style:{margin:0,fontSize:"0.95em",fontWeight:500,color:"var(--reactaform-text-color, #333)"},children:n("Instance Name")}),h.jsx("input",{id:"instance-name-input",type:"text",value:e,onChange:a=>r(a.target.value),style:{width:"100%",padding:"var(--reactaform-input-padding, 8px 12px)",fontSize:"var(--reactaform-input-font-size, 14px)",border:"1px solid var(--reactaform-input-border, #ddd)",borderRadius:"var(--reactaform-border-radius, 4px)",backgroundColor:"var(--reactaform-input-bg, #fff)",color:"var(--reactaform-text-color, #333)",boxSizing:"border-box"},placeholder:n("Enter instance name")})]}),h.jsx("div",{style:{height:"1px",backgroundColor:"var(--reactaform-separator, #e6e6e6)",marginTop:12,marginBottom:12}})]})});Xe.displayName="InstanceName";class Cr extends ge{registerInCategory(r,n,a){this.get(r)||this.register(r,{});const t=this.get(r);t[n]=a}getFromCategory(r,n){return this.get(r)?.[n]}listFromCategory(r){return Object.keys(this.get(r)||{})}listCategories(){return this.list()}}const Ze=new ge,Qe=new Cr;function Rr(e,r){Ze.register(e,r)}function Er(e,r,n){Qe.registerInCategory(e,r,n)}function jr(e,r){return Qe.getFromCategory(e,r)||null}function kr(e){return Ze.get(e)||null}const be=new Map,ye=new Map;function P(e,r,n,a){if(r&&typeof r.validationHandlerName=="string"){const t=`${e}:${r.validationHandlerName}`;if(!be.has(t)){const i=jr(e,r.validationHandlerName);be.set(t,i)}const o=be.get(t);if(o)return o(n,a)||null}return null}function er(e,r,n){if(e&&typeof e.validationHandlerName=="string"){const a=e.validationHandlerName;if(!ye.has(a)){const o=kr(a);ye.set(a,o)}const t=ye.get(a);if(t)return t(r,n)||null}return null}function ne(e){return typeof e=="object"&&e!==null}function Ie(e){if(!ne(e))return!1;const r=e;return typeof r.name=="string"&&typeof r.displayName=="string"}function rr(e){if(!ne(e))return!1;const r=e;return typeof r.name!="string"||typeof r.version!="string"||!Array.isArray(r.properties)?!1:r.properties.every(n=>Ie(n))}function we(e){try{return typeof File<"u"&&e instanceof File}catch{const r=ne(e)?e:void 0;return!!r&&typeof r.name=="string"&&typeof r.size=="number"}}function Nr(e,r,n={}){try{const{includeMetadata:a=!1,dateFormat:t="iso",fileHandling:o="metadata",prettify:i=!1,excludeFields:c=[],includeOnlyFields:m=[]}=n;if(!e||typeof e!="object")return{success:!1,error:"Instance must be a valid object"};const d=[],u=[],f={},g=(rr(r)||ne(r)&&Array.isArray(r.properties)?r.properties:[]).filter(Ie),y=new Map(g.map(x=>[x.name,x]));for(const[x,R]of Object.entries(e)){if(c.includes(x)){u.push(x);continue}if(m.length>0&&!m.includes(x)){u.push(x);continue}if(R===void 0)continue;const v=y.get(x);try{f[x]=Ir(R,v,{dateFormat:t,fileHandling:o})}catch(E){d.push(`Error serializing field '${x}': ${String(E)}`),f[x]=null}}return a&&(f._metadata={serializedAt:new Date().toISOString(),version:(ne(r)?r.version:void 0)||"1.0.0",fieldCount:Object.keys(f).length-1}),{success:!0,data:i?JSON.stringify(f,null,2):JSON.stringify(f),metadata:{fieldCount:Object.keys(f).length,excludedFields:u,warnings:d}}}catch(a){return{success:!1,error:`Serialization failed: ${a instanceof Error?a.message:"Unknown error"}`}}}function Ir(e,r,n={}){const{dateFormat:a="iso",fileHandling:t="metadata"}=n;if(e==null)return null;if(r)switch(r.type){case"date":case"datetime":case"date-time":return Le(e,a);case"file":return Pe(e,t);case"int":case"integer":return typeof e=="string"?parseInt(e,10):e;case"float":case"number":return typeof e=="string"?parseFloat(e):e;case"boolean":return typeof e=="string"?e==="true":!!e;case"int-array":case"float-array":return Array.isArray(e)?e.map(o=>typeof o=="string"?Number(o):o):e;default:return e}return e instanceof Date?Le(e,a):we(e)||Array.isArray(e)&&we(e[0])?Pe(e,t):e}function Le(e,r){let n=null;if(e instanceof Date)n=e;else if(typeof e=="string"){const a=new Date(e);if(!isNaN(a.getTime()))n=a;else return e}else return e;switch(r){case"timestamp":return n.getTime();case"locale":return n.toLocaleString();case"iso":default:return n.toISOString()}}function Pe(e,r){return r==="skip"?null:Array.isArray(e)?e.map(n=>_e(n,r)):_e(e,r)}function _e(e,r){if(!we(e))return e;const n=e;return r==="metadata"?{name:n.name,size:n.size,type:n.type,lastModified:n.lastModified}:{name:n.name,size:n.size,type:n.type,lastModified:n.lastModified,_note:"Base64 encoding requires async implementation"}}function Ar(e,r,n={}){try{const{strict:a=!1,validateTypes:t=!0,preserveUnknownFields:o=!0,dateFormat:i="auto"}=n;if(!e||typeof e!="string")return{success:!1,error:"Serialized data must be a non-empty string"};let c;try{c=JSON.parse(e)}catch(p){return{success:!1,error:`Invalid JSON: ${p instanceof Error?p.message:"Unknown parsing error"}`}}if(!c||typeof c!="object")return{success:!1,error:"Parsed data must be an object"};const m=[],d=[],u={},l=(rr(r)||ne(r)&&Array.isArray(r.properties)?r.properties:[]).filter(Ie),g=new Map(l.map(p=>[p.name,p]));for(const p of l){const x=p.name,R=c[x];if(R===void 0){a&&p.required&&d.push(`Required field '${x}' is missing`);continue}try{u[x]=Fr(R,p,{validateTypes:t,dateFormat:i})}catch(v){const E=`Error deserializing field '${x}': ${String(v)}`;a?d.push(E):(m.push(E),u[x]=R)}}if(o)for(const[p,x]of Object.entries(c))!g.has(p)&&p!=="_metadata"&&(a&&m.push(`Unknown field '${p}' preserved`),u[p]=x);const y=d.length>0;return{success:!y,data:u,warnings:m.length>0?m:void 0,validationErrors:y?d:void 0}}catch(a){return{success:!1,error:`Deserialization failed: ${a instanceof Error?a.message:"Unknown error"}`}}}function Fr(e,r,n={}){const{validateTypes:a=!0,dateFormat:t="auto"}=n;if(e==null)return e;try{switch(r.type){case"date":case"datetime":case"date-time":return Or(e,t,a);case"int":case"integer":return Se(e,a);case"float":case"number":return Ce(e,a);case"boolean":return Dr(e,a);case"int-array":return qe(e,"integer",a);case"float-array":return qe(e,"number",a);case"string":case"text":case"email":case"url":case"phone":return a?String(e):e;default:return e}}catch(o){if(a)throw new Error(`Type conversion failed: ${String(o)}`);return e}}function Mr(e,r={}){try{const{prettify:n=!0,includeMetadata:a=!0}=r;if(!e||typeof e!="object")return{success:!1,error:"Definition must be a valid object"};const t={...e};return a&&(t._metadata={serializedAt:new Date().toISOString(),version:t.version||"1.0.0",propertyCount:(Array.isArray(t.properties)?t.properties.length:0)||0}),{success:!0,data:n?JSON.stringify(t,null,2):JSON.stringify(t),metadata:{fieldCount:(Array.isArray(t.properties)?t.properties.length:0)||0,excludedFields:[],warnings:[]}}}catch(n){return{success:!1,error:`Definition serialization failed: ${n instanceof Error?n.message:"Unknown error"}`}}}function $r(e,r={}){try{const{strict:n=!1,validateTypes:a=!0}=r;let t;if(typeof e=="string")try{t=JSON.parse(e)}catch(u){return{success:!1,error:`Invalid JSON for definition: ${u instanceof Error?u.message:"Unknown parsing error"}`}}else if(e&&typeof e=="object")t={...e};else return{success:!1,error:"Input must be a string or object"};const o=[],i=[],c=["name","version","displayName"];for(const u of c)if(!t[u])if(n)i.push(`Required field '${u}' is missing`);else switch(o.push(`Missing field '${u}', using default`),u){case"name":t.name="unnamed-definition";break;case"version":t.version="1.0.0";break;case"displayName":t.displayName=t.name||"Unnamed Definition";break}const m=Array.isArray(t.properties)?t.properties:null;m?t.properties=m.map((u,f)=>{const l=ne(u)?u:{},g={...l};if(!l.name){const y=`Property at index ${f} missing 'name'`;n?i.push(y):(o.push(`${y}, using 'field_${f}'`),g.name=`field_${f}`)}return l.displayName||(g.displayName=l.name||`Field ${f}`),l.type||(n&&a?i.push(`Property '${l.name||f}' missing 'type'`):(o.push(`Property '${l.name||f}' missing 'type', using 'string'`),g.type="string")),l.defaultValue===void 0&&(g.defaultValue=null),l.required===void 0&&(g.required=!1),g}):n?i.push("Properties must be an array"):(o.push("Properties not found or invalid, using empty array"),t.properties=[]);const d=i.length>0;return{success:!d,data:t,warnings:o.length>0?o:void 0,validationErrors:d?i:void 0}}catch(n){return{success:!1,error:`Definition deserialization failed: ${n instanceof Error?n.message:"Unknown error"}`}}}function Or(e,r,n){if(e instanceof Date)return e;if(typeof e=="number"){const a=new Date(e);if(n&&isNaN(a.getTime()))throw new Error(`Invalid timestamp: ${e}`);return a}if(typeof e=="string"){const a=new Date(e);if(n&&isNaN(a.getTime()))throw new Error(`Invalid date string: ${e}`);return a}if(n)throw new Error(`Cannot convert ${typeof e} to Date`);return e}function Se(e,r){if(typeof e=="number"&&Number.isInteger(e))return e;if(typeof e=="string"&&e.trim()!==""){const n=parseInt(e,10);if(r&&isNaN(n))throw new Error(`Cannot convert "${e}" to integer`);return n}if(r)throw new Error(`Cannot convert ${typeof e} to integer`);return e}function Ce(e,r){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim()!==""){const n=parseFloat(e);if(r&&isNaN(n))throw new Error(`Cannot convert "${e}" to number`);return n}if(r)throw new Error(`Cannot convert ${typeof e} to number`);return e}function Dr(e,r){if(typeof e=="boolean")return e;if(typeof e=="string"){const n=e.toLowerCase();if(n==="true"||n==="1")return!0;if(n==="false"||n==="0")return!1;if(r)throw new Error(`Cannot convert "${e}" to boolean`)}if(typeof e=="number")return!!e;if(r)throw new Error(`Cannot convert ${typeof e} to boolean`);return e}function qe(e,r,n){if(!Array.isArray(e)){if(typeof e=="string")return e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>r==="integer"?Se(t,n):Ce(t,n));if(n)throw new Error(`Expected array, got ${typeof e}`);return e}return e.map((a,t)=>{try{return r==="integer"?Se(a,n):Ce(a,n)}catch(o){if(n)throw new Error(`Array element ${t}: ${o}`);return a}})}const Vr=(e,r)=>{const n=new Map;let a=null,t=null,o=0;for(const i of e){const c=i.group;if(!c){a=null,t=null;continue}if(c===a)r[i.name].group=t??c;else{if(!n.has(c))n.set(c,1),t=null,r[i.name].group=c;else{const m=n.get(c),d=`${c}(${m})`;n.set(c,m+1),t=d,r[i.name].group=d,o++}a=c}}return o},zr=(e,r={})=>{const{includeEmpty:n=!0}=r,a=[];let t=null,o=[],i=0;for(const m of e){const d=m.group||null;d!==t?((o.length>0||n)&&(o.length===0&&i++,a.push({name:t,fields:o})),t=d,o=[m]):o.push(m)}(o.length>0||n)&&(o.length===0&&i++,a.push({name:t,fields:o}));const c=Math.max(0,...a.map(m=>m.fields.length));return{groups:a,metadata:{totalGroups:a.length,emptyGroups:i,largestGroup:c}}},xe=new Map,de=new Map,te=new Set,Re=new Map,Tr=async e=>{try{let r;switch(e.toLowerCase()){case"fr":r=(await Promise.resolve().then(()=>require("./common-DLr0UoG9.cjs"))).default;break;case"de":r=(await Promise.resolve().then(()=>require("./common-BgCI2TVb.cjs"))).default;break;case"es":r=(await Promise.resolve().then(()=>require("./common-DRIndE7S.cjs"))).default;break;case"zh-cn":r=(await Promise.resolve().then(()=>require("./common-BeJOG7Z0.cjs"))).default;break;case"en":r={};break;default:r={}}return{success:!0,translations:r,fromCache:!1}}catch(r){return{success:!1,translations:{},error:`Failed to load common translations for ${e}: ${r}`}}},Lr=async e=>{if(!e)return{success:!1,translations:{},error:"Language is required"};const r=e.toLowerCase();if(r==="en")return{success:!0,translations:{},fromCache:!1};if(xe.has(r))return{success:!0,translations:xe.get(r)||{},fromCache:!0};const n=await Tr(r);return n.success&&(xe.set(r,n.translations),Re.set(r,{loadedAt:new Date,size:Object.keys(n.translations).length,source:"common"})),n},Pr=async(e,r)=>{if(!e||!r)return{success:!1,translations:{},error:"Both language and localizeName are required"};const n=`${e.toLowerCase()}/${r}`;if(te.has(n))return{success:!1,translations:{},error:"Previously failed to load",fromCache:!0};if(de.has(n))return{success:!0,translations:de.get(n)||{},fromCache:!0};try{let a=r;!r.includes("/")&&!r.includes(".")&&(a=`/locales/${e}/${r}.json`);const t=await fetch(a);if(!t.ok){const d=`HTTP ${t.status}: ${t.statusText}`;return t.status===404?(de.set(n,{}),Re.set(n,{loadedAt:new Date,size:0,source:"user"}),{success:!0,translations:{},fromCache:!1}):(te.add(n),{success:!1,translations:{},error:d})}const o=t.headers.get("content-type")||"";!o.includes("application/json")&&!o.includes("text/json")&&tr()&&console.warn(`Translation file at ${a} has unexpected content-type: ${o}`);const i=await t.text();if(!i){const d="Empty translation file";return te.add(n),{success:!1,translations:{},error:d}}let c;try{c=JSON.parse(i)}catch(d){const u=`Invalid JSON in translation file: ${d instanceof Error?d.message:String(d)}`;return te.add(n),{success:!1,translations:{},error:u}}if(!c||typeof c!="object"){const d="Invalid translation file format";return te.add(n),{success:!1,translations:{},error:d}}const m=Object.fromEntries(Object.entries(c).map(([d,u])=>[d,typeof u=="string"?u:String(u)]));if(!m||typeof m!="object"){const d="Invalid translation file format";return te.add(n),{success:!1,translations:{},error:d}}return de.set(n,m),Re.set(n,{loadedAt:new Date,size:Object.keys(m).length,source:"user"}),{success:!0,translations:m,fromCache:!1}}catch(a){const t=`Failed to load user translations: ${a instanceof Error?a.message:"Unknown error"}`;return te.add(n),{success:!1,translations:{},error:t}}};function tr(){try{if(typeof process<"u"&&process?.env?.NODE_ENV==="development")return!0}catch{}return!1}function _r(e,r){return r.length===0?e:e.replace(/\{\{(\d+)\}\}/g,(n,a)=>{const t=parseInt(a,10)-1,o=r[t];if(o==null)return n;try{return String(o)}catch{return n}})}const qr=(e,r,n)=>(a,...t)=>{let o=a,i=!1;return!a||typeof a!="string"?String(a||""):(e.toLowerCase()==="en"?(o=a,i=!0):Object.prototype.hasOwnProperty.call(n,a)?(o=n[a],i=!0):Object.prototype.hasOwnProperty.call(r,a)?(o=r[a],i=!0):o=a,o=_r(o,t),!i&&tr()&&console.debug(`Missing translation for "${a}" in language "${e}"`),o)},Ae={length:["m","cm","mm","km","in","ft","yd","mi"],area:["m^2","cm^2","mm^2","in^2","ft^2","yd^2"],volume:["L","m^3","cm^3","mL","in^3","ft^3","yd^3"],weight:["kg","g","mg","t","lb","oz"],time:["min","s","h","ms","d"],temperature:["C","F","K"],angle:["deg","rad","rev"]},Fe={length:{m:"Meter (m)",mm:"Millimeter (mm)",cm:"Centimeter (cm)",km:"Kilometer (km)",in:"Inch (in)",ft:"Foot (ft)",yd:"Yard (yd)",mi:"Mile (mi)"},area:{"m^2":"Square meter (m^2)","mm^2":"Square millimeter (mm^2)","cm^2":"Square centimeter (cm^2)","in^2":"Square inch (in^2)","ft^2":"Square foot (ft^2)","yd^2":"Square yard (yd^2)"},volume:{L:"Liter (L)","cm^3":"Cubic centimeter (cm^3)","m^3":"Cubic meter (m^3)",mL:"Milliliter (mL)","in^3":"Cubic inch (in^3)","ft^3":"Cubic foot (ft^3)","yd^3":"Cubic yard (yd^3)"},weight:{kg:"Kilogram (kg)",g:"Gram (g)",mg:"Milligram (mg)",t:"Tonne (t)",lb:"Pound (lb)",oz:"Ounce (oz)"},time:{s:"Second (s)",min:"Minute (min)",h:"Hour (h)",ms:"Millisecond (ms)",d:"Day (d)",wk:"Week (wk)"},temperature:{C:"Celsius (C)",F:"Fahrenheit (F)",K:"Kelvin (K)"},angle:{deg:"Degree (deg)",rad:"Radian (rad)",rev:"Revolution (rev)"}},Me={length:{mm:1e3,cm:100,m:1,km:.001,in:100/2.54,ft:100/(2.54*12),yd:100/(2.54*36),mi:1/1609.344},area:{"m^2":1,"mm^2":1e6,"cm^2":1e4,"km^2":1/1e6,"in^2":(100/2.54)**2,"ft^2":(100/(2.54*12))**2,"yd^2":(100/(2.54*36))**2},volume:{"cm^3":1e6,"m^3":1,L:1,mL:1e6,"in^3":(100/2.54)**3,"ft^3":(100/(2.54*12))**3,"yd^3":(100/(2.54*36))**3},weight:{mg:1e6,g:1e3,kg:1,t:.001,lb:1/.45359237,oz:1/.028349523125},time:{ms:1e3,s:1,min:1/60,h:1/3600,d:1/86400,wk:1/604800},temperature:{C:1,F:33.8,K:274.15},angle:{deg:1,rad:Math.PI/180,rev:1/360}},$e={},Br=new Set([...Object.keys(Ae),...Object.keys(Fe),...Object.keys(Me)]);for(const e of Br){const r={},n=Ae[e]??[],a=Fe[e]??{},t=Me[e]??{};for(const o of n){const i=a[o];r[o]={name:typeof i=="string"?i:String(o),shortName:o,factor:Object.prototype.hasOwnProperty.call(t,o)?t[o]:void 0}}for(const[o,i]of Object.entries(a))if(!r[o]){const c=typeof i=="string"?i:String(o);r[o]={name:c,shortName:o,factor:Object.prototype.hasOwnProperty.call(t,o)?t[o]:void 0}}for(const[o,i]of Object.entries(t))r[o]||(r[o]={name:String(o),shortName:String(o),factor:i});$e[e]=r}const Hr=Object.freeze(Object.defineProperty({__proto__:null,dimensionUnitDisplayMap:Fe,dimensionUnitsMap:Ae,dimensonUnitFactorsMap:Me,unitsByDimension:$e},Symbol.toStringTag,{value:"Module"})),Ur=({field:e,value:r,onChange:n,onError:a})=>{const{definitionName:t,t:o}=D(),i=s.useRef(a);s.useEffect(()=>{i.current=a},[a]),s.useEffect(()=>{const f=P(t,e,r??!1,o);i.current?.(f??null)},[r,e,t,o]);const c=f=>{const l=f.target.checked;n?.(l,null)},m=f=>{(f.key===" "||f.key==="Spacebar"||f.key==="Space"||f.key==="Enter")&&(f.preventDefault(),n?.(!r,null))},d=e.name,u=P(t,e,r??!1,o);return h.jsx(q,{field:e,rightAlign:!1,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[h.jsx("label",{className:A.label,htmlFor:d,style:{textAlign:"left",justifyContent:"flex-start"},children:o(e.displayName)}),h.jsx("input",{id:d,"data-testid":"boolean-checkbox",type:"checkbox",checked:!!r,onChange:c,onKeyDown:m,"aria-checked":!!r,"aria-invalid":!!u,"aria-describedby":u?`${e.name}-error`:void 0,style:{cursor:"pointer",margin:"8px 0 8px 0",width:"1.2em",height:"1.2em",verticalAlign:"middle",color:"#FFFFFF",accentColor:"#0000FF",opacity:void 0}})]})})},Be=[{label:"Black",value:"#000000"},{label:"White",value:"#ffffff"},{label:"Red",value:"#ff0000"},{label:"Green",value:"#008000"},{label:"Blue",value:"#0000ff"},{label:"Yellow",value:"#ffff00"},{label:"Cyan",value:"#00ffff"},{label:"Magenta",value:"#ff00ff"},{label:"Orange",value:"#ffa500"},{label:"Purple",value:"#800080"},{label:"Brown",value:"#a52a2a"},{label:"Gray",value:"#808080"},{label:"Light Gray",value:"#d3d3d3"},{label:"Pink",value:"#ffc0cb"}];function nr(e){return/^#([0-9A-F]{3}){1,2}$/i.test(e)}function Wr(e){if(!nr(e))return null;const r=ar(e),n=parseInt(r.slice(1),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function ar(e){return e?(e=e.toLowerCase(),/^#([a-f0-9]){3}$/i.test(e)?"#"+e.slice(1).split("").map(r=>r+r).join(""):e):"#000000"}const Yr=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),[i,c]=s.useState("#000000"),m=s.useRef(null),d=s.useRef(null),u=s.useRef(a);s.useEffect(()=>{u.current=a},[a]),s.useEffect(()=>{const v=r&&nr(r)?r:"#000000",E=ar(v);c(E)},[r]),s.useEffect(()=>{const v=P(o,e,r??"#000000",t);u.current?.(v??null)},[r,e,o,t]);const f=P(o,e,r??"#000000",t),l=v=>{const E=v.target.value;c(E),n?.(E,null)},g=v=>{const E=v.target.value;c(E),n?.(E,null)},y=Be.find(v=>v.value===i),{r:p,g:x,b:R}=Wr(i)||{r:0,g:0,b:0};return h.jsx(q,{field:e,error:f,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[h.jsxs("select",{ref:m,id:e.name,value:i,onChange:l,style:{minWidth:"120px",flex:1},className:U(A.input,A.inputSelect),"aria-invalid":!!f,"aria-describedby":f?`${e.name}-error`:void 0,children:[Be.map(v=>h.jsx("option",{value:v.value,children:t(v.label)},v.value)),y?null:h.jsxs("option",{value:i,children:["(",p,", ",x,", ",R,")"]},i)]}),h.jsx("label",{style:{width:"2.5em",height:"1.8em",display:"inline-block",border:"1px solid #ccc",borderRadius:"4px",backgroundColor:i,cursor:"pointer",overflow:"hidden",flexShrink:0},children:h.jsx("input",{ref:d,id:`${e.name}-color`,type:"color",value:i,onChange:g,style:{opacity:0,width:"100%",height:"100%",border:"none",padding:0,cursor:"pointer"},"aria-invalid":!!f,"aria-describedby":f?`${e.name}-error`:void 0})})]})})},ue=e=>{if(!e)return null;const r=new Date(e);return isNaN(r.getTime())?null:r},Jr=e=>{if(!e)return"";if(/^\d{4}-\d{2}-\d{2}$/.test(e))return ue(e)?e:"";const n=ue(e);if(n){const a=n.getFullYear(),t=String(n.getMonth()+1).padStart(2,"0"),o=String(n.getDate()).padStart(2,"0");return`${a}-${t}-${o}`}return""},Gr=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),{name:i,required:c}=e,m=s.useRef(null),d=s.useRef(a);s.useEffect(()=>{d.current=a},[a]);const u=s.useCallback(l=>{if(!l||l.trim()==="")return c?t("Value required"):null;if(l){const y=ue(l);if(!y)return t("Invalid date format");if(e.minDate){const p=ue(e.minDate);if(p&&y.getTime()<p.getTime())return t("Date must be on or after {{1}}",e.minDate)}if(e.maxDate){const p=ue(e.maxDate);if(p&&y.getTime()>p.getTime())return t("Date must be on or before {{1}}",e.maxDate)}}return P(o,e,l,t)??null},[e,o,t,c]),f=l=>{const g=l.target.value,y=u(g);n?.(g,y)};return s.useEffect(()=>{const l=u(r);l!==m.current&&(m.current=l,d.current?.(l??null))},[r,u]),h.jsx(q,{field:e,error:u(r),children:h.jsx("input",{id:i,type:"date",value:Jr(r),onChange:f,className:U(A.input,A.textInput),...e.minDate?{min:e.minDate}:{},...e.maxDate?{max:e.maxDate}:{},"aria-invalid":!!u(r),"aria-describedby":u(r)?`${i}-error`:void 0})})},Kr=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useRef(a);s.useEffect(()=>{c.current=a},[a]);const m=s.useCallback(u=>u===""||u===null||u===void 0?t("Value required"):!e.options||e.options.length===0?null:e.options.some(l=>l.value===u)?P(o,e,u,t)??null:t("Invalid option selected"),[e,t,o]);s.useEffect(()=>{const u=r!=null?String(r):"",f=m(u);if(f&&e.options&&e.options.length>0){const l=String(e.options[0].value);i.current&&(i.current.value=l),n?.(l,null),c.current?.(null)}else i.current&&(i.current.value=u),c.current?.(f??null)},[r,m,n,e.options]);const d=u=>{const f=u.target.value,l=m(f);n?.(f,l)};return h.jsx(q,{field:e,error:m(String(r??"")),children:h.jsx("select",{id:e.name,"aria-invalid":!!m(String(r??"")),"aria-describedby":m(String(r??""))?`${e.name}-error`:void 0,defaultValue:String(r??""),ref:i,onChange:d,className:U(A.input,A.inputSelect),children:(e.options??[]).map(u=>h.jsx("option",{value:String(u.value),children:t(u.label)},String(u.value)))})})};function Xr(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}const Zr=({field:e,value:r,onChange:n,onError:a})=>{const{definitionName:t,t:o}=D(),i=s.useRef(null),c=s.useCallback(f=>{const l=f.trim();return l===""?e.required?o("Value required"):null:Xr(l)?e.pattern&&!new RegExp(e.pattern).test(l)?e.patternErrorMessage?o(e.patternErrorMessage):o("Email does not match pattern: {{%1}}",{"%1":`${e.pattern}`}):P(t,e,f,o)??null:o("Must be valid email format")},[e,t,o]),m=f=>{const l=f.target.value,g=c(l);n?.(l,g)},d=s.useRef(null),u=s.useRef(a);return s.useEffect(()=>{u.current=a},[a]),s.useEffect(()=>{const f=r??"",l=c(f);i.current&&i.current.value!==String(f)&&(i.current.value=String(f)),l!==d.current&&(d.current=l,u.current?.(l??null))},[r,c]),h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"email",defaultValue:String(r??""),ref:i,onChange:m,className:U(A.input,A.textInput),"aria-invalid":!!c(String(r??"")),"aria-describedby":c(String(r??""))?`${e.name}-error`:void 0})})},Qr=({field:e})=>{const{darkMode:r}=D(),{color:n=r?"#444444":"#CCCCCC",thickness:a=1,margin:t="8px 0"}=e;return h.jsx("div",{style:{width:"auto",height:"0",borderTop:`${a}px solid ${n}`,margin:t}})},et=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),[i,c]=s.useState(!1),m=s.useRef(null),d=s.useRef(a);s.useEffect(()=>{d.current=a},[a]);const u=s.useCallback(v=>e.required&&(!v||Array.isArray(v)&&v.length===0)?t("Value required"):P(o,e,v,t)??null,[e,o,t]),f=s.useMemo(()=>u(r),[r,u]);s.useEffect(()=>{const v=u(r);n?.(r,v),d.current?.(v??null)},[r,u]);const l=v=>{const E=v.target.files;let k=null;if(E&&E.length>0){const S=Array.from(E);e.multiple?k=[...Array.isArray(r)?r:[],...S]:k=S[0]}const w=u(k);n?.(k,w)},g=v=>{v.preventDefault(),v.stopPropagation(),c(!1);const E=v.dataTransfer.files;if(E&&E.length>0){const k=Array.from(E);let w=null;e.multiple?w=[...Array.isArray(r)?r:[],...k]:w=k[0];const S=u(w);n?.(w,S)}},y=v=>{v.preventDefault(),v.stopPropagation(),c(!0)},p=v=>{v.preventDefault(),v.stopPropagation(),c(!1)},x=v=>{if(Array.isArray(r)&&typeof v=="number"){const E=r.filter((S,N)=>N!==v),k=E.length>0?E:null,w=u(k);n?.(k,w)}else{const E=u(null);n?.(null,E)}},R=()=>{const v=Array.isArray(r)?r:r?[r]:[];return v.length===0?null:h.jsx("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:v.map((E,k)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",backgroundColor:"var(--reactaform-input-bg, #fff)",border:"1px solid var(--reactaform-border-color, #d1d5db)",borderRadius:"4px",fontSize:"0.875rem",gap:"8px"},children:[h.jsx("div",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:E.name}),h.jsx("button",{type:"button",onClick:()=>x(Array.isArray(r)?k:void 0),"aria-label":t("Remove file"),style:{background:"transparent",border:"none",color:"var(--reactaform-color-error, #ef4444)",cursor:"pointer",padding:"2px 6px",fontSize:"1.125rem",lineHeight:1,borderRadius:"4px",transition:"background-color 0.2s",flexShrink:0},onMouseEnter:w=>{w.currentTarget.style.backgroundColor="var(--reactaform-bg-hover, #fee)"},onMouseLeave:w=>{w.currentTarget.style.backgroundColor="transparent"},children:"×"})]},`${E.name}-${k}`))})};return h.jsx(q,{field:e,error:f,children:h.jsxs("div",{style:{width:"100%"},children:[h.jsxs("div",{onDrop:g,onDragOver:y,onDragLeave:p,style:{position:"relative",border:`1px dashed ${i?"var(--reactaform-color-primary, #2563eb)":f?"var(--reactaform-color-error, #ef4444)":"var(--reactaform-border-color, #d1d5db)"}`,borderRadius:"var(--reactaform-border-radius, 4px)",padding:"8px 12px",textAlign:"center",backgroundColor:i?"var(--reactaform-bg-hover, #f0f9ff)":"var(--reactaform-input-bg, #fff)",transition:"all 0.2s ease",cursor:"pointer",minHeight:"var(--reactaform-input-height, 34px)",width:"100%",maxWidth:"100%",alignSelf:"stretch",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},onClick:()=>m.current?.click(),onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&(v.preventDefault(),m.current?.click())},role:"button","aria-label":e.multiple?t("Choose Files or Drag & Drop"):t("Choose File or Drag & Drop"),"aria-invalid":!!f,"aria-describedby":f?`${e.name}-error`:void 0,children:[h.jsx("input",{id:e.name,ref:m,type:"file",accept:e.accept,multiple:e.multiple,style:{display:"none"},onChange:l}),h.jsx("div",{style:{fontSize:"1.25rem",opacity:.6,lineHeight:1,flexShrink:0},children:"📁"}),h.jsx("div",{style:{fontSize:"0.875rem",fontWeight:400,color:"var(--reactaform-text-color, #111827)",flex:1,textAlign:"left"},children:i?t("Drop files here"):e.multiple?t("Choose Files or Drag & Drop"):t("Choose File or Drag & Drop")}),e.accept&&h.jsx("div",{style:{fontSize:"0.75rem",color:"var(--reactaform-text-muted, #6b7280)",whiteSpace:"nowrap",opacity:i?0:1,transition:"opacity 0.15s ease",pointerEvents:i?"none":"auto"},children:e.accept})]}),R()]})})},rt=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function tt(e){return e.split(",").map(r=>r.trim()).every(r=>rt.test(r))}const nt=e=>!e||e.trim()===""?[]:e.split(",").map(r=>r.trim()).filter(Boolean).map(Number),at=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),[i,c]=s.useState(Array.isArray(r)?r.join(", "):String(r??"")),m=s.useCallback(l=>{if(l.trim()==="")return e.required?t("Value required"):null;if(!tt(l))return t("Each value must be a valid float");const g=nt(l);if(e.minCount!==void 0&&g.length<e.minCount)return t("Minimum number of values: {{1}}",e.minCount);if(e.maxCount!==void 0&&g.length>e.maxCount)return t("Maximum number of values: {{1}}",e.maxCount);for(const p of g){if(e.min!==void 0&&(e.minInclusive?p<e.min:p<=e.min))return t("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?p>e.max:p>=e.max))return t("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return P(o,e,g,t)??null},[o,e,t]),d=l=>{const g=l.target.value,y=m(g);c(g),n?.(g,y)},u=s.useRef(null),f=s.useRef(a);return s.useEffect(()=>{f.current=a},[a]),s.useEffect(()=>{const l=Array.isArray(r)?r.join(", "):String(r??""),g=m(l);g!==u.current&&(u.current=g,f.current?.(g??null))},[r,e.required,m,t]),h.jsx(q,{field:e,error:m(i),children:h.jsx("input",{id:e.name,type:"text",value:i,onChange:d,className:U(A.input,A.textInput),style:{flex:1},"aria-invalid":!!m(i),"aria-describedby":m(i)?`${e.name}-error`:void 0})})},ot=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,st=e=>{const r=Number.parseFloat(e);return Number.isNaN(r)?null:r},it=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useCallback(f=>{if(f.trim()==="")return e.required?t("Value required"):null;if(!ot.test(f))return t("Must be a valid float");const l=st(f);return l===null?t("Must be a valid float"):e.min!==void 0&&(e.minInclusive?l<e.min:l<=e.min)?t("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min):e.max!==void 0&&(e.maxInclusive?l>e.max:l>=e.max)?t("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max):P(o,e,l,t)??null},[e,o,t]),m=s.useRef(null),d=s.useRef(a);s.useEffect(()=>{d.current=a},[a]),s.useEffect(()=>{const f=String(r??""),l=c(f);l!==m.current&&(m.current=l,d.current?.(l??null)),i.current&&document.activeElement!==i.current&&(i.current.value=f)},[r,e,c,t]);const u=f=>{const l=f.target.value,g=c(l);n?.(l,g)};return h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:i,onChange:u,className:U(A.input,A.inputNumber),"aria-invalid":!!c(String(r??"")),"aria-describedby":c(String(r??""))?`${e.name}-error`:void 0})})};function ct(){try{return"/"}catch{}try{if(typeof process<"u"&&process?.env?.PUBLIC_URL)return process.env.PUBLIC_URL}catch{}return"/"}const lt=({field:e,value:r})=>{const{language:n,t:a}=D(),t=e.alignment||"center",o={left:"flex-start",center:"center",right:"flex-end"},i=typeof r=="string"?r:"";let c=i&&i.trim()!==""?i:typeof e.defaultValue=="string"?e.defaultValue:"";c&&!c.startsWith("/")&&(c=`${ct()}${c}`);const m=e.localized?.split(";").map(x=>x.trim()),[d,u]=s.useState(c||""),f=s.useRef(c||null);if(s.useEffect(()=>{if(!c)return;const x=c.split("/"),R=x.pop(),v=R.lastIndexOf(".");if(v===-1)return;const E=R.substring(0,v),k=R.substring(v);let w=null;m?.includes(n)&&(w=`${E}_${n}${k}`);const S=new AbortController;if(w){const N=[...x,w].join("/");fetch(N,{method:"HEAD",signal:S.signal}).then(I=>{const j=I.ok?N:c;j!==f.current&&(f.current=j,u(j))}).catch(()=>{c!==f.current&&(f.current=c,u(c))})}else{const N=c;N!==f.current&&(f.current=N,requestAnimationFrame(()=>u(N)))}return()=>{S.abort()}},[c,n,m]),!d)return null;const{width:l,height:g}=e,y={},p={borderRadius:"8px",objectFit:"contain",boxShadow:"0 2px 6px rgba(0,0,0,0.1)",margin:"0 0 8px 0"};return l&&g?(y.width=l,y.height=g,p.width=`${l}px`,p.height=`${g}px`):l&&!g?(y.width=l,p.width=`${l}px`,p.height="auto"):!l&&g&&(y.height=g,p.width="auto",p.height=`${g}px`),h.jsx(q,{field:e,children:h.jsx("div",{"data-testid":"image-wrapper",style:{display:"flex",justifyContent:o[t]||"center",margin:"0 0"},children:h.jsx("img",{src:d,alt:a?.(e.displayName||"Image")||e.displayName||"Image",...y,style:p})})})};function ut(e){const r=/^-?\d+$/;return e.split(",").map(n=>n.trim()).every(n=>r.test(n))}const ft=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=",",[c,m]=s.useState(Array.isArray(r)?r.join(i+" "):String(r??"")),d=p=>!p||p.trim()===""?[]:p.split(i).map(x=>x.trim()).filter(Boolean).map(x=>Number(x)),u=s.useCallback(p=>{if(p.trim()==="")return e.required?t("Value required"):null;if(!ut(p))return t("Each value must be a valid integer");const x=d(p);if(e.minCount!==void 0&&x.length<e.minCount)return t("Minimum number of values: {{1}}",`${e.minCount}`);if(e.maxCount!==void 0&&x.length>e.maxCount)return t("Maximum number of values: {{1}}",`${e.maxCount}`);for(const v of x){if(e.min!==void 0&&(e.minInclusive?v<e.min:v<=e.min))return t("Each value must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?v>e.max:v>=e.max))return t("Each value must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max)}return P(o,e,x,t)??null},[o,e,t]),f=p=>{const x=p.target.value,R=u(x);m(x),n?.(x,R)},l=s.useRef(null),g=s.useRef(a);s.useEffect(()=>{g.current=a},[a]),s.useEffect(()=>{const p=Array.isArray(r)?r.join(i+" "):String(r??""),x=u(p);x!==l.current&&(l.current=x,g.current?.(x??null))},[r,e.required,u,t]);const y=u(c);return h.jsx(q,{field:e,error:y,children:h.jsx("input",{id:e.name,type:"text",value:c,onChange:f,className:U(A.input,A.textInput),style:{flex:1},"aria-invalid":!!y,"aria-describedby":y?`${e.name}-error`:void 0})})};function mt(e){return/^[-+]?\d*$/.test(e)}const dt=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useCallback(g=>{const y=parseInt(g,10);return Number.isNaN(y)?null:y},[]),m=s.useCallback(g=>{if(g.trim()==="")return e.required?t("Value required"):null;if(!mt(g))return t("Must be a valid integer");const y=c(g);if(y===null)return t("Must be a valid integer");if(e.min!==void 0&&(e.minInclusive?y<e.min:y<=e.min))return t("Must be {{1}} {{2}}",e.minInclusive?"≥":">",e.min);if(e.max!==void 0&&(e.maxInclusive?y>e.max:y>=e.max))return t("Must be {{1}} {{2}}",e.maxInclusive?"≤":"<",e.max);if(e.step!==void 0){const x=Number(e.step);if(!Number.isInteger(x))return t("Invalid step value");if(y%x!==0)return t("Must be a multiple of {{1}}",x)}return P(o,e,y,t)??null},[e,o,t,c]),d=s.useRef(null),u=s.useRef(a);s.useEffect(()=>{u.current=a},[a]),s.useEffect(()=>{const g=String(r??""),y=m(g);y!==d.current&&(d.current=y,u.current?.(y??null)),i.current&&document.activeElement!==i.current&&(i.current.value=g)},[r,e,m,t]);const f=g=>{const y=g.target.value,p=m(y);n?.(y,p)},l=m(String(r??""));return h.jsx(q,{field:e,error:l,children:h.jsx("input",{id:e.name,type:"text",defaultValue:String(r??""),ref:i,onChange:f,className:U(A.input,A.inputNumber),"aria-invalid":!!l,"aria-describedby":l?`${e.name}-error`:void 0})})},pt=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=e.minHeight??"80px",c=s.useRef(null),m=s.useRef(null),d=s.useRef(a);s.useEffect(()=>{d.current=a},[a]);const u=s.useCallback(y=>y.trim()===""?e.required?t("Value required"):null:e.minLength!==void 0&&y.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&y.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):P(o,e,y,t),[e,o,t]),f=y=>{const p=y.target.value,x=u(p);n?.(p,x)};s.useEffect(()=>{const y=u(r);y!==m.current&&(m.current=y,d.current?.(y??null)),c.current&&c.current.value!==String(r??"")&&(c.current.value=String(r??""))},[r,u]);const l={id:e.name,defaultValue:String(r??""),ref:c,onChange:f,style:{resize:"vertical",minHeight:i,width:"100%",boxSizing:"border-box"},className:U(A.input,A.textInput)},g=u(r);return h.jsx(q,{field:e,error:g,children:h.jsx("textarea",{...l,"aria-invalid":!!g,"aria-describedby":g?`${e.name}-error`:void 0})})},gt=({field:e,value:r,onChange:n,onError:a})=>{const t=s.useRef(a);s.useEffect(()=>{t.current=a},[a]);const{t:o,darkMode:i,formStyle:c,fieldStyle:m,definitionName:d}=D(),u=(j,F,M)=>{if(!F)return{};const B=j?.[F];return(M&&B?B[M]:void 0)??{}},f=s.useRef(null),[l,g]=s.useState(!1),[y,p]=s.useState(null),x=s.useMemo(()=>e.options.map(j=>({value:j.value,label:o(j.label)})),[e.options,o]),R=s.useMemo(()=>{const j=Array.isArray(r)?r:[],F=new Set(x.map(M=>M.value));return j.filter(M=>F.has(M))},[r,x]),v=j=>{const F=Array.isArray(j)?j:[];return e.required&&F.length===0?o("Value required"):P(d,e,F,o)??null},E=()=>{if(!f.current)return;const j=f.current.getBoundingClientRect();p({x:j.left,y:j.bottom}),g(F=>!F)},k=j=>{const F=R.includes(j)?R.filter(z=>z!==j):[...R,j],M=v(F);t.current?.(M??null),n?.(F,M)},w=s.useMemo(()=>({height:"var(--reactaform-input-height, 2.5rem)",padding:"var(--reactaform-input-padding, 8px)",display:"flex",alignItems:"center",boxSizing:"border-box",cursor:"pointer",position:"relative",borderRadius:"var(--reactaform-border-radius, 4px)",border:"1px solid var(--reactaform-border-color, #ccc)",background:"var(--reactaform-secondary-bg, #fff)",color:"var(--reactaform-text-color, #000)",...u(c,"multiSelect","control"),...u(m,void 0,"control")}),[c,m]),S=s.useMemo(()=>({position:"absolute",right:"1.5em",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",padding:0,...u(c,"multiSelect","clearButton"),...u(m,void 0,"clearButton")}),[c,m]),N=s.useMemo(()=>({position:"absolute",right:"0.7em",top:"50%",transform:"translateY(-50%)",pointerEvents:"none",fontSize:"0.8em",color:"var(--reactaform-text-muted, #999)",...u(c,"multiSelect","arrow"),...u(m,void 0,"arrow")}),[c,m]),I=v(Array.isArray(r)?r:[]);return h.jsxs("div",{children:[h.jsx(q,{field:e,error:null,children:h.jsx("div",{style:{width:"100%"},children:h.jsxs("div",{ref:f,className:"reactaform-multiselection-control",style:w,onClick:E,tabIndex:0,role:"button","aria-haspopup":"listbox","aria-expanded":l,"aria-invalid":!!I,"aria-describedby":I?`${e.name}-error`:void 0,onKeyDown:j=>{(j.key==="Enter"||j.key===" ")&&(j.preventDefault(),E())},children:[h.jsxs("span",{style:{flex:1,color:"var(--reactaform-text-muted, #888)"},children:[R.length," / ",x.length," selected"]}),R.length>0&&h.jsx("button",{type:"button","aria-label":"Clear selections",onClick:j=>{j.stopPropagation(),n?.([],null)},style:S,children:h.jsx("span",{style:S,"aria-hidden":!0,children:"✖"})}),h.jsx("span",{style:N,"aria-hidden":!0,children:"▼"})]})})}),l&&y&&h.jsx(ht,{position:y,options:x,selectedValues:R,onToggleOption:k,onClose:()=>g(!1),controlRef:f,darkMode:i})]})},ht=({position:e,options:r,selectedValues:n,onToggleOption:a,onClose:t,controlRef:o,darkMode:i})=>{const c=s.useRef(null),[m,d]=s.useState(-1),{formStyle:u,fieldStyle:f}=D(),l=(S,N,I)=>{if(!N)return{};const F=S?.[N];return(I&&F?F[I]:void 0)??{}},g=s.useMemo(()=>({maxHeight:200,overflowY:"auto",background:"var(--reactaform-secondary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:4,zIndex:2e3,boxShadow:"var(--reactaform-shadow, 0 2px 8px rgba(0,0,0,0.15))",pointerEvents:"auto",color:"var(--reactaform-text-color, #000)",fontSize:"var(--reactaform-popup-font-size, 0.875rem)",...l(u,"multiSelect","popup"),...l(f,void 0,"popup")}),[u,f]),y=s.useMemo(()=>({padding:"6px 8px",cursor:"pointer",display:"flex",alignItems:"center",background:"transparent",color:"var(--reactaform-text-color, #000)",...l(u,"multiSelect","option"),...l(f,void 0,"option")}),[u,f]);s.useEffect(()=>{const S=N=>{const I=N.target;!c.current?.contains(I)&&!o.current?.contains(I)&&t()};return document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[t,o]),s.useEffect(()=>{c.current&&r.length>0&&requestAnimationFrame(()=>d(S=>S===-1?0:S))},[r.length]),s.useEffect(()=>{if(!c.current||m<0)return;const S=c.current.querySelector(`#multi-opt-${m}`);S&&requestAnimationFrame(()=>S.focus())},[m]);const p=250,x=200,[R,v]=s.useState(null),[E,k]=s.useState(null);if(s.useEffect(()=>{if(typeof window>"u")return;const S=()=>{let j=e.x,F=e.y,M=p;const z=o?.current;if(z){const B=z.getBoundingClientRect();j=B.left,F=B.bottom,M=Math.max(80,Math.round(B.width))}j=Math.min(j,window.innerWidth-M),F=Math.min(F,window.innerHeight-x),v({left:j,top:F}),k(M)};S(),window.addEventListener("scroll",S,!0),window.addEventListener("resize",S);let N=null;const I=o?.current;return typeof ResizeObserver<"u"&&I&&(N=new ResizeObserver(()=>S()),N.observe(I)),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",S),N&&I&&N.unobserve(I)}},[o,e.x,e.y]),typeof window>"u")return null;let w=document.getElementById("popup-root");return w||(w=document.createElement("div"),w.id="popup-root",document.body.appendChild(w)),je.createPortal(h.jsx("div",{ref:c,role:"listbox","aria-activedescendant":m>=0?`multi-opt-${m}`:void 0,style:{position:"absolute",top:R?R.top:e.y,left:R?R.left:e.x,width:E??p,...g},"data-reactaform-theme":i?"dark":"light",children:r.map((S,N)=>{const I=n.includes(S.value),j=i?"var(--reactaform-hover-bg, rgba(255,255,255,0.01))":"var(--reactaform-hover-bg, #eee)",F={...y,background:N===m?j:y.background};return h.jsxs("div",{id:`multi-opt-${N}`,onMouseDown:M=>{M.stopPropagation(),a(S.value)},onKeyDown:M=>{const z=r.length;switch(M.key){case"ArrowDown":M.preventDefault(),d(B=>(B+1)%z);break;case"ArrowUp":M.preventDefault(),d(B=>(B-1+z)%z);break;case"Home":M.preventDefault(),d(0);break;case"End":M.preventDefault(),d(z-1);break;case"Enter":case" ":M.preventDefault(),M.stopPropagation(),a(S.value);break;case"Escape":M.preventDefault(),t(),o?.current?.focus();break}},tabIndex:N===m?0:-1,role:"option","aria-selected":I,style:F,onMouseEnter:M=>{M.currentTarget.style.background=j,d(N)},onMouseLeave:M=>{M.currentTarget.style.background="transparent",d(z=>z===N?-1:z)},children:[h.jsx("input",{type:"checkbox",checked:I,readOnly:!0,style:{marginRight:8,width:"1.125em",height:"1.125em",verticalAlign:"middle",accentColor:i?"#10b981":"#22c55e",cursor:"pointer"}}),S.label]},S.value)})}),w)},bt=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=e.min??void 0,m=e.max??void 0,d=Math.max(1,Math.round(e.step??1)),u=s.useCallback(x=>isNaN(x)?t("Must be a valid integer"):Number.isInteger(x)?c!==void 0&&x<c?t("Must be �?{{1}}",c):m!==void 0&&x>m?t("Must be �?{{1}}",m):P(o,e,x,t)??null:t("Must be an integer"),[o,e,t,c,m]),f=s.useRef(null),l=s.useRef(a);s.useEffect(()=>{l.current=a},[a]),s.useEffect(()=>{if(document.activeElement===i.current)return;const R=String(r),v=u(r);i.current&&(i.current.value=R),v!==f.current&&(f.current=v,l.current?.(v??null))},[r,u]);const g=x=>{if(x.trim()==="")return e.required?t("Value required"):null;const v=Number(x);return u(v)},y=x=>{const R=x.target.value,v=x.target.valueAsNumber,E=g(R);n?.(v,E)},p=g(String(r??""));return h.jsx(q,{field:e,error:p,children:h.jsx("input",{ref:i,id:e.name,type:"number",defaultValue:String(r??""),min:c,max:m,step:d,onChange:y,style:{width:"100%",height:"100%"},className:A.input,"aria-invalid":!!p,"aria-describedby":p?`${e.name}-error`:void 0})})},yt=({field:e,value:r,onChange:n,onError:a})=>{const{t}=D(),o=s.useRef(null),{definitionName:i}=D(),c=s.useCallback(f=>{const l=String(f??"").trim();if(l==="")return e.required?t("Value required"):null;if(e.pattern)try{if(!new RegExp(e.pattern).test(l))return e.patternErrorMessage?t(e.patternErrorMessage):t("Phone number does not match pattern: {{1}}",`${e.pattern}`)}catch{}return P(i,e,l,t)},[i,e,t]),m=s.useRef(null),d=s.useRef(a);s.useEffect(()=>{d.current=a},[a]),s.useEffect(()=>{const f=String(r??""),l=c(f);o.current&&o.current.value!==String(f)&&(o.current.value=String(f)),l!==m.current&&(m.current=l,d.current?.(l??null))},[r,c]);const u=f=>{const l=f.target.value,g=l.trim();let y=null;if(g===""){y=e.required?t("Value required"):null,n?.(l,y);return}y||(y=c(l)),n?.(l,y)};return h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"tel",defaultValue:String(r??""),ref:o,onChange:u,className:U(A.input,A.textInput),"aria-invalid":!!c(String(r??"")),"aria-describedby":c(String(r??""))?`${e.name}-error`:void 0})})},xt=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=e.layout?.toLowerCase()==="horizontal"?"row":"column",c=s.useRef(null),m=s.useRef(a);s.useEffect(()=>{m.current=a},[a]);const d=s.useCallback(f=>f===""||f===null||f===void 0?t("Value required"):!e.options||e.options.length===0?null:e.options.some(g=>g.value===f)?P(o,e,f,t)??null:t("Invalid option selected"),[e,t,o]);s.useEffect(()=>{const f=r!=null?String(r):"",l=d(f);if(m.current?.(l??null),c.current){const g=Array.from(c.current.querySelectorAll("input[type=radio]"));if(l&&e.options&&e.options.length>0){const y=String(e.options[0].value);g.forEach(p=>p.checked=p.value===y),n?.(y,null)}else g.forEach(y=>y.checked=y.value===f)}},[r,d,n,e.options]);const u=f=>{const l=f.target.value,g=d(l);m.current?.(g??null),n?.(l,g)};return h.jsx(q,{field:e,error:d(String(r??"")),children:h.jsx("div",{className:A.input,role:"radiogroup","aria-labelledby":`${e.name}-label`,"aria-invalid":!!d(String(r??"")),style:{display:"flex",flexDirection:i,flexWrap:i==="row"?"wrap":"nowrap",gap:i==="row"?"12px":"4px",alignItems:i==="row"?"center":"stretch",width:"100%",padding:i==="row"?"8px":void 0,boxSizing:"border-box"},ref:c,children:(e.options??[]).map(f=>h.jsxs("label",{className:U(A.label),style:{display:i==="column"?"flex":"inline-flex",gap:"8px",alignItems:"center",whiteSpace:"nowrap",marginBottom:i==="column"?6:0,cursor:"pointer",width:i==="column"?"100%":void 0,justifyContent:"flex-start"},children:[h.jsx("input",{type:"radio",name:e.name,value:String(f.value),defaultChecked:String(r??"")===String(f.value),onChange:u,style:{width:"1.1em",height:"1.1em"}}),h.jsx("span",{style:{userSelect:"none",textAlign:i==="column"?"left":void 0,flex:i==="column"?1:void 0,fontWeight:400},children:t(f.label)})]},String(f.value)))})})},vt={display:"flex",gap:4},wt={cursor:"pointer",fontSize:"1.5rem",lineHeight:1,display:"inline-block",marginRight:"0.25rem",userSelect:"none",transition:"color 0.12s ease"},St=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),[i,c]=s.useState(null),m=s.useRef([]),d=e.max||5,u=s.useCallback(p=>e.required&&p===0?t("Value required"):P(o,e,p,t)??null,[e,t,o]),f=s.useRef(null),l=s.useRef(a);s.useEffect(()=>{l.current=a},[a]),s.useEffect(()=>{let p=r||0;r<0&&(p=0),r>d&&(p=d);const x=u(p);x!==f.current&&(f.current=x,l.current?.(x??null))},[r,u,d]);const g=p=>{const x=u(p);n?.(p,x)},y=(()=>{let p=r||0;return p<0&&(p=0),p>d&&(p=d),p})();return h.jsx(q,{field:e,error:u(y),children:h.jsx("div",{role:"radiogroup","aria-labelledby":`${e.name}-label`,style:vt,"aria-invalid":!!u(y),"aria-describedby":u(y)?`${e.name}-error`:void 0,children:(()=>{const p=e.icon,x=p&&String(p).trim()?String(p):"★";return[...Array(d)].map((R,v)=>{const E=v<y,w=i!==null&&v<=i||E?"gold":"lightgray";return h.jsx("span",{ref:S=>m.current[v]=S,role:"radio",tabIndex:y>0?v===y-1?0:-1:v===0?0:-1,"aria-checked":E,onClick:()=>g(v+1),onKeyDown:S=>{if(S.key==="Enter"||S.key===" ")S.preventDefault(),g(v+1);else if(S.key==="ArrowRight"||S.key==="ArrowUp"){S.preventDefault();const N=Math.min(d-1,v+1);m.current[N]?.focus()}else if(S.key==="ArrowLeft"||S.key==="ArrowDown"){S.preventDefault();const N=Math.max(0,v-1);m.current[N]?.focus()}},onMouseEnter:()=>c(v),onMouseLeave:()=>c(null),style:{...wt,color:w},"aria-label":`Rating ${v+1}`,title:t(`${e.displayName} ${v+1}`),children:x},v)})})()})})},Ct=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useRef(null),m=s.useRef(a);s.useEffect(()=>{m.current=a},[a]);const d=s.useMemo(()=>e.pattern?new RegExp(e.pattern):null,[e.pattern]),u=s.useCallback(p=>p===""?e.required?t("Value required"):null:e.minLength!==void 0&&p.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&p.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):d&&!d.test(p)?e.patternErrorMessage?t(e.patternErrorMessage):t("Input does not match pattern: {{1}}",e.pattern):P(o,e,p,t),[e,o,t,d]),f=p=>{const x=p.target.value,R=u(x);n?.(x,R)};s.useEffect(()=>{const p=u(r??"");i.current&&i.current.value!==String(r??"")&&(i.current.value=String(r??"")),p!==c.current&&(c.current=p,m.current?.(p??null))},[r,u]);const[l,g]=s.useState(!1),y=()=>g(p=>!p);return h.jsx(q,{field:e,error:u(String(r??"")),children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,width:"100%"},children:[h.jsx("input",{id:e.name,type:l?"text":"password",defaultValue:String(r??""),ref:i,onChange:f,className:U(A.input,A.textInput),style:{flex:1,minWidth:0},"aria-invalid":!!u(String(r??"")),"aria-describedby":u(String(r??""))?`${e.name}-error`:void 0}),h.jsx("button",{type:"button",onClick:y,"aria-label":t(l?"Hide password":"Show password"),style:{background:"transparent",border:"none",cursor:"pointer",fontSize:16,lineHeight:1,padding:"4px 6px",flexShrink:0},children:l?"🙈":"👁️"})]})})},Rt=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/;function Et(e){return Rt.test(e)}const jt=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useRef(null),m=s.useCallback(y=>{let p=null;if(y.trim()==="")return t("Value required");if(!Et(y))return t("Invalid number");const x=Number(y);return typeof e.min=="number"&&x<e.min?t("Value should be at least {{1}}",e.min):typeof e.max=="number"&&x>e.max?t("Value should be at most {{1}}",e.max):(p||(p=P(o,e,x,t)),p)},[o,e,t]),d=s.useRef(null),u=s.useRef(a);s.useEffect(()=>{u.current=a},[a]),s.useEffect(()=>{const y=String(r),p=m(y);c.current&&document.activeElement!==c.current&&(c.current.value=isNaN(Number(y))?String(e.min??0):String(Number(y))),i.current&&document.activeElement!==i.current&&(i.current.value=y),p!==d.current&&(d.current=p,u.current?.(p??null))},[r,m,e.min]);const f=e.min??0,l=e.max??100,g=y=>{const p=y.target.value,x=m(p);n?.(p,x)};return h.jsx(q,{field:e,error:m(String(r??"")),children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",width:"100%"},children:[h.jsx("input",{ref:c,id:`${e.name}-range`,type:"range",defaultValue:isNaN(Number(r))?String(f):String(Number(r)),onChange:g,min:f,max:l,style:{padding:"0px, 0px",flex:1},className:A.rangeInput,"aria-invalid":!!m(String(r??"")),"aria-describedby":m(String(r??""))?`${e.name}-error`:void 0}),h.jsx("input",{id:e.name,ref:i,type:"text",defaultValue:String(r??""),onChange:g,required:!0,style:{width:"40px",minWidth:"40px",height:"2.3em",textAlign:"center",flexShrink:0},className:U(A.input,A.textInput),"aria-invalid":!!m(String(r??"")),"aria-describedby":m(String(r??""))?`${e.name}-error`:void 0})]})})},kt=({field:e,value:r,onChange:n,onError:a})=>{const{t,formStyle:o,fieldStyle:i,definitionName:c}=D(),m=o,d=i,u=(w,S,N)=>{if(!S)return{};const I=w?.[S];return(N&&I?I[N]:void 0)??{}},f=s.useMemo(()=>({display:"inline-block",position:"relative",width:44,height:24,...u(m,"switch","label"),...u(d,void 0,"label")}),[m,d]),l=s.useMemo(()=>({position:"absolute",opacity:0,top:0,left:0,width:"100%",height:"100%",margin:0,cursor:"pointer",pointerEvents:"none",...u(m,"switch","hiddenInput"),...u(d,void 0,"hiddenInput")}),[m,d]),g=s.useMemo(()=>({position:"absolute",cursor:"pointer",top:0,left:0,right:0,bottom:0,backgroundColor:"var(--reactaform-switch-off-bg, #ccc)",transition:"0.3s",borderRadius:24,borderWidth:2,borderStyle:"solid",borderColor:"transparent",...u(m,"switch","slider"),...u(d,void 0,"slider")}),[m,d]),y=s.useMemo(()=>({position:"absolute",height:16,width:16,left:2,bottom:2,backgroundColor:"white",transition:"0.3s",borderRadius:"50%",boxShadow:"0 1px 3px rgba(0, 0, 0, 0.3)",...u(m,"switch","knob"),...u(d,void 0,"knob")}),[m,d]),p=!!r,x=s.useRef(null),R=s.useRef(a),v=s.useCallback(w=>w?P(c,e,w,t)??null:e.required?t("Value required"):null,[e,t,c]),E=()=>{const w=!p,S=v(w);n?.(w,S)};s.useEffect(()=>{R.current=a},[a]),s.useEffect(()=>{const w=v(p);w!==x.current&&(x.current=w,R.current?.(w??null))},[p,e,v]);const k=e.name;return h.jsx(q,{field:e,error:v(p),rightAlign:!1,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[h.jsx("label",{className:A.label,htmlFor:k,style:{textAlign:"left",justifyContent:"flex-start"},children:t(e.displayName)}),h.jsxs("label",{style:f,children:[h.jsx("input",{id:e.name,type:"checkbox",checked:p,readOnly:!0,"aria-label":t(e.displayName),"aria-invalid":!!v(p),"aria-describedby":v(p)?`${e.name}-error`:void 0,style:l,tabIndex:-1}),h.jsx("span",{role:"switch","data-testid":"switch",tabIndex:0,"aria-checked":p,"aria-invalid":!!v(p),"aria-describedby":v(p)?`${e.name}-error`:void 0,onClick:E,onKeyDown:w=>{(w.key===" "||w.key==="Spacebar"||w.key==="Space"||w.key==="Enter")&&(w.preventDefault(),E())},className:`reactaform-switch ${p?"active checked on":""} `,style:p?{...g,backgroundColor:"var(--reactaform-switch-on-bg, #22c55e)",borderColor:"var(--reactaform-switch-on-border, #16a34a)"}:g,children:h.jsx("span",{style:{...y,transform:p?"translateX(20px)":void 0}})})]})]})})},He=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useRef(null),m=s.useRef(a);s.useEffect(()=>{m.current=a},[a]);const d=s.useMemo(()=>e.pattern?new RegExp(e.pattern):null,[e.pattern]),u=s.useCallback(l=>l.trim()===""?e.required?t("Value required"):null:e.minLength!==void 0&&l.length<e.minLength?t("Must be at least {{1}} characters",e.minLength):e.maxLength!==void 0&&l.length>e.maxLength?t("Must be at most {{1}} characters",e.maxLength):d&&!d.test(l)?e.patternErrorMessage?t(e.patternErrorMessage):t("Input does not match pattern: {{1}}",e.pattern):P(o,e,l,t),[e,o,t,d]),f=l=>{const g=l.target.value,y=u(g);n?.(g,y)};return s.useEffect(()=>{const l=u(r);i.current&&i.current.value!==String(r??"")&&(i.current.value=String(r??"")),l!==c.current&&(c.current=l,m.current?.(l??null))},[r,u]),h.jsx(q,{field:e,error:u(String(r??"")),children:h.jsx("input",{id:e.name,"aria-invalid":!!u(String(r??"")),"aria-describedby":u(String(r??""))?`${e.name}-error`:void 0,type:"text",defaultValue:String(r??""),ref:i,onChange:f,className:U(A.input,A.textInput)})})},Nt=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useRef(a),m=e.includeSeconds??!0;s.useEffect(()=>{c.current=a},[a]);const d=s.useCallback(f=>{if(!f||f.trim()==="")return e.required||e.min||e.max?t("Value required"):null;const l=p=>{const x=p.split(":").map(v=>parseInt(v,10));if(x.some(v=>Number.isNaN(v)))return NaN;let R=0;if(x.length===3)R=x[0]*3600+x[1]*60+x[2];else if(x.length===2)R=x[0]*3600+x[1]*60;else if(x.length===1)R=x[0]*3600;else return NaN;return R},g=l(f);if(Number.isNaN(g))return t("Invalid time format");if(e.min&&typeof e.min=="string"){const p=l(e.min);if(!Number.isNaN(p)&&g<p)return t("Time must be on or after {{1}}",e.min)}if(e.max&&typeof e.max=="string"){const p=l(e.max);if(!Number.isNaN(p)&&g>p)return t("Time must be on or before {{1}}",e.max)}return P(o,e,f,t)??null},[e,o,t]),u=f=>{const l=f.target.value,g=d(l);n?.(l,g)};return s.useEffect(()=>{const f=d(r);f!==i.current&&(i.current=f,c.current?.(f??null))},[r,d]),h.jsx(q,{field:e,error:d(r),children:h.jsx("input",{id:e.name,type:"time",value:r,step:m?1:60,onChange:u,min:typeof e.min=="string"?e.min:void 0,max:typeof e.max=="string"?e.max:void 0,className:U(A.input,A.textInput),"aria-invalid":!!d(r),"aria-describedby":d(r)?`${e.name}-error`:void 0})})};function It({pos:e,options:r,onClose:n,onClickOption:a}){const t=s.useRef(null),o=s.useRef(!1),i=typeof window<"u"?document.getElementById("popup-root")||document.body:null;if(s.useEffect(()=>{function g(y){o.current||y.target.dataset?.popupMenu==="item"||t.current&&y.target instanceof Node&&!t.current.contains(y.target)&&n()}return document.addEventListener("mousedown",g),()=>document.removeEventListener("mousedown",g)},[n]),!i||r===void 0||r.length===0||!e||e.x==null||e.y==null)return null;const c=e.x,m=e.y,d=typeof window<"u"?window.innerWidth:1024,u=Math.max(0,d-160),f=Math.max(0,Math.min(c,u)),l=Math.max(0,m);return je.createPortal(h.jsx("div",{ref:t,onMouseDown:g=>{g.stopPropagation()},style:{position:"fixed",top:l,left:f,backgroundColor:"var(--reactaform-primary-bg, #fff)",border:"1px solid var(--reactaform-border-color, #ccc)",borderRadius:"var(--reactaform-border-radius, 4px)",boxShadow:"var(--reactaform-shadow, 0 2px 10px rgba(0,0,0,0.2))",zIndex:9999,minWidth:"var(--reactaform-menu-min-width, 150px)",pointerEvents:"auto"},children:r.map((g,y)=>h.jsx("div",{"data-popup-menu":"item",onMouseDown:p=>{p.stopPropagation(),o.current=!0},onClick:p=>{p.stopPropagation(),p.preventDefault(),a(g),n(),setTimeout(()=>{o.current=!1},100)},style:{padding:"var(--reactaform-menu-item-padding, 8px 12px)",cursor:"pointer",fontSize:"var(--reactaform-menu-item-font-size, 0.8em)",borderBottom:y<r.length-1?"1px solid var(--reactaform-border-light, #eee)":void 0,transition:"background-color 0.15s ease"},onMouseEnter:p=>{p.currentTarget.style.backgroundColor="var(--reactaform-hover-bg, #e0e0e0)"},onMouseLeave:p=>{p.currentTarget.style.backgroundColor="transparent"},children:g.label},g.label??y))}),i)}const fe={};function At(e,r){if(e in fe)return;const n=$e[e]??{},a={},t={},o={};for(const[c,m]of Object.entries(n))typeof m.factor=="number"&&(a[c]=m.factor),t[c]=r(c),o[r(c)]=c;const i=Object.keys(n)[0]??"";fe[e]={default:i,factors:a,labels:t,reverseLabels:o}}function Ft(e,r,n){if(e==="C"){if(r==="F")return n*(9/5)+32;if(r==="K")return n+273.15}else if(e==="F"){if(r==="C")return(n-32)*5/9;if(r==="K")return(n-32)*5/9+273.15}else if(e==="K"){if(r==="C")return n-273.15;if(r==="F")return(n-273.15)*9/5+32}return n}function Mt(e,r,n){if(!Number.isFinite(e))return[];if(n===fe.temperature)return Object.keys(n.labels).map(o=>{const i=Ft(r,o,e);return Number.isFinite(i)?{label:`${i.toFixed(6)} ${o}`,value:i.toString(),unit:o}:{label:`${String(i)} ${o}`,value:String(i),unit:o}});const t=n.factors[r];return t===void 0?[]:Object.entries(n.factors).map(([o,i])=>{const c=e/t*i;return Number.isFinite(c)?{label:`${c.toFixed(6)} ${o}`,value:c.toString(),unit:o}:{label:`${String(c)} ${o}`,value:String(c),unit:o}})}function pe(e,r){return e in r.labels?e:r.reverseLabels&&r.reverseLabels[e]?r.reverseLabels[e]:null}const $t=/^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][-+]?\d+)?$/,Ot=({unitFactors:e,field:r,value:n,onChange:a,onError:t})=>{const{t:o,definitionName:i}=D(),c=s.useRef(null),m=s.useRef(null),d=s.useRef(null),[u,f]=s.useState(null),[l,g]=s.useState(null),[y,p]=s.useState(!1),[x,R]=s.useState(null),[v,E]=s.useState([]),k=s.useCallback((V,b)=>{if(!V||V.trim()==="")return r.required?o("Value required"):null;if(!$t.test(V))return o("Must be a valid number");const C=P(i,r,[V,b],o);return C||null},[i,r,o]),w=e.reverseLabels!==void 0?e.reverseLabels:Object.fromEntries(Object.entries(e.labels).map(([V,b])=>[b,V]));s.useEffect(()=>{const V=String(n[0]);let b=n[1]??e.default;b=pe(b,e)||b;const C=document.activeElement;C===c.current||C===m.current||(c.current&&(c.current.value=V),m.current&&(m.current.value=b),d.current!==null&&(cancelAnimationFrame(d.current),d.current=null),d.current=requestAnimationFrame(()=>{d.current=null,f(null),g(null)}))},[n,e]),s.useEffect(()=>()=>{d.current!==null&&(cancelAnimationFrame(d.current),d.current=null)},[]);const S=s.useRef(null),N=s.useRef(t);s.useEffect(()=>{N.current=t},[t]),s.useEffect(()=>{const V=String(n[0]);let b=n[1]??e.default;b=pe(b,e)||b;const C=k(V,b);C!==S.current&&(S.current=C,N.current?.(C??null))},[n,e,k]);const I=(V,b,C)=>{const O=w[b]||b;a?.([V,O],C)},j=V=>{const b=V.target.value,C=m.current?m.current.value:e.default,O=k(b,C);f(b),I(b,C,O)},F=V=>{const b=V.target.value,C=c.current?c.current.value:String(n[0]??""),O=k(C,b);g(b),m.current&&(m.current.value=b),I(C,b,O)},M=V=>{const b=c.current?c.current.value:String(n[0]??""),C=parseFloat(b),O=m.current?m.current.value:e.default;if(k(b,O)||!b.trim()||!Number.isFinite(C))return;const X=V.currentTarget.getBoundingClientRect(),re=X.left,L=X.bottom;R({x:re,y:L});const $=Mt(C,O,e);if($.length===0){E([]),p(!1);return}E($),p(T=>!T)},z=V=>{const{value:b,unit:C}=V;p(!1),R(null),c.current&&(c.current.value=b),m.current&&(m.current.value=C),f(b),g(C);const O=k(b,C);I(b,C,O)},B=String(n[0]??""),Q=pe(n[1]??e.default,e)||(n[1]??e.default),K=u??B,J=!!k(K,l??Q)||!K.trim(),ee={width:"var(--reactaform-unit-btn-width, 2.5em)",height:"var(--reactaform-unit-btn-height, 2.5em)",padding:"var(--reactaform-unit-btn-padding, 0)",border:"none",borderRadius:"var(--reactaform-button-border-radius, var(--reactaform-border-radius, 0.25em))",backgroundColor:J?"var(--reactaform-button-disabled-bg, #cccccc)":"var(--reactaform-button-bg, var(--reactaform-success-color))",color:"var(--reactaform-button-text, #ffffff)",cursor:J?"var(--reactaform-button-disabled-cursor, not-allowed)":"pointer",opacity:J?+"var(--reactaform-button-disabled-opacity, 0.6)":1,display:"flex",alignItems:"center",justifyContent:"center"},Y=k(B,Q);return h.jsx(q,{field:r,error:Y,children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"var(--reactaform-unit-gap, 8px)",width:"100%"},children:[h.jsx("input",{id:r.name,type:"text",ref:c,defaultValue:String(n[0]??""),onChange:j,style:{width:"var(--reactaform-unit-input-width, 100px)"},className:U(A.input,A.textInput),"aria-invalid":!!Y,"aria-describedby":Y?`${r.name}-error`:void 0}),h.jsx("select",{id:`${r.name}-unit`,ref:m,defaultValue:pe(n[1]??e.default,e)||(n[1]??e.default),onChange:F,className:U(A.input,A.inputSelect),"aria-invalid":!!Y,"aria-describedby":Y?`${r.name}-error`:void 0,children:Object.keys(e.labels).map(V=>h.jsx("option",{value:V,children:e.labels[V]??V},V))}),h.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[h.jsx("button",{onClick:M,"aria-disabled":J,disabled:J,style:ee,className:A.button,children:h.jsx("span",{style:{fontSize:"var(--reactaform-unit-btn-icon-size, 1em)",lineHeight:"1",transform:"translateY(-1px)",pointerEvents:"none"},children:"⟷"})}),y&&v&&h.jsx(It,{pos:x,options:v,onClose:()=>{R(null),p(!1)},onClickOption:z})]})]})})};function Dt({field:e,value:r,onChange:n}){const{t:a}=D(),t=e.dimension;if(!t)return null;fe[t]||At(t,a);const o=fe[t];return o?h.jsx(Ot,{unitFactors:o,field:e,value:r,onChange:n}):null}const Ue=/^(https?|ftp|file):\/\/[-A-Z0-9+&@#/%?=~_|!:,.;]*[-A-Z0-9+&@#/%=~_|]$/i,We=e=>{try{return new URL(e),!0}catch{return!1}},Vt=({field:e,value:r,onChange:n,onError:a})=>{const{t,definitionName:o}=D(),i=s.useRef(null),c=s.useCallback(f=>{const l=f.trim();if(l==="")return e.required?t("Value required"):null;if(!Ue.test(l)&&!We(l)){const y=e.allowRelative===!0;let p=!1;if(Ue.test(l)||We(l))p=!0;else if(y)try{new URL(l,"http://example.com"),p=!0}catch{p=!1}if(!p)return t("Must be a valid URL")}return P(o,e,l,t)??null},[o,e,t]),m=f=>{const l=f.target.value,g=c(l);n?.(l.trim(),g)},d=s.useRef(null),u=s.useRef(a);return s.useEffect(()=>{u.current=a},[a]),s.useEffect(()=>{const f=r??"",l=c(f);i.current&&i.current.value!==String(f)&&(i.current.value=String(f)),l!==d.current&&(d.current=l,u.current?.(l??null))},[r,c]),h.jsx(q,{field:e,error:c(String(r??"")),children:h.jsx("input",{id:e.name,type:"url",defaultValue:String(r??""),ref:i,onChange:m,style:{alignItems:"left"},className:U(A.input,A.textInput),placeholder:"https://example.com","aria-invalid":!!c(String(r??"")),"aria-describedby":c(String(r??""))?`${e.name}-error`:void 0})})},Ee=new ge,zt=new Set(["checkbox","switch","dropdown","radio","multi-selection","slider","stepper","color","rating"]),or={checkbox:Ur,color:Yr,date:Gr,dropdown:Kr,email:Zr,file:et,float:it,"float-array":at,image:lt,int:dt,"int-array":ft,"multi-selection":gt,multiline:pt,password:Ct,phone:yt,radio:xt,rating:St,separator:Qr,slider:jt,string:He,stepper:bt,switch:kt,text:He,time:Nt,unit:Dt,url:Vt};function sr(e,r,n){if(!n&&e in or){console.warn(`Can't Overwrite Base Component type "${e}".`);return}if(zt.has(e)){Ee.register(e,r);return}const a=t=>{const{callback:i,cancel:c}=Je((...m)=>{const d=t.onChange;typeof d=="function"&&d(...m)},200);return s.useEffect(()=>()=>{c()},[c]),s.createElement(r,{...t,onChange:i})};Ee.register(e,a)}function Tt(e,r){sr(e,r,!1)}function ir(e){return Ee.get(e)}let Ye=!1;function cr(){Ye||(Object.entries(or).forEach(([e,r])=>{sr(e,r,!0)}),Ye=!0)}const lr=new ge;function ur(e,r){lr.register(e,r)}function Lt(e){return lr.get(e)}ur("Preset_AlertSubmitHandler",(e,r,n)=>{const a={name:r||"Unnamed Instance",version:e.version,definition:e.name,values:n},t=JSON.stringify(a,null,2);alert(t)});const fr=s.memo(({field:e,value:r,handleChange:n,handleError:a})=>{const t=ir(e.type),o=s.useCallback((c,m)=>n(e.name,c,m),[n,e.name]),i=s.useCallback(c=>a?.(e.name,c),[a,e.name]);return t?h.jsx(t,{field:e,value:r,onChange:o,onError:i}):null},(e,r)=>e.field===r.field&&e.value===r.value&&e.handleChange===r.handleChange&&e.handleError===r.handleError);fr.displayName="FieldWrapper";const mr=(e,r,n,a)=>h.jsx(fr,{field:e,value:r[e.name],handleChange:n,handleError:a},e.name),dr=s.memo(({groupName:e,isOpen:r,fields:n,valuesMap:a,handleChange:t,handleError:o,toggleGroup:i,t:c})=>{const m=s.useCallback(()=>i(e),[i,e]),{formStyle:d,fieldStyle:u}=D(),f=s.useMemo(()=>({border:"1px solid var(--reactaform-border-color, #bbb)",padding:"var(--reactaform-fieldset-padding, 0.5em)",borderRadius:"var(--reactaform-border-radius, 4px)",marginBottom:"var(--reactaform-space, 8px)",...d?.fieldset||{},...u?.fieldset||{}}),[d,u]),l=s.useMemo(()=>({fontWeight:"bold",cursor:"pointer",display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0 var(--reactaform-space, 8px)",color:"var(--reactaform-text-color, inherit)",...d?.legend||{},...u?.legend||{}}),[d,u]);return h.jsxs("fieldset",{style:f,children:[h.jsxs("legend",{onClick:m,style:l,children:[h.jsx("span",{children:c(e)}),h.jsx("span",{children:r?"▼":"▶"})]}),r&&n.map(g=>h.jsx("div",{children:mr(g,a,t,o)},g.name))]})});dr.displayName="FieldGroup";const Pt=(e,r,n,a,t,o,i,c,m)=>{const d=r.slice(0,c).filter(g=>i[g.name]),f=zr(d).groups,l=[];return f.forEach(g=>{if(g.name){const y=e[g.name]??!0;l.push(h.jsx(dr,{groupName:g.name,isOpen:y,fields:g.fields,valuesMap:n,handleChange:t,handleError:o,toggleGroup:m,t:a},g.name))}else g.fields.forEach(y=>l.push(h.jsx("div",{children:mr(y,n,t,o)},y.name)))}),l},_t=e=>{const r={};return e.forEach(n=>{r[n.name]=!1}),r},Oe=(e,r,n,a)=>{const t=r[e];if(!t?.children)return;const o=n[e],i=o!=null?String(o):"";(t.children[i]||[]).forEach(m=>{a[m]=!0,Oe(m,r,n,a)})},pr=(e,r,n)=>{const a=r[e];a?.children&&Object.values(a.children).flat().forEach(t=>{n[t]=!1,pr(t,r,n)})},qt=(e,r,n,a)=>{const t={...n};return e.forEach(o=>{(!o.parents||Object.keys(o.parents).length===0)&&(t[o.name]=!0,Oe(o.name,a,r,t))}),t},Bt=(e,r,n,a,t)=>{const o={...e};if(pr(a,r,o),t!=null){const i=r[a];if(i?.children){const c=String(t);(i.children[c]||[]).forEach(d=>{o[d]=!0,Oe(d,r,n,o)})}}return o};function Ht(e,r,n,a,t){const o=Object.values(t).filter(Boolean);if(o.length>0)return{success:!1,message:a("Please fix validation errors before submitting."),errors:o};const i={...n},c=[];if(e&&Array.isArray(e.properties))for(const d of e.properties){const u=d.name,f=i[u];if(f==null)continue;const l=d.type;try{if(l==="int"||l==="number"||l==="float"){const g=Number(String(f).trim());isNaN(g)?c.push(a(`Invalid number format for field ${d.displayName||u}`)):i[u]=g}else if(l==="int-array"||l==="float-array"){const y=String(f).split(",").map(p=>p.trim()).filter(Boolean).map(p=>{const x=Number(p);return isNaN(x)?(c.push(a(`Invalid number "${p}" in array for field ${d.displayName||u}`)),0):x});c.length===0&&(i[u]=y)}}catch(g){c.push(a(`Error processing field ${d.displayName||u}: ${g}`))}}if(c.length>0)return{success:!1,message:a("Data transformation errors occurred."),errors:c};const m=er(e,i,a);if(m&&m.length>0)return{success:!1,message:"Validation Fail",errors:m};if(e&&typeof e.submitHandlerName=="string"){const d=Lt(e.submitHandlerName);if(d)try{const u=d(e,r?.name??null,i,a);if(u&&u.length>0)return{success:!1,message:a("Submission failed."),errors:Array.isArray(u)?u:[u]}}catch(u){return{success:!1,message:a("Submission handler error occurred."),errors:[String(u)]}}}return{success:!0,message:a("Form submitted successfully."),data:i}}const gr=({definition:e,instance:r,chunkSize:n=50,chunkDelay:a=50})=>{const{properties:t,displayName:o}=e,i=D(),{t:c,formStyle:m,language:d}=i,u={...i,definitionName:e?.name??i.definitionName},[f,l]=s.useState("en"),[g,y]=s.useState([]),[p,x]=s.useState({}),[R,v]=s.useState({}),[E,k]=s.useState({}),[w,S]=s.useState({}),[N,I]=s.useState({}),[j,F]=s.useState(null),[M,z]=s.useState(null),[B,Q]=s.useState(0),[K,oe]=s.useState(!1),[J,ee]=s.useState(!1),[Y,V]=s.useState(r.name||""),b=s.useRef(r),C=s.useRef(!1);s.useEffect(()=>{const $=Object.fromEntries(t.map(_=>[_.name,{..._,children:{}}]));t.forEach(_=>{_.parents&&Object.entries(_.parents).forEach(([se,he])=>{const ie=$[se];ie&&he.forEach(yr=>{ie.children||(ie.children={});const De=String(yr);ie.children[De]=[...ie.children[De]||[],_.name]})})}),Vr(t,$);const T=Object.values($),W={};T.forEach(_=>{if(_.type==="unit"){const se=typeof _.defaultValue=="number"?String(_.defaultValue):"",he=typeof _.defaultUnit=="string"?_.defaultUnit:String(_.defaultUnit??"m");W[_.name]=[se,he]}else W[_.name]=_.defaultValue}),b.current=r,Object.keys(r.values).forEach(_=>{$[_]!==void 0&&(W[_]=r.values[_])});const G=_t(T),Z={};T.forEach(_=>{_.group&&!(_.group in Z)&&(Z[_.group]=!0)});const ae=requestAnimationFrame(()=>{y(T),x($),v(W),k(qt(T,W,G,$)),S(Z),oe(!0),V(r.name)});return()=>cancelAnimationFrame(ae)},[t,r,e]),s.useEffect(()=>{if(!K||B>=g.length)return;const $=setTimeout(()=>{Q(T=>Math.min(T+n,g.length))},a);return()=>clearTimeout($)},[K,B,g.length,n,a]);const O=s.useCallback(($,T,W)=>{F(null),z(null),v(G=>{const Z={...G,[$]:T},ae=p[$];return ae&&["checkbox","dropdown","multi-select","radio","switch"].includes(ae.type)&&k(se=>Bt(se,p,Z,$,String(T))),Z}),I(G=>W?{...G,[$]:W}:Object.fromEntries(Object.entries(G).filter(([ae])=>ae!==$)))},[p,F,z]);s.useEffect(()=>{let $=0;return $=requestAnimationFrame(()=>{d!==f&&(l(d||"en"),F(null),z(null))}),()=>cancelAnimationFrame($)},[d,f]),s.useEffect(()=>{let $=0;return $=requestAnimationFrame(()=>{if(C.current){C.current=!1,b.current=r,V(r.name||"");return}b.current=r,F(null),z(null),V(r.name||"")}),()=>cancelAnimationFrame($)},[r,r.name]);const H=s.useCallback(($,T)=>{I(W=>T?{...W,[$]:String(T)}:Object.fromEntries(Object.entries(W).filter(([Z])=>Z!==$)))},[]),X=()=>{C.current=!0;const $=b.current?.name;b.current.name=Y;const T=Ht(e,b.current,R,c,N),W=typeof T.message=="string"?T.message:String(T.message),G=Object.values(T.errors??{}).join(`
|
|
293
|
+
`);F(G?W+`
|
|
294
|
+
`+G:W),z(T.success),T.success||(b.current.name=$??b.current.name,V($??""))},re=$=>{S(T=>({...T,[$]:!T[$]}))},L=s.useMemo(()=>Object.values(N).some(Boolean),[N]);return h.jsx(ke.Provider,{value:u,children:h.jsxs("div",{style:m.container,children:[o&&h.jsx("h2",{style:m.titleStyle,children:c(o)}),j&&h.jsxs("div",{role:"status",style:{marginBottom:12,padding:12,borderRadius:6,backgroundColor:M?"rgba(76, 175, 80, 0.12)":"rgba(225, 29, 72, 0.06)",border:`1px solid ${M?"rgba(76,175,80,0.3)":"rgba(225,29,72,0.12)"}`,color:M?"var(--reactaform-success-color, #4CAF50)":"var(--reactaform-error-color, #e11d48)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsx("div",{style:{whiteSpace:"pre-wrap",flex:1},children:j}),h.jsx("button",{onClick:()=>{F(null),z(null)},"aria-label":c("Dismiss"),style:{marginLeft:12,background:"transparent",border:"none",cursor:"pointer",color:"inherit",fontSize:16,lineHeight:1},children:"×"})]}),r&&h.jsx(Xe,{name:Y,onChange:$=>{V($),F(null),z(null)}}),h.jsxs(h.Fragment,{children:[Pt(w,g,R,c,O,H,E,B,re),B<g.length&&h.jsx("div",{style:{fontSize:"0.9em",color:"var(--reactaform-text-muted, #666)"}})]}),h.jsx("button",{onClick:X,disabled:L,onMouseEnter:()=>ee(!0),onMouseLeave:()=>ee(!1),style:{padding:"var(--reactaform-button-padding, var(--reactaform-space) 12px)",backgroundColor:L?"var(--reactaform-button-disabled-bg, #cccccc)":"var(--reactaform-button-bg, var(--reactaform-success-color))",color:"var(--reactaform-button-text, #ffffff)",border:"none",borderRadius:"4px",cursor:L?"var(--reactaform-button-disabled-cursor, not-allowed)":"pointer",fontSize:"var(--reactaform-button-font-size, 14px)",fontWeight:"var(--reactaform-button-font-weight, 500)",boxShadow:"var(--reactaform-button-shadow, none)",marginTop:"var(--reactaform-button-margin-top, 0.5em)",transition:"opacity 0.2s ease",opacity:L?"var(--reactaform-button-disabled-opacity, 0.6)":J?"var(--reactaform-button-hover-opacity, 0.9)":"1"},children:c("Submit")})]})})};cr();const Ut=(e,r=!1)=>({container:{padding:"var(--reactaform-space-sm, 8px)",margin:"0 auto",backgroundColor:"transparent",borderRadius:0,color:"var(--reactaform-color-text)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, system-ui, -apple-system, sans-serif)",boxSizing:"border-box",minHeight:e?.minHeight??"0",...e?.width?{width:e.width,overflowX:"auto"}:{maxWidth:"100%"},...e?.height?{height:e.height,overflowY:"auto"}:{}},buttonStyle:{padding:"var(--reactaform-space-sm, 8px) var(--reactaform-space-md, 16px)",backgroundColor:"var(--reactaform-color-primary)",color:"var(--reactaform-color-background)",border:"1px solid var(--reactaform-color-primary)",borderRadius:"var(--reactaform-border-radius, 6px)",cursor:"pointer",fontSize:e?.fontSize||"1rem",fontWeight:"600",transition:"all 0.2s ease",boxShadow:"var(--reactaform-shadow-small, 0 1px 3px rgba(0, 0, 0, 0.12))"},titleStyle:{marginBottom:"var(--reactaform-space-lg, 24px)",color:"var(--reactaform-color-text)",fontSize:typeof e?.fontSize=="number"?`${e.fontSize*1.5}px`:"1.5rem",fontWeight:"700",lineHeight:"1.2",textAlign:"left"}}),Wt=(e,r=!1)=>{const n={color:"var(--reactaform-color-text)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)",transition:"all 0.2s ease",outline:"none",width:"100%",boxSizing:"border-box"};return{container:{fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)",fontSize:e?.fontSize||"var(--reactaform-font-size, 1rem)",width:"100%",maxWidth:e?.width||"100%",marginBottom:"var(--reactaform-space-md, 16px)"},label:{display:"block",marginBottom:"var(--reactaform-space-xs, 4px)",fontWeight:"500",color:"var(--reactaform-color-text)",fontSize:"var(--reactaform-font-size, 1rem)",fontFamily:e?.fontFamily||"var(--reactaform-font-family, inherit)"},input:n,textInput:n,optionInput:n,select:{...n,cursor:"pointer",backgroundRepeat:"no-repeat",backgroundPosition:"right 8px center",backgroundSize:"16px",paddingRight:"32px",backgroundImage:`url("data:image/svg+xml;utf8,<svg
|
|
295
295
|
xmlns='http://www.w3.org/2000/svg'
|
|
296
296
|
viewBox='0 0 24 24'
|
|
297
297
|
fill='none'
|
|
@@ -300,4 +300,4 @@ React keys must be passed directly to JSX without using spread:
|
|
|
300
300
|
stroke-linecap='round'
|
|
301
301
|
stroke-linejoin='round'>
|
|
302
302
|
<polyline points='6,9 12,15 18,9'/>
|
|
303
|
-
</svg>")`},textarea:{...n,minHeight:"80px",resize:"vertical",paddingTop:"var(--reactaform-space-sm, 8px)"},error:{color:"var(--reactaform-color-error)",fontSize:"0.875rem",marginTop:"var(--reactaform-space-xs, 4px)",display:"block"}}},hr=({children:e,definitionName:r="",defaultStyle:n,defaultLanguage:
|
|
303
|
+
</svg>")`},textarea:{...n,minHeight:"80px",resize:"vertical",paddingTop:"var(--reactaform-space-sm, 8px)"},error:{color:"var(--reactaform-color-error)",fontSize:"0.875rem",marginTop:"var(--reactaform-space-xs, 4px)",display:"block"}}},hr=({children:e,definitionName:r="",defaultStyle:n,defaultLanguage:a="en",defaultDarkMode:t=!1,defaultLocalizeName:o="",className:i="reactaform-container"})=>{const c=r,m=o,d=t,u=a,f=s.useMemo(()=>n??{},[n]),[l,g]=s.useState({}),[y,p]=s.useState({}),[x,R]=s.useState({}),[v,E]=s.useState({});s.useEffect(()=>{let I=!0;return(async()=>{if(u==="en"){I&&(g({}),p({}));return}try{const F=await Lr(u),M=F.success?F.translations:{};I&&g(M);const z=await Pr(u,m),B=z.success?z.translations:{};I&&p(B)}catch{I&&(g({}),p({}))}})(),()=>{I=!1}},[u,m]),s.useEffect(()=>{E(Ut(f,d)),R(Wt(f,d))},[f,d]);const k=s.useMemo(()=>qr(u,l,y),[u,l,y]),w=s.useCallback((I,...j)=>k(I,...j),[k]),S=s.useMemo(()=>({definitionName:c,language:u,darkMode:d,formStyle:v,fieldStyle:x,t:w}),[c,u,d,x,v,w]),N=f?.height?{height:"100%"}:void 0;return h.jsx(ke.Provider,{value:S,children:h.jsx("div",{"data-reactaform-theme":d?"dark":"light",className:i,style:N,children:e})})};function Yt(e){if(!e||typeof e!="object")return"Definition must be an object";const r=e;if(!r.name||typeof r.name!="string")return"Definition must include a 'name' string";if(!r.version||typeof r.version!="string")return"Definition must include a 'version' string";if(r.properties!==void 0&&!Array.isArray(r.properties))return"'properties' must be an array if provided";if(Array.isArray(r.properties))for(let n=0;n<r.properties.length;n++){const a=r.properties[n];if(!a||typeof a!="object")return`Property at index ${n} must be an object`;if(!a.name||typeof a.name!="string")return`Property at index ${n} must have a string 'name'`;if(!a.type||typeof a.type!="string")return`Property '${a.name}' must have a string 'type'`}return null}async function Jt(e,r={}){const{validateSchema:n=!0}=r;try{if(!e||typeof e!="string")return{success:!1,error:"jsonData must be a non-empty JSON string"};const a=e.trim();if(!a)return{success:!1,error:"jsonData is empty"};let t;try{t=JSON.parse(a)}catch(o){return{success:!1,error:`Invalid JSON format: ${o instanceof Error?o.message:"Unknown parsing error"}`}}if(n){const o=Yt(t);if(o)return{success:!1,error:`Schema validation failed: ${o}`}}return{success:!0,definition:t}}catch(a){return{success:!1,error:`Unexpected error loading definition: ${a instanceof Error?a.message:"Unknown error"}`}}}function br(e,r){try{if(!e)return{success:!1,error:"Definition is required"};if(!r||typeof r!="string")return{success:!1,error:"Instance name is required"};const n={name:r,definition:e.name??"unknown",version:e.version??"1.0.0",values:{}},a=e.properties||[];return Array.isArray(a)&&a.forEach(t=>{const o=t;o.defaultValue!==void 0&&(n.values[o.name]=o.defaultValue)}),{success:!0,instance:n}}catch(n){return{success:!1,error:`Error creating instance: ${n instanceof Error?n.message:"Unknown error"}`}}}function Gt(e){try{if(!e)return{success:!1,error:"Instance data is required"};let r;if(typeof e=="string")try{r=JSON.parse(e)}catch(n){return{success:!1,error:`Invalid JSON format: ${n instanceof Error?n.message:"Unknown parsing error"}`}}else r=e;return typeof r!="object"||r===null?{success:!1,error:"Instance must be a valid object"}:{success:!0,instance:r}}catch(r){return{success:!1,error:`Error loading instance: ${r instanceof Error?r.message:"Unknown error"}`}}}cr();function Kt(e){const[r,n]=s.useState(null);return s.useEffect(()=>{const a=document.querySelector("[data-reactaform-theme]");if(!a)return;const t=a.closest("[data-reactaform-theme]");if(!t)return;const o=()=>n(t.getAttribute("data-reactaform-theme"));o();const i=new MutationObserver(c=>{for(const m of c)m.type==="attributes"&&m.attributeName==="data-reactaform-theme"&&o()});return i.observe(t,{attributes:!0,attributeFilter:["data-reactaform-theme"]}),()=>i.disconnect()},[e]),r}const Xt=({definitionData:e,instance:r,language:n,className:a,darkMode:t,style:o})=>{const i=s.useMemo(()=>{try{return typeof e=="string"?JSON.parse(e):e??null}catch{return null}},[e]),c={fontSize:"inherit",fontFamily:"inherit",...o},m=Kt(),d=t??m==="dark",u=n??"en";if(s.useEffect(()=>{let l=document.getElementById("popup-root");l||(l=document.createElement("div"),l.id="popup-root",document.body.appendChild(l))},[]),!i)return h.jsx("div",{style:{color:"red"},children:"Error: No form definition provided."});let f=r;if(!f){const l=br(i,i.name);if(!l.success||!l.instance)return h.jsx("div",{style:{color:"red"},children:"Error: Failed to create instance from definition."});f=l.instance}return h.jsx(hr,{definitionName:i.name,defaultStyle:c,defaultLanguage:u,defaultDarkMode:d,defaultLocalizeName:i.localization||"",className:a,children:h.jsx(gr,{definition:i,instance:f})})};function Zt(){if(!(typeof document>"u")&&!document.getElementById("reactaform-styles"))try{const e=document.createElement("style");e.id="reactaform-styles",e.textContent=xr,document.head.appendChild(e)}catch{}}Zt();exports.CSS_CLASSES=A;exports.ReactaForm=Xt;exports.ReactaFormProvider=hr;exports.ReactaFormRenderer=gr;exports.StandardFieldLayout=q;exports.Units=Hr;exports.combineClasses=U;exports.createInstanceFromDefinition=br;exports.deserializeDefinition=$r;exports.deserializeInstance=Ar;exports.getComponent=ir;exports.loadInstance=Gt;exports.loadJsonDefinition=Jt;exports.registerComponent=Tt;exports.registerFieldValidationHandler=Er;exports.registerFormValidationHandler=Rr;exports.registerSubmissionHandler=ur;exports.serializeDefinition=Mr;exports.serializeInstance=Nr;exports.useDebouncedCallback=Je;exports.useReactaFormContext=D;exports.validateFieldValue=P;exports.validateFormValues=er;
|
package/dist/reactaform.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--reactaform-primary-bg: #f9f9f9;--reactaform-secondary-bg: #fff;--reactaform-text-color: #000;--reactaform-text-muted: #666;--reactaform-border-color: #ccc;--reactaform-border-hover: #999;--reactaform-border-focus: #4CAF50;--reactaform-error-color: #e11d48;--reactaform-success-color: #4CAF50;--reactaform-space: 8px;--reactaform-space-lg: 12px;--reactaform-hover-bg: #f5f5f5;--reactaform-column-gap: var(--reactaform-space);--reactaform-inline-gap: var(--reactaform-space);--reactaform-label-gap: 4px;--reactaform-font-size: 14px;--reactaform-font-weight: 500;--reactaform-border-radius: 0px;--reactaform-shadow: 0 2px 4px rgba(0, 0, 0, .1);--reactaform-button-bg: var(--reactaform-success-color);--reactaform-button-text: #ffffff;--reactaform-button-padding: var(--reactaform-space) 12px;--reactaform-button-border-radius: var(--reactaform-border-radius);--reactaform-button-font-size: 14px;--reactaform-button-font-weight: var(--reactaform-font-weight);--reactaform-button-hover-opacity: .9;--reactaform-button-disabled-opacity: .6;--reactaform-button-disabled-bg: #cccccc;--reactaform-button-disabled-cursor: not-allowed;--reactaform-button-margin-top: .5em;--reactaform-button-shadow: none;--reactaform-input-padding: var(--reactaform-space);--reactaform-container-padding: var(--reactaform-space-lg);--reactaform-field-gap: var(--reactaform-space);--reactaform-input-bg: var(--reactaform-secondary-bg);--reactaform-field-text-color: #0000ff;--reactaform-tooltip-color-bg: rgba(60,60,60,.92);--reactaform-tooltip-color: #ffffff}[data-reactaform-theme=dark]{--reactaform-primary-bg: #121212;--reactaform-secondary-bg: #1A1A1A;--reactaform-input-bg: #262626;--reactaform-text-color: #EDEDED;--reactaform-text-muted: #A5A5A5;--reactaform-field-text-color: #C8C8E5;--reactaform-border-color: #3A3A3A;--reactaform-border-hover: #4A4A4A;--reactaform-border-focus: #4DA6FF;--reactaform-error-color: #FF6B6B;--reactaform-success-color: #4CAF6A;--reactaform-hover-bg: rgba(255, 255, 255, .06);--reactaform-shadow: 0 2px 8px rgba(0, 0, 0, .45);--reactaform-tooltip-color-bg: rgba(40, 40, 40, .95);--reactaform-tooltip-color: #F5F5F5}.reactaform-container{background-color:var(--reactaform-primary-bg);color:var(--reactaform-text-color);padding:var(--reactaform-container-padding);border-radius:var(--reactaform-border-radius);box-shadow:var(--reactaform-shadow);gap:var(--reactaform-space-lg);max-width:100%;margin:0 auto}.reactaform-field{display:grid;grid-template-columns:1fr 2fr;align-items:start;padding:0;gap:var(--reactaform-column-gap);margin-bottom:var(--reactaform-field-gap)}.reactaform-label{justify-self:start;align-self:center;white-space:normal;line-height:1.4;min-width:100px;color:var(--reactaform-text-color);font-weight:
|
|
1
|
+
:root{--reactaform-primary-bg: #f9f9f9;--reactaform-secondary-bg: #fff;--reactaform-text-color: #000;--reactaform-text-muted: #666;--reactaform-border-color: #ccc;--reactaform-border-hover: #999;--reactaform-border-focus: #4CAF50;--reactaform-error-color: #e11d48;--reactaform-success-color: #4CAF50;--reactaform-space: 8px;--reactaform-space-lg: 12px;--reactaform-hover-bg: #f5f5f5;--reactaform-column-gap: var(--reactaform-space);--reactaform-inline-gap: var(--reactaform-space);--reactaform-label-gap: 4px;--reactaform-font-size: 14px;--reactaform-font-weight: 500;--reactaform-border-radius: 0px;--reactaform-shadow: 0 2px 4px rgba(0, 0, 0, .1);--reactaform-button-bg: var(--reactaform-success-color);--reactaform-button-text: #ffffff;--reactaform-button-padding: var(--reactaform-space) 12px;--reactaform-button-border-radius: var(--reactaform-border-radius);--reactaform-button-font-size: 14px;--reactaform-button-font-weight: var(--reactaform-font-weight);--reactaform-button-hover-opacity: .9;--reactaform-button-disabled-opacity: .6;--reactaform-button-disabled-bg: #cccccc;--reactaform-button-disabled-cursor: not-allowed;--reactaform-button-margin-top: .5em;--reactaform-button-shadow: none;--reactaform-input-padding: var(--reactaform-space);--reactaform-container-padding: var(--reactaform-space-lg);--reactaform-field-gap: var(--reactaform-space);--reactaform-input-bg: var(--reactaform-secondary-bg);--reactaform-field-text-color: #0000ff;--reactaform-tooltip-color-bg: rgba(60,60,60,.92);--reactaform-tooltip-color: #ffffff}[data-reactaform-theme=dark]{--reactaform-primary-bg: #121212;--reactaform-secondary-bg: #1A1A1A;--reactaform-input-bg: #262626;--reactaform-text-color: #EDEDED;--reactaform-text-muted: #A5A5A5;--reactaform-field-text-color: #C8C8E5;--reactaform-border-color: #3A3A3A;--reactaform-border-hover: #4A4A4A;--reactaform-border-focus: #4DA6FF;--reactaform-error-color: #FF6B6B;--reactaform-success-color: #4CAF6A;--reactaform-hover-bg: rgba(255, 255, 255, .06);--reactaform-shadow: 0 2px 8px rgba(0, 0, 0, .45);--reactaform-tooltip-color-bg: rgba(40, 40, 40, .95);--reactaform-tooltip-color: #F5F5F5}.reactaform-container{background-color:var(--reactaform-primary-bg);color:var(--reactaform-text-color);padding:var(--reactaform-container-padding);border-radius:var(--reactaform-border-radius);box-shadow:var(--reactaform-shadow);gap:var(--reactaform-space-lg);max-width:100%;margin:0 auto}.reactaform-field{display:grid;grid-template-columns:1fr 2fr;align-items:start;padding:0;gap:var(--reactaform-column-gap);margin-bottom:var(--reactaform-field-gap)}.reactaform-label{justify-self:start;align-self:center;white-space:normal;line-height:1.4;min-width:100px;color:var(--reactaform-text-color);font-weight:600;font-size:var(--reactaform-font-size);-webkit-user-select:none;user-select:none}.reactaform-input{width:100%;color:var(--reactaform-text-color);border:1px solid var(--reactaform-border-color);border-radius:var(--reactaform-border-radius);padding:var(--reactaform-input-padding);box-sizing:border-box;background-color:var(--reactaform-input-bg);font-size:var(--reactaform-font-size);transition:border-color .2s ease;box-shadow:inset 0 1px #ffffff08}.reactaform-input:hover{border-color:var(--reactaform-border-hover)}.reactaform-input:focus{outline:none;border-color:var(--reactaform-border-focus);box-shadow:0 0 0 3px #22d3ee66,0 0 16px #22d3ee40,inset 0 1px #ffffff0d}.reactaform-input--text{text-align:left}.reactaform-input--number{text-align:right}.reactaform-input--select{text-align:left;appearance:none;background-image:url("data:image/svg+xml;utf8,<svg fill='%23666' height='8' viewBox='0 0 24 24' width='8' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");background-repeat:no-repeat;background-position:right var(--reactaform-space) center;background-size:20px;padding-right:32px}.reactaform-select{text-align:left;appearance:none;background-image:url("data:image/svg+xml;utf8,<svg fill='%23666' height='8' viewBox='0 0 24 24' width='8' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/></svg>");background-repeat:no-repeat;background-position:right var(--reactaform-space) center;background-size:2.5em;padding-right:32px;background-color:var(--reactaform-input-bg)}.reactaform-textarea{width:100%;background-color:var(--reactaform-input-bg);color:var(--reactaform-text-color);border:1px solid var(--reactaform-border-color);border-radius:var(--reactaform-border-radius);padding:var(--reactaform-input-padding);box-sizing:border-box}@media(max-width:1024px){.reactaform-container{padding:calc(var(--reactaform-space) * .8)}.reactaform-field{gap:calc(var(--reactaform-column-gap) * .8)}}@media(max-width:768px){.reactaform-field{grid-template-columns:1fr;gap:6px}.reactaform-label{justify-self:start;margin-bottom:4px;font-size:.9rem}.reactaform-container{padding:var(--reactaform-space)}.reactaform-input,.reactaform-textarea,.reactaform-select{font-size:16px;padding:12px}.reactaform-checkbox-wrapper,.reactaform-radio-wrapper{padding:8px 0;min-height:44px;align-items:center}.reactaform-group{margin-bottom:calc(var(--reactaform-space) * 1.5)}}@media(max-width:480px){.reactaform-container{padding:calc(var(--reactaform-space) * .7)}.reactaform-field{gap:8px}.reactaform-label{font-size:.85rem;line-height:1.3}.reactaform-input,.reactaform-textarea,.reactaform-select{padding:14px}}
|