@golemui/core 0.14.0 → 0.15.0

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/index.umd.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("rxjs");require("@standard-schema/spec");function at(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function ft(e){return e.issues===void 0}var Qt=class{constructor(e){this.value=e}map(e){return T(e(this.value))}isOk(){return!0}},qt=class{constructor(e){this.error=e}map(e){return I(this.error)}isOk(){return!1}};function T(e){return new Qt(e)}function I(e){return new qt(e)}var F=class Fe{constructor(t){this.decodeFn=t,this["~standard"]={version:1,vendor:"ts.data.json",validate:r=>{let n=this.decode(r);return n.isOk()?{value:n.value}:{issues:[{message:n.error}]}}},this.decodeToPromise=this.decodePromise,this.chain=this.flatMap}parse(t){let r=this.decode(t);if(r.isOk())return r.value;throw r.error}decode(t){return this.decodeFn(t)}decodePromise(t){return new Promise((r,n)=>{let o=this.decode(t);return o.isOk()?r(o.value):n(o.error)})}map(t){return new Fe(r=>{let n=this.decodeFn(r);return n.isOk()?T(t(n.value)):I(n.error)})}flatMap(t){return new Fe(r=>{let n=this.decodeFn(r);return n.isOk()?t(n.value).decode(r):I(n.error)})}},Yt=(e,t,r)=>`<${e}> decoder failed at index "${t}" with error: ${r}`,Q=(e,t)=>`${JSON.stringify(e)} is not a valid ${t}`;function Le(e,t){return new F(r=>{if(r instanceof Array){let n=[];for(let o=0;o<r.length;o++){let i=e.decode(r[o]);if(i.isOk())n.push(i.value);else return I(Yt(t,o,i.error))}return T(n)}else return I(Q(r,"array"))})}function Zt(){return new F(e=>typeof e=="boolean"?T(e):I(Q(e,"boolean")))}function ht(e){return new F(t=>e().decode(t))}var xt=(e,t)=>`${JSON.stringify(e)} is not exactly ${JSON.stringify(t)}`;function $e(e){return new F(t=>t===e?T(e):I(xt(t,e)))}function Ae(){return new F(e=>typeof e=="number"?T(e):I(Q(e,"number")))}var bt=(e,t,r)=>`<${e}> decoder failed at key "${t}" with error: ${r}`;function ne(e,t){return new F(r=>{if(r!==null&&typeof r=="object"){let n={};for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let i,s=e[o];if(s instanceof F?i=s.decode(r[o]):i=s.decoder.decode(r[s.fromKey]),i.isOk())n[o]=i.value;else return I(bt(t,o,i.error))}return T(n)}else return I(Q(r,t))})}var er=(e,t)=>`<${e}> decoder failed because ${JSON.stringify(t)} can't be decoded with any of the provided oneOf decoders`;function q(e,t){return new F(r=>{for(let n=0;n<e.length;n++){let o=e[n].decode(r);if(o.isOk())return o}return I(er(t,r))})}function S(e){return new F(t=>t===void 0?T(void 0):e.decode(t))}var tr=(e,t,r)=>`<${e}> record decoder failed at key "${t}" with error: ${r}`;function rr(e,t){return new F(r=>{if(r!==null&&typeof r=="object"){let n={};for(let o in r)if(Object.prototype.hasOwnProperty.call(r,o)){let i=e.decode(r[o]);if(i.isOk())n[o]=i.value;else return I(tr(t,o,i.error))}return T(n)}else return I(Q(r,t))})}function C(){return new F(e=>typeof e=="string"?T(e):I(Q(e,"string")))}function X(){return new F(e=>T(e))}function oe(e,t){return new F(r=>{if(typeof r!="object"||r===null)return I(`<${t}> failed. Expected object literal, got "${typeof r}"`);const n={};for(const[o,i]of Object.entries(e)){const s=i.decoder.decode(r[o]);if(!s.isOk())return I(`<${t}> failed at "${o}" with ${s.error}`);if(n[o]=s.value,i.suffixed){for(const[u,c]of Object.entries(r))if(u.startsWith(o+".")){const p=i.decoder.decode(c);if(!p.isOk())return I(`<${t}> failed at "${u}" with ${p.error}`);n[u]=p.value}}}return T(n)})}const je=()=>crypto.randomUUID().slice(0,8),nr=e=>typeof e!="function"&&e.kind==="display",ee=e=>typeof e!="function"&&e.kind==="action",D=e=>typeof e!="function"&&e.kind==="input",Te=e=>typeof e!="function"&&e.kind==="layout",ie=e=>typeof e=="function",or=ne({in:Le(C(),"In[]")},"In"),Me=ne({when:C()},"When"),Se=q([or,Me],"In | When"),ir=ne({from:Le(C(),"From[]")},"From"),Ee=q([ir,Me],"Exclude"),We=q([Zt(),Me],"Bool | When"),sr=new F(e=>{const t=typeof e;return t==="function"?T(e):I(`Expected a function, got '${t}'`)}),M=e=>q([e,sr],""),Ve=oe({load:{suffixed:!0,decoder:M(S(C()))},click:{suffixed:!0,decoder:M(S(C()))},change:{suffixed:!0,decoder:M(S(C()))},filter:{suffixed:!0,decoder:M(S(C()))},blur:{suffixed:!0,decoder:M(S(C()))}},"On"),dr=ne({key:C(),default:S(C()),params:X()},"TranslationConfig"),pt=q([C(),dr],"Localizable"),ve=S(C()).map(e=>e||je()),ur=oe({kind:{decoder:$e("display")},uid:{decoder:ve},type:{decoder:C()},size:{suffixed:!0,decoder:S(Ae())},include:{decoder:S(Se)},exclude:{decoder:S(Ee)},props:{decoder:S(X())}},"DisplayWidget"),cr=oe({kind:{decoder:$e("action")},uid:{decoder:ve},type:{decoder:C()},size:{suffixed:!0,decoder:S(Ae())},include:{decoder:S(Se)},exclude:{decoder:S(Ee)},label:{suffixed:!0,decoder:M(pt)},disabled:{suffixed:!0,decoder:S(We)},on:{decoder:S(Ve)},props:{decoder:S(X())}},"ActionWidget"),lr=new F(e=>{const t=typeof e;if(t==="function"){const r=e,n=r(void 0);return r.uid=n.uid||je(),r.type=n.type,r.path=n.path,T(r)}else return I(`Expected a function, got '${t}'`)}),ar=oe({kind:{decoder:$e("input")},uid:{decoder:ve},type:{decoder:C()},size:{suffixed:!0,decoder:S(Ae())},include:{decoder:S(Se)},exclude:{decoder:S(Ee)},disabled:{suffixed:!0,decoder:S(We)},readonly:{suffixed:!0,decoder:S(We)},on:{decoder:S(Ve)},props:{decoder:S(X())},label:{suffixed:!0,decoder:M(S(pt))},path:{decoder:C()},defaultValue:{decoder:S(X())},validator:{suffixed:!0,decoder:M(S(X()))}},"InputWidget").map(e=>{const t={...e};if(e.uid||(t.uid=`${e.path}-${e.type}`),e.type==="repeater"){const r=e.props;r.template=Be.parse(r.template)}return t}),fr=ht(()=>q([lr,ar,Be,ur,cr],"FormWidget")),Be=oe({kind:{decoder:$e("layout")},uid:{decoder:ve},type:{decoder:C()},size:{suffixed:!0,decoder:S(Ae())},include:{decoder:S(Se)},exclude:{decoder:S(Ee)},props:{decoder:S(X())},on:{decoder:S(Ve)},children:{decoder:Le(fr,"FormWidget[]")}},"LayoutWidget"),G=class G{constructor(){this.widgetLoaders={},this._ready=!1}get ready(){return this._ready}setWidgetLoaders(t){this.widgetLoaders=t,this._ready=!0}async loadWidget(t){const r=this.widgetLoaders[t];if(!G.sharedCache.has(r)){const n=r().catch(o=>(G.sharedCache.delete(r),Promise.reject(o)));G.sharedCache.set(r,n)}return G.sharedCache.get(r)}};G.sharedCache=new Map;let Re=G;function hr(e){return{...e,form:{uid:"",type:"flex",kind:"layout",children:e.form}}}const gt=ne({states:S(rr(C(),"states")),form:ht(()=>Be)},"FormDef"),mt=e=>({formName:"",formDef:gt.parse({form:{kind:"layout",type:"flex",children:[]}}),flatForm:{},currentStates:[],calculatedWidgets:{},validations:{},touchedControls:{},injectedValidations:{},widgetFlags:{},widgetPropOverrides:{},data:{},meta:{},formHealth:{status:"ok"},touched:!1,lang:e}),pr=e=>!(typeof e!="object"||e===null||typeof e.key!="string");function gr(e){const t=new Intl.Locale(e).maximize().script;return["Arab","Hebr","Thaa","Syrc","Tfng","Adlm","Rohg"].includes(t||"")?"rtl":"ltr"}const yt=(e=navigator.language||"en-US")=>{const t=new Set;return{get lang(){return e},translate(n){return n},subscribe(n){return t.add(n),()=>{t.delete(n)}},setLang(n){e=n,t.forEach(o=>o(e))}}},mr=e=>{throw new Error(`Unhandled case: ${JSON.stringify(e)}`)};function _(e,...t){return t.reduce((r,n)=>n(r),e)}function yr(e,t){const r=t.payload.widget.uid;if(!r)throw new Error("addWidget: widget must have a uid");return{...e,calculatedWidgets:{...e.calculatedWidgets,[r]:{source:t.payload.widget,current:{}}}}}const b={calculateCurrentStateError:10,initializeParseError:20,initializeUidCollisionError:21,initializeUnknownError:22,widgetCouldNotBeLoaded:30},k=(e,t)=>{if(e===void 0)throw new Error("obj is undefined");return t.split(".").reduce((r,n)=>r===void 0||n===""?r:Array.isArray(r)?r[parseInt(n,10)]:r[n],e)},He=(e,t,r)=>{if(e===null)throw new Error("object is null");if(e===void 0)throw new Error("object is undefined");if(t==="")throw new Error("path cannot be empty");const n=t.split(".");let o=e;for(let s=0;s<n.length-1;s++){const u=n[s],c=n[s+1];(o[u]==null||typeof o[u]!="object")&&(o[u]=$r(c)?[]:{}),o=o[u]}const i=n[n.length-1];return o[i]=r,e};function $r(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}const ue=(e,t)=>(delete e[t],e);function ke(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>ke(r));const t={};for(const r of Object.keys(e))t[r]=ke(e[r]);return t}const P={FORM:"$form",META:"$meta",ERRORS:"$errors",FORM_IS_INVALID:"$formIsInvalid"},Ar=e=>typeof e=="string"&&!e.includes(" ")&&(e.startsWith(`${P.FORM}.`)||e.startsWith(`${P.META}.`)||e.startsWith(`${P.ERRORS}.`)||e===P.FORM_IS_INVALID),Sr=[P.FORM,P.META,P.ERRORS].map(e=>e.replace("$","\\$")).join("|"),Er=new RegExp(`\\{\\{(?:(?<scope>${Sr})\\.(?<path>[^}]+)|(?<isInvalid>\\${P.FORM_IS_INVALID}))\\}\\}`,"g"),vr=(e,t)=>typeof e!="string"||!e.includes("{{$")?e:e.replace(Er,(r,...n)=>{const o=n[n.length-1],{scope:i,path:s,isInvalid:u}=o;try{if(u===P.FORM_IS_INVALID)return t.resolveFormIsInvalid();if(i&&s)switch(i){case P.FORM:return t.resolveFormPath(s);case P.META:return t.resolveMetaPath(s);case P.ERRORS:return t.resolveErrorsPath(s);default:return r}}catch(c){return console.error(`Error resolving Expression: '${e}'`,c),r}return r}),Ir=(e,t)=>{const r=`${P.FORM}.`;if(e.startsWith(r))return t.resolveFormPath(e.replace(r,""));const n=`${P.META}.`;if(e.startsWith(n))return t.resolveMetaPath(e.replace(n,""));const o=`${P.ERRORS}.`;if(e.startsWith(o))return t.resolveErrorsPath(e.replace(o,""));if(e===P.FORM_IS_INVALID)return t.resolveFormIsInvalid()};function Ge(e){return e.flatMap(t=>[t,...Te(t)?Ge(t.children):[]])}function Ke(e){return Object.entries(e.validations).reduce((r,[n,o])=>(o!==null&&(r.$formIsInvalid=!0,He(r.$errors,n,[...o])),r),{$formIsInvalid:!1,$errors:{}})}const Xe=32;let _e,h,g,y=e=>(h=0,g=e,y.newline=!1,e=E(),g[h]?z():e||""),z=(e="Unexpected token",t=h,r=g.slice(0,t).split(`
2
- `),n=r.pop(),o=g.slice(Math.max(0,t-40),t),i="̭",s=(g[t]||" ")+i,u=g.slice(t+1,t+20))=>{throw SyntaxError(`${e} at ${r.length+1}:${n.length+1}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("rxjs");require("@standard-schema/spec");function ft(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function ht(e){return e.issues===void 0}var qt=class{constructor(e){this.value=e}map(e){return T(e(this.value))}isOk(){return!0}},Yt=class{constructor(e){this.error=e}map(e){return I(this.error)}isOk(){return!1}};function T(e){return new qt(e)}function I(e){return new Yt(e)}var D=class De{constructor(t){this.decodeFn=t,this["~standard"]={version:1,vendor:"ts.data.json",validate:r=>{let n=this.decode(r);return n.isOk()?{value:n.value}:{issues:[{message:n.error}]}}},this.decodeToPromise=this.decodePromise,this.chain=this.flatMap}parse(t){let r=this.decode(t);if(r.isOk())return r.value;throw r.error}decode(t){return this.decodeFn(t)}decodePromise(t){return new Promise((r,n)=>{let i=this.decode(t);return i.isOk()?r(i.value):n(i.error)})}map(t){return new De(r=>{let n=this.decodeFn(r);return n.isOk()?T(t(n.value)):I(n.error)})}flatMap(t){return new De(r=>{let n=this.decodeFn(r);return n.isOk()?t(n.value).decode(r):I(n.error)})}},Zt=(e,t,r)=>`<${e}> decoder failed at index "${t}" with error: ${r}`,Y=(e,t)=>`${JSON.stringify(e)} is not a valid ${t}`;function Ue(e,t){return new D(r=>{if(r instanceof Array){let n=[];for(let i=0;i<r.length;i++){let o=e.decode(r[i]);if(o.isOk())n.push(o.value);else return I(Zt(t,i,o.error))}return T(n)}else return I(Y(r,"array"))})}function xt(){return new D(e=>typeof e=="boolean"?T(e):I(Y(e,"boolean")))}function pt(e){return new D(t=>e().decode(t))}var bt=(e,t)=>`${JSON.stringify(e)} is not exactly ${JSON.stringify(t)}`;function q(e){return new D(t=>t===e?T(e):I(bt(t,e)))}function $e(){return new D(e=>typeof e=="number"?T(e):I(Y(e,"number")))}var er=(e,t,r)=>`<${e}> decoder failed at key "${t}" with error: ${r}`;function ie(e,t){return new D(r=>{if(r!==null&&typeof r=="object"){let n={};for(let i in e)if(Object.prototype.hasOwnProperty.call(e,i)){let o,s=e[i];if(s instanceof D?o=s.decode(r[i]):o=s.decoder.decode(r[s.fromKey]),o.isOk())n[i]=o.value;else return I(er(t,i,o.error))}return T(n)}else return I(Y(r,t))})}var tr=(e,t)=>`<${e}> decoder failed because ${JSON.stringify(t)} can't be decoded with any of the provided oneOf decoders`;function z(e,t){return new D(r=>{for(let n=0;n<e.length;n++){let i=e[n].decode(r);if(i.isOk())return i}return I(tr(t,r))})}function y(e){return new D(t=>t===void 0?T(void 0):e.decode(t))}var rr=(e,t,r)=>`<${e}> record decoder failed at key "${t}" with error: ${r}`;function nr(e,t){return new D(r=>{if(r!==null&&typeof r=="object"){let n={};for(let i in r)if(Object.prototype.hasOwnProperty.call(r,i)){let o=e.decode(r[i]);if(o.isOk())n[i]=o.value;else return I(rr(t,i,o.error))}return T(n)}else return I(Y(r,t))})}function C(){return new D(e=>typeof e=="string"?T(e):I(Y(e,"string")))}function X(){return new D(e=>T(e))}function oe(e,t){return new D(r=>{if(typeof r!="object"||r===null)return I(`<${t}> failed. Expected object literal, got "${typeof r}"`);const n={};for(const[i,o]of Object.entries(e)){const s=o.decoder.decode(r[i]);if(!s.isOk())return I(`<${t}> failed at "${i}" with ${s.error}`);if(n[i]=s.value,o.suffixed){for(const[u,c]of Object.entries(r))if(u.startsWith(i+".")){const p=o.decoder.decode(c);if(!p.isOk())return I(`<${t}> failed at "${u}" with ${p.error}`);n[u]=p.value}}}return T(n)})}const Le=()=>crypto.randomUUID().slice(0,8),ir=e=>typeof e!="function"&&e.kind==="display",te=e=>typeof e!="function"&&e.kind==="action",P=e=>typeof e!="function"&&e.kind==="input",Te=e=>typeof e!="function"&&e.kind==="layout",se=e=>typeof e=="function",or=ie({in:Ue(C(),"In[]")},"In"),Ve=ie({when:C()},"When"),Se=z([or,Ve],"In | When"),sr=ie({from:Ue(C(),"From[]")},"From"),ve=z([sr,Ve],"Exclude"),We=z([xt(),Ve],"Bool | When"),dr=new D(e=>{const t=typeof e;return t==="function"?T(e):I(`Expected a function, got '${t}'`)}),V=e=>z([e,dr],""),Me=oe({load:{suffixed:!0,decoder:V(y(C()))},click:{suffixed:!0,decoder:V(y(C()))},change:{suffixed:!0,decoder:V(y(C()))},filter:{suffixed:!0,decoder:V(y(C()))},blur:{suffixed:!0,decoder:V(y(C()))}},"On"),ur=ie({key:C(),default:y(C()),params:X()},"TranslationConfig"),gt=z([C(),ur],"Localizable"),Ee=y(C()).map(e=>e||Le()),cr=oe({kind:{decoder:q("display")},uid:{decoder:Ee},type:{decoder:C()},size:{suffixed:!0,decoder:y($e())},include:{decoder:y(Se)},exclude:{decoder:y(ve)},props:{decoder:y(X())}},"DisplayWidget"),lr=oe({kind:{decoder:q("action")},uid:{decoder:Ee},type:{decoder:C()},actionType:{decoder:y(z([q("button"),q("submit")],"button | submit "))},size:{suffixed:!0,decoder:y($e())},include:{decoder:y(Se)},exclude:{decoder:y(ve)},label:{suffixed:!0,decoder:V(gt)},disabled:{suffixed:!0,decoder:y(We)},on:{decoder:y(Me)},props:{decoder:y(X())}},"ActionWidget"),ar=new D(e=>{const t=typeof e;if(t==="function"){const r=e,n=r(void 0);return r.uid=n.uid||Le(),r.type=n.type,r.path=n.path,T(r)}else return I(`Expected a function, got '${t}'`)}),fr=oe({kind:{decoder:q("input")},uid:{decoder:Ee},type:{decoder:C()},size:{suffixed:!0,decoder:y($e())},include:{decoder:y(Se)},exclude:{decoder:y(ve)},disabled:{suffixed:!0,decoder:y(We)},readonly:{suffixed:!0,decoder:y(We)},on:{decoder:y(Me)},props:{decoder:y(X())},label:{suffixed:!0,decoder:V(y(gt))},path:{decoder:C()},defaultValue:{decoder:y(X())},validator:{suffixed:!0,decoder:V(y(X()))}},"InputWidget").map(e=>{const t={...e};if(e.uid||(t.uid=`${e.path}-${e.type}`),e.type==="repeater"){const r=e.props;r.template=Be.parse(r.template)}return t}),hr=pt(()=>z([ar,fr,Be,cr,lr],"FormWidget")),Be=oe({kind:{decoder:q("layout")},uid:{decoder:Ee},type:{decoder:C()},size:{suffixed:!0,decoder:y($e())},include:{decoder:y(Se)},exclude:{decoder:y(ve)},props:{decoder:y(X())},on:{decoder:y(Me)},children:{decoder:Ue(hr,"FormWidget[]")}},"LayoutWidget"),G=class G{constructor(){this.widgetLoaders={},this._ready=!1}get ready(){return this._ready}setWidgetLoaders(t){this.widgetLoaders=t,this._ready=!0}async loadWidget(t){const r=this.widgetLoaders[t];if(!G.sharedCache.has(r)){const n=r().catch(i=>(G.sharedCache.delete(r),Promise.reject(i)));G.sharedCache.set(r,n)}return G.sharedCache.get(r)}};G.sharedCache=new Map;let Re=G;function pr(e){return{...e,form:{uid:"",type:"flex",kind:"layout",children:e.form}}}const mt=ie({states:y(nr(C(),"states")),form:pt(()=>Be)},"FormDef"),yt=e=>({formName:"",formDef:mt.parse({form:{kind:"layout",type:"flex",children:[]}}),flatForm:{},currentStates:[],calculatedWidgets:{},validations:{},touchedControls:{},injectedValidations:{},isFormValid:!0,widgetFlags:{},widgetPropOverrides:{},data:{},meta:{},formHealth:{status:"ok"},touched:!1,lang:e}),gr=e=>!(typeof e!="object"||e===null||typeof e.key!="string");function mr(e){const t=new Intl.Locale(e).maximize().script;return["Arab","Hebr","Thaa","Syrc","Tfng","Adlm","Rohg"].includes(t||"")?"rtl":"ltr"}const At=(e=navigator.language||"en-US")=>{const t=new Set;return{get lang(){return e},translate(n){return n},subscribe(n){return t.add(n),()=>{t.delete(n)}},setLang(n){e=n,t.forEach(i=>i(e))}}},yr=e=>{throw new Error(`Unhandled case: ${JSON.stringify(e)}`)};function _(e,...t){return t.reduce((r,n)=>n(r),e)}function Ar(e,t){const r=t.payload.widget.uid;if(!r)throw new Error("addWidget: widget must have a uid");return{...e,calculatedWidgets:{...e.calculatedWidgets,[r]:{source:t.payload.widget,current:{}}}}}const ee={calculateCurrentStateError:10,initializeParseError:20,initializeUidCollisionError:21,initializeUnknownError:22,widgetCouldNotBeLoaded:30},k=(e,t)=>{if(e===void 0)throw new Error("obj is undefined");return t.split(".").reduce((r,n)=>r===void 0||n===""?r:Array.isArray(r)?r[parseInt(n,10)]:r[n],e)},He=(e,t,r)=>{if(e===null)throw new Error("object is null");if(e===void 0)throw new Error("object is undefined");if(t==="")throw new Error("path cannot be empty");const n=t.split(".");let i=e;for(let s=0;s<n.length-1;s++){const u=n[s],c=n[s+1];(i[u]==null||typeof i[u]!="object")&&(i[u]=$r(c)?[]:{}),i=i[u]}const o=n[n.length-1];return i[o]=r,e};function $r(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}const ce=(e,t)=>(delete e[t],e);function ke(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>ke(r));const t={};for(const r of Object.keys(e))t[r]=ke(e[r]);return t}const F={FORM:"$form",META:"$meta",ERRORS:"$errors",FORM_IS_INVALID:"$formIsInvalid"},Sr=e=>typeof e=="string"&&!e.includes(" ")&&(e.startsWith(`${F.FORM}.`)||e.startsWith(`${F.META}.`)||e.startsWith(`${F.ERRORS}.`)||e===F.FORM_IS_INVALID),vr=[F.FORM,F.META,F.ERRORS].map(e=>e.replace("$","\\$")).join("|"),Er=new RegExp(`\\{\\{(?:(?<scope>${vr})\\.(?<path>[^}]+)|(?<isInvalid>\\${F.FORM_IS_INVALID}))\\}\\}`,"g"),Ir=(e,t)=>typeof e!="string"||!e.includes("{{$")?e:e.replace(Er,(r,...n)=>{const i=n[n.length-1],{scope:o,path:s,isInvalid:u}=i;try{if(u===F.FORM_IS_INVALID)return t.resolveFormIsInvalid();if(o&&s)switch(o){case F.FORM:return t.resolveFormPath(s);case F.META:return t.resolveMetaPath(s);case F.ERRORS:return t.resolveErrorsPath(s);default:return r}}catch(c){return console.error(`Error resolving Expression: '${e}'`,c),r}return r}),Cr=(e,t)=>{const r=`${F.FORM}.`;if(e.startsWith(r))return t.resolveFormPath(e.replace(r,""));const n=`${F.META}.`;if(e.startsWith(n))return t.resolveMetaPath(e.replace(n,""));const i=`${F.ERRORS}.`;if(e.startsWith(i))return t.resolveErrorsPath(e.replace(i,""));if(e===F.FORM_IS_INVALID)return t.resolveFormIsInvalid()};function Ge(e){return e.flatMap(t=>[t,...Te(t)?Ge(t.children):[]])}function Ke(e){return Object.entries(e.validations).reduce((r,[n,i])=>(i!==null&&(r.$formIsInvalid=!0,He(r.$errors,n,[...i])),r),{$formIsInvalid:!1,$errors:{}})}const Xe=32;let _e,h,g,A=e=>(h=0,g=e,A.newline=!1,e=v(),g[h]?J():e||""),J=(e="Unexpected token",t=h,r=g.slice(0,t).split(`
2
+ `),n=r.pop(),i=g.slice(Math.max(0,t-40),t),o="̭",s=(g[t]||" ")+o,u=g.slice(t+1,t+20))=>{throw SyntaxError(`${e} at ${r.length+1}:${n.length+1}
3
3
  ${g[t-41]!==`
4
- `,""+o}${s}${u}`)},$t=(e,t=h)=>(Array.isArray(e)&&(e.loc=t),e),Y=(e,t=h,r)=>{for(;r=e(g.charCodeAt(h));)h+=r;return g.slice(t,h)},O=(e=1)=>g[h+=e],Ne=e=>h=e,E=(e=0,t)=>{let r,n,o,i,s;for(t&&y.asi&&(y.newline=!1);(r=y.space())&&(s=y.newline,1)&&r!==t&&(o=(n&&r===91&&_e&&y.asi?.(n,e,E)||null)??((i=R[r])&&i(n,e))??(n&&s&&y.asi?.(n,e,E))??(!n&&Y(y.id)));)n=o;return t&&(r==t?(h++,t===125&&y.asi&&(y.newline=!0)):z("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),n},B=(e,t=h)=>{for(_e=!1;(e=g.charCodeAt(h))<=Xe;)y.asi&&e===10&&(y.newline=_e=!0),h++;return e},Cr=(e=h)=>{for(;g.charCodeAt(e)<=Xe;)e++;return g.charCodeAt(e)};y.id=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e==36||e==95||e>=192&&e!=215&&e!=247;let Or=(e,t=e.length)=>g.substr(h,t)===e&&!y.id(g.charCodeAt(h+t)),R=[],it={},W=(e,t=Xe,r,n=e.charCodeAt(0),o=e.length,i=R[n],s=e.toUpperCase()!==e,u,c)=>(t=it[e]=!i&&it[e]||t,R[n]=(p,A,m,f=h)=>(u=m,(m?e==m:(o<2||e.charCodeAt(1)===g.charCodeAt(h+1)&&(o<3||g.substr(h,o)==e))&&(!s||!y.id(g.charCodeAt(h+o)))&&(u=m=e))&&A<t&&(h+=o,(c=r(p))?$t(c,f):(h=f,u=0,!s&&!i&&!p&&z()),c)||i?.(p,A,u))),$=(e,t,r=!1)=>W(e,t,n=>n&&(o=>o&&[e,n,o])(E(t-(r?.5:0)))),H=(e,t,r)=>W(e,t,n=>!n&&(n=E(t-.5))&&[e,n]),se=(e,t)=>W(e,200,r=>!r&&[,t]),At=(e,t,r)=>W(e,t,(n,o)=>(o=E(t-(r?.5:0)),n?.[0]!==e&&(n=[e,n||null]),o?.[0]===e?n.push(...o.slice(1)):n.push(o||null),n)),ze=(e,t)=>W(e[0],t,r=>!r&&[e,E(0,e.charCodeAt(1))||null]),St=(e,t)=>W(e[0],t,r=>r&&[e,r,E(0,e.charCodeAt(1))||null]),de=(e,t,r,n=e.charCodeAt(0),o=e.length,i=R[n],s)=>R[n]=(u,c,p,A=h)=>!u&&(p?e==p:(o<2||g.substr(h,o)==e)&&(p=e))&&c<t&&!y.id(g.charCodeAt(h+o))&&(!y.prop||y.prop(h+o))&&(Ne(h+o),(s=r())?$t(s,A):Ne(A),s)||i?.(u,c,p);Object.defineProperty(y,"space",{configurable:!0,enumerable:!0,get:()=>B,set:e=>B=e});const Ue={},l=(e,t,r=Ue[e])=>Ue[e]=(...n)=>t(...n)||r?.(...n),d=e=>Array.isArray(e)?e[0]==null?(t=>()=>t)(e[1]):Ue[e[0]]?.(...e.slice(1))??z(`Unknown operator: ${e[0]}`,e?.loc):e===void 0?()=>{}:t=>t?.[e],fe=46,te=48,he=57,wr=69,Pr=101,Dr=43,Fr=45,ae=95,Et=110,Tr=97,Wr=102,Rr=65,kr=70,vt=e=>e.indexOf("_")<0?e:e.replaceAll("_",""),Je=e=>{let t=vt(Y(r=>r===fe&&g.charCodeAt(h+1)!==fe||r>=te&&r<=he||r===ae||((r===wr||r===Pr)&&((r=g.charCodeAt(h+1))>=te&&r<=he||r===Dr||r===Fr)?2:0)));return g.charCodeAt(h)===Et?(O(),[,BigInt(t)]):(e=+t)!=e?z():[,e]},_r={2:e=>e===48||e===49||e===ae,8:e=>e>=48&&e<=55||e===ae,16:e=>e>=te&&e<=he||e>=Tr&&e<=Wr||e>=Rr&&e<=kr||e===ae};y.number=null;R[fe]=e=>!e&&g.charCodeAt(h+1)!==fe&&Je();for(let e=te;e<=he;e++)R[e]=t=>t?void 0:Je();R[te]=e=>{if(e)return;const t=y.number;if(t){for(const[r,n]of Object.entries(t))if(r[0]==="0"&&g[h+1]?.toLowerCase()===r[1]){O(2);const o=vt(Y(_r[n]));return g.charCodeAt(h)===Et?(O(),[,BigInt("0"+r[1]+o)]):[,parseInt(o,n)]}}return Je()};const Nr=92,st=34,dt=39,Ur={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},It=e=>(t,r,n="")=>{if(!(t||!y.string?.[String.fromCharCode(e)]))return O(),Y(o=>o-e&&(o===Nr?(n+=Ur[g[h+1]]||g[h+1],2):(n+=g[h],1))),g[h]===String.fromCharCode(e)?O():z("Bad string"),[,n]};R[st]=It(st);R[dt]=It(dt);y.string={'"':!0};const Lr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(e=>$(e,Lr,!0));const Ct=(e,t,r,n)=>typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=d(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),o=>t(r(o),n(o),o)):e[0]==="()"&&e.length===2?Ct(e[1],t):(()=>{throw Error("Invalid assignment target")})(),ut={"=":(e,t,r)=>e[t]=r,"+=":(e,t,r)=>e[t]+=r,"-=":(e,t,r)=>e[t]-=r,"*=":(e,t,r)=>e[t]*=r,"/=":(e,t,r)=>e[t]/=r,"%=":(e,t,r)=>e[t]%=r,"|=":(e,t,r)=>e[t]|=r,"&=":(e,t,r)=>e[t]&=r,"^=":(e,t,r)=>e[t]^=r,">>=":(e,t,r)=>e[t]>>=r,"<<=":(e,t,r)=>e[t]<<=r};for(const e in ut)l(e,(t,r)=>(r=d(r),Ct(t,(n,o,i)=>ut[e](n,o,r(i)))));const jr=30,Mr=40,Vr=140;H("!",Vr);$("||",jr);$("&&",Mr);l("!",e=>(e=d(e),t=>!e(t)));l("||",(e,t)=>(e=d(e),t=d(t),r=>e(r)||t(r)));l("&&",(e,t)=>(e=d(e),t=d(t),r=>e(r)&&t(r)));const Br=50,Hr=60,Gr=70,Ot=100,Kr=140;$("|",Br);$("&",Gr);$("^",Hr);$(">>",Ot);$("<<",Ot);H("~",Kr);l("~",e=>(e=d(e),t=>~e(t)));l("|",(e,t)=>(e=d(e),t=d(t),r=>e(r)|t(r)));l("&",(e,t)=>(e=d(e),t=d(t),r=>e(r)&t(r)));l("^",(e,t)=>(e=d(e),t=d(t),r=>e(r)^t(r)));l(">>",(e,t)=>(e=d(e),t=d(t),r=>e(r)>>t(r)));l("<<",(e,t)=>(e=d(e),t=d(t),r=>e(r)<<t(r)));const Ie=90;$("<",Ie);$(">",Ie);$("<=",Ie);$(">=",Ie);l(">",(e,t)=>(e=d(e),t=d(t),r=>e(r)>t(r)));l("<",(e,t)=>(e=d(e),t=d(t),r=>e(r)<t(r)));l(">=",(e,t)=>(e=d(e),t=d(t),r=>e(r)>=t(r)));l("<=",(e,t)=>(e=d(e),t=d(t),r=>e(r)<=t(r)));const wt=80;$("==",wt);$("!=",wt);l("==",(e,t)=>(e=d(e),t=d(t),r=>e(r)==t(r)));l("!=",(e,t)=>(e=d(e),t=d(t),r=>e(r)!=t(r)));const Pt=110,Qe=120,Dt=140;$("+",Pt);$("-",Pt);$("*",Qe);$("/",Qe);$("%",Qe);H("+",Dt);H("-",Dt);l("+",(e,t)=>t!==void 0?(e=d(e),t=d(t),r=>e(r)+t(r)):(e=d(e),r=>+e(r)));l("-",(e,t)=>t!==void 0?(e=d(e),t=d(t),r=>e(r)-t(r)):(e=d(e),r=>-e(r)));l("*",(e,t)=>(e=d(e),t=d(t),r=>e(r)*t(r)));l("/",(e,t)=>(e=d(e),t=d(t),r=>e(r)/t(r)));l("%",(e,t)=>(e=d(e),t=d(t),r=>e(r)%t(r)));const pe=150;W("++",pe,e=>e?["++",e,null]:["++",E(pe-1)]);W("--",pe,e=>e?["--",e,null]:["--",E(pe-1)]);const qe=(e,t,r,n)=>typeof e=="string"?o=>t(o,e):e[0]==="."?(r=d(e[1]),n=e[2],o=>t(r(o),n)):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),o=>t(r(o),n(o))):e[0]==="()"&&e.length===2?qe(e[1],t):(()=>{throw Error("Invalid increment target")})();l("++",(e,t)=>qe(e,t===null?(r,n)=>r[n]++:(r,n)=>++r[n]));l("--",(e,t)=>qe(e,t===null?(r,n)=>r[n]--:(r,n)=>--r[n]));const Xr=5,zr=10;At(",",zr);At(";",Xr,!0);const Ft=(...e)=>(e=e.map(d),t=>{let r;for(const n of e)r=n(t);return r});l(",",Ft);l(";",Ft);const Jr=170;ze("()",Jr);const V=e=>e?.[0]==="_"&&e[1]==="_"||e==="constructor"||e==="prototype",Ye=170;St("[]",Ye);$(".",Ye);St("()",Ye);const ge=e=>{throw Error(e)};l("[]",(e,t)=>t===void 0?(e=e?e[0]===","?e.slice(1):[e]:[],e=e.map(r=>r==null?(()=>{}):r[0]==="..."?(r=d(r[1]),n=>r(n)):(r=d(r),n=>[r(n)])),r=>e.flatMap(n=>n(r))):(t==null&&ge("Missing index"),e=d(e),t=d(t),r=>{const n=t(r);return V(n)?void 0:e(r)[n]}));l(".",(e,t)=>(e=d(e),t=t[0]?t:t[1],V(t)?()=>{}:r=>e(r)[t]));l("()",(e,t)=>{if(t===void 0)return e==null?ge("Empty ()"):d(e);const r=o=>o?.[0]===","&&o.slice(1).some(i=>i==null||r(i));r(t)&&ge("Empty argument");const n=t?t[0]===","?(t=t.slice(1).map(d),o=>t.map(i=>i(o))):(t=d(t),o=>[t(o)]):()=>[];return Ze(e,(o,i,s)=>o[i](...n(s)))});const J=e=>typeof e=="string"||Array.isArray(e)&&(e[0]==="."||e[0]==="?."||e[0]==="[]"&&e.length===3||e[0]==="?.[]"||e[0]==="()"&&e.length===2&&J(e[1])||e[0]==="{}"),Ze=(e,t,r,n)=>e==null?ge("Empty ()"):e[0]==="()"&&e.length==2?Ze(e[1],t):typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=d(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="?."?(r=d(e[1]),n=e[2],o=>{const i=r(o);return i==null?void 0:t(i,n,o)}):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),o=>t(r(o),n(o),o)):e[0]==="?.[]"?(r=d(e[1]),n=d(e[2]),o=>{const i=r(o);return i==null?void 0:t(i,n(o),o)}):(e=d(e),o=>t([e(o)],0,o)),Z=Ze,Qr=32,qr=y.space;y.comment??={"//":`
6
- `,"/*":"*/"};let Oe;y.space=()=>{Oe||(Oe=Object.entries(y.comment).map(([o,i])=>[o,i,o.charCodeAt(0)]));for(var e;e=qr();){for(var t=0,r;r=Oe[t++];)if(e===r[2]&&g.substr(h,r[0].length)===r[0]){var n=h+r[0].length;if(r[1]===`
7
- `)for(;g.charCodeAt(n)>=Qr;)n++;else{for(;g[n]&&g.substr(n,r[1].length)!==r[1];)n++;g[n]&&(n+=r[1].length)}Ne(n),e=0;break}if(e)return e}return e};const Tt=80;$("===",Tt);$("!==",Tt);l("===",(e,t)=>(e=d(e),t=d(t),r=>e(r)===t(r)));l("!==",(e,t)=>(e=d(e),t=d(t),r=>e(r)!==t(r)));const Yr=30;$("??",Yr);l("??",(e,t)=>(e=d(e),t=d(t),r=>e(r)??t(r)));const Zr=130,xr=20;$("**",Zr,!0);$("**=",xr,!0);l("**",(e,t)=>(e=d(e),t=d(t),r=>e(r)**t(r)));const br=e=>{throw Error(e)};l("**=",(e,t)=>(J(e)||br("Invalid assignment target"),t=d(t),Z(e,(r,n,o)=>r[n]**=t(o))));const Wt=90;$("in",Wt);$("of",Wt);l("in",(e,t)=>(e=d(e),t=d(t),r=>e(r)in t(r)));const en=20,tn=100,rn=e=>{throw Error(e)};$(">>>",tn);$(">>>=",en,!0);l(">>>",(e,t)=>(e=d(e),t=d(t),r=>e(r)>>>t(r)));l(">>>=",(e,t)=>(J(e)||rn("Invalid assignment target"),t=d(t),Z(e,(r,n,o)=>r[n]>>>=t(o))));const xe=5,nn=10,on=20,sn=e=>e[0]?.[0]===","?e[0].slice(1):e,me=(e,t,r)=>{if(typeof e=="string"){r[e]=t;return}const[n,...o]=e,i=sn(o);if(n==="{}"){const s=[];for(const u of i){if(Array.isArray(u)&&u[0]==="..."){const f={};for(const w in t)s.includes(w)||(f[w]=t[w]);r[u[1]]=f;break}let c,p,A;typeof u=="string"?c=p=u:u[0]==="="?(typeof u[1]=="string"?c=p=u[1]:[,c,p]=u[1],A=u[2]):[,c,p]=u,s.push(c);let m=t[c];m===void 0&&A&&(m=d(A)(r)),me(p,m,r)}}else if(n==="[]"){let s=0;for(const u of i){if(u===null){s++;continue}if(Array.isArray(u)&&u[0]==="..."){r[u[1]]=t.slice(s);break}let c=u,p;Array.isArray(u)&&u[0]==="="&&([,c,p]=u);let A=t[s++];A===void 0&&p&&(A=d(p)(r)),me(c,A,r)}}},Rt=e=>{let t=E(nn-1);return t?.[0]==="in"||t?.[0]==="of"?[t[0],[e,t[1]],t[2]]:t?.[0]===","?[e,...t.slice(1)]:[e,t]};de("let",xe+1,()=>Rt("let"));de("const",xe+1,()=>Rt("const"));de("var",xe,()=>(B(),["var",E(on)]));const kt=(...e)=>(e=e.map(t=>{if(typeof t=="string")return r=>{r[t]=void 0};if(t[0]==="="){const[,r,n]=t,o=d(n);return typeof r=="string"?i=>{i[r]=o(i)}:i=>me(r,o(i),i)}return d(t)}),t=>{for(const r of e)r(t)});l("let",kt);l("const",kt);l("var",e=>typeof e=="string"?t=>{t[e]=void 0}:()=>{});const be=20,Ce=e=>{throw Error(e)};$("||=",be,!0);$("&&=",be,!0);$("??=",be,!0);l("=",(e,t)=>{if(Array.isArray(e)&&(e[0]==="let"||e[0]==="const"||e[0]==="var")){const r=e[1];return t=d(t),typeof r=="string"?n=>{n[r]=t(n)}:n=>me(r,t(n),n)}return J(e)||Ce("Invalid assignment target"),t=d(t),Z(e,(r,n,o)=>r[n]=t(o))});l("||=",(e,t)=>(J(e)||Ce("Invalid assignment target"),t=d(t),Z(e,(r,n,o)=>r[n]||=t(o))));l("&&=",(e,t)=>(J(e)||Ce("Invalid assignment target"),t=d(t),Z(e,(r,n,o)=>r[n]&&=t(o))));l("??=",(e,t)=>(J(e)||Ce("Invalid assignment target"),t=d(t),Z(e,(r,n,o)=>r[n]??=t(o))));se("true",!0);se("false",!1);se("null",null);de("undefined",200,()=>[]);se("NaN",NaN);se("Infinity",1/0);const we=20;W("?",we,(e,t,r)=>e&&(t=E(we-1))&&Y(n=>n===58)&&(r=E(we-1),["?",e,t,r]));l("?",(e,t,r)=>(e=d(e),t=d(t),r=d(r),n=>e(n)?t(n):r(n)));const dn=[],un=20;$("=>",un,!0);l("=>",(e,t)=>{e=e?.[0]==="()"?e[1]:e;const r=e?e[0]===","?e.slice(1):[e]:[];let n=-1,o=null;const i=r[r.length-1];Array.isArray(i)&&i[0]==="..."&&(n=r.length-1,o=i[1],r.length--);const s=t?.[0]==="{}";return t=d(s?["{",t[1]]:t),u=>(...c)=>{const p={};r.forEach((m,f)=>p[m]=c[f]),o&&(p[o]=c.slice(n));const A=new Proxy(p,{get:(m,f)=>f in m?m[f]:u?.[f],set:(m,f,w)=>((f in m?m:u)[f]=w,!0),has:(m,f)=>f in m||(u?f in u:!1)});try{const m=t(A);return s?void 0:m}catch(m){if(m===dn)return m[0];throw m}}});const cn=140;H("...",cn);l("...",e=>(e=d(e),t=>Object.entries(e(t))));const ct=170;W("?.",ct,(e,t)=>{if(!e)return;const r=B();return r===40?(O(),["?.()",e,E(0,41)||null]):r===91?(O(),["?.[]",e,E(0,93)]):(t=E(ct),t?["?.",e,t]:void 0)});l("?.",(e,t)=>(e=d(e),V(t)?()=>{}:r=>e(r)?.[t]));l("?.[]",(e,t)=>(e=d(e),t=d(t),r=>{const n=t(r);return V(n)?void 0:e(r)?.[n]}));l("?.()",(e,t)=>{const r=t?t[0]===","?(t=t.slice(1).map(d),o=>t.map(i=>i(o))):(t=d(t),o=>[t(o)]):()=>[];if(e[0]==="?."){const o=d(e[1]),i=e[2];return V(i)?()=>{}:s=>o(s)?.[i]?.(...r(s))}if(e[0]==="?.[]"){const o=d(e[1]),i=d(e[2]);return s=>{const u=o(s),c=i(s);return V(c)?void 0:u?.[c]?.(...r(s))}}if(e[0]==="."){const o=d(e[1]),i=e[2];return V(i)?()=>{}:s=>o(s)?.[i]?.(...r(s))}if(e[0]==="[]"&&e.length===3){const o=d(e[1]),i=d(e[2]);return s=>{const u=o(s),c=i(s);return V(c)?void 0:u?.[c]?.(...r(s))}}const n=d(e);return o=>n(o)?.(...r(o))});const re=140;H("typeof",re);H("void",re);H("delete",re);de("new",re,()=>Or(".target")?(O(7),["new.target"]):["new",E(re)]);l("typeof",e=>(e=d(e),t=>typeof e(t)));l("void",e=>(e=d(e),t=>(e(t),void 0)));l("delete",e=>{if(e[0]==="."){const t=d(e[1]),r=e[2];return n=>delete t(n)[r]}if(e[0]==="[]"){const t=d(e[1]),r=d(e[2]);return n=>delete t(n)[r(n)]}return()=>!0});l("new",e=>{const t=d(e?.[0]==="()"?e[1]:e),r=e?.[0]==="()"?e[2]:null,n=r?r[0]===","?(o=>i=>o.map(s=>s(i)))(r.slice(1).map(d)):(o=>i=>[o(i)])(d(r)):()=>[];return o=>new(t(o))(...n(o))});const et=Symbol("accessor"),tt=20,ln=40,_t=41,Nt=123,Ut=125,Lt=e=>t=>{if(t)return;B();const r=Y(y.id);if(!r||(B(),g.charCodeAt(h)!==ln))return!1;O();const n=E(0,_t);return B(),g.charCodeAt(h)!==Nt?!1:(O(),[e,r,n,E(0,Ut)])};W("get",tt-1,Lt("get"));W("set",tt-1,Lt("set"));W("(",tt-1,e=>{if(!e||typeof e!="string")return;const t=E(0,_t)||null;if(B(),g.charCodeAt(h)===Nt)return O(),[":",e,["=>",["()",t],E(0,Ut)||null]]});l("get",(e,t)=>(t=t?d(t):()=>{},r=>[[et,e,{get:function(){const n=Object.create(r||{});return n.this=this,t(n)}}]]));l("set",(e,t,r)=>(r=r?d(r):()=>{},n=>[[et,e,{set:function(o){const i=Object.create(n||{});i.this=this,i[t]=o,r(i)}}]]));const an=20,jt=200;y.prop=e=>Cr(e)!==58;const fn=e=>e==null||typeof e=="string"||[":",",","...","get","set"].includes(e[0]);ze("[]",jt);ze("{}",jt);$(":",an-1,!0);l("{}",(e,t)=>{if(t!==void 0)return;if(!fn(e))return d(["{",e]);e=e?e[0]!==","?[e]:e.slice(1):[];const r=e.map(n=>d(typeof n=="string"?[":",n,n]:n));return n=>{const o={},i={};for(const s of r.flatMap(u=>u(n)))if(s[0]===et){const[,u,c]=s;i[u]={...i[u],...c,configurable:!0,enumerable:!0}}else o[s[0]]=s[1];for(const s in i)Object.defineProperty(o,s,i[s]);return o}});l("{",e=>(e=e?d(e):()=>{},t=>e(Object.create(t))));l(":",(e,t)=>(t=d(t),Array.isArray(e)?(e=d(e),r=>[[e(r),t(r)]]):r=>[[e,t(r)]]));const hn=170,ye=96,pn=36,gn=123,mn=92,yn={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},lt=()=>{const e=[];for(let t="",r;(r=g.charCodeAt(h))!==ye;)r?r===mn?(O(),t+=yn[g[h]]||g[h],O()):r===pn&&g.charCodeAt(h+1)===gn?(t&&e.push([,t]),t="",O(2),e.push(E(0,125))):(t+=g[h],O(),r=g.charCodeAt(h),r===ye&&t&&e.push([,t])):z("Unterminated template");return O(),e},$n=R[ye];R[ye]=(e,t)=>e&&t<hn?y.asi&&y.newline?void 0:(O(),["``",e,...lt()]):e?$n?.(e,t):(O(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(lt()));l("`",(...e)=>(e=e.map(d),t=>e.map(r=>r(t)).join("")));l("``",(e,...t)=>{e=d(e);const r=[],n=[];for(const i of t)Array.isArray(i)&&i[0]===void 0?r.push(i[1]):n.push(d(i));const o=Object.assign([...r],{raw:r});return i=>e(i)(o,...n.map(s=>s(i)))});y.string["'"]=!0;y.number={"0x":16,"0b":2,"0o":8};const An={log:(e,t)=>(t?console.log(t,e):console.log(e),e)};function U(e,t,r,n,o){const i=y(Sn(e));return d(i)({$form:t,$meta:r,$errors:n,$formIsInvalid:o,$log:An.log})===!0}function Sn(e){return e.replace(/\?\.(\d+)/g,"?.[$1]").replace(/\.(\d+)/g,"[$1]")}const L=e=>{let t=e.formDef.states;if(!t||Object.keys(t).length===0||e.formHealth.status==="errored")return e;const{$formIsInvalid:r,$errors:n}=Ke(e);t=En(t);let o=[],i={status:"ok"};try{o=Object.keys(t).map(s=>{const u=t[s];let c;try{c=U(u,e.data,e.meta,n,r)}catch{c=!1}return c===!0?s:void 0}).filter(s=>s!==void 0)}catch(s){const u=s,c=b.calculateCurrentStateError;i={status:"errored",message:`[${c}] ${u.message}`,code:c}}return{...e,currentStates:o,formHealth:i}};function En(e){const t={};function r(n){const o=n.split(":"),i=[];for(let s=0;s<o.length;s++)i.push(o.slice(0,s+1).join(":"));return i}for(const[n,o]of Object.entries(e)){const i=r(n),s=[];for(const u of i)e[u]&&s.push(`(${e[u]})`);t[n]=s.join(" && ")}return t}const rt=Symbol("filterMap.skip");function Mt(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n,e);o!==rt&&r.push(o)}return r}function vn(e,t,r){for(let n=0;n<e.length;n++)t(e[n],n,e)&&r(e[n],n,e)}function In(e,t,r,n){let o=n;for(let i=0;i<e.length;i++)t(e[i],i,e)&&(o=r(o,e[i],i,e));return o}function Cn(e,t,r){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n],n,e,t))return!1;return!0}function Vt(e,t){const r=Bt(e.uid,t);return D(e)?{...e,uid:r,path:On(e.path,t)}:{...e,uid:r}}function Bt(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r=t.reduce((n,o)=>`${n}[${o}]`,"");return`${e}${r}`}function On(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r="items",n=e.split(`.${r}`),o=n.length-1;if(o!==t.length)throw new Error(`Path contains ${o} '${r}' occurrences, but ${t.length} indexes were provided.`);return n.reduce((i,s,u)=>u===0?s:`${i}.${t[u-1]}${s}`)}function ce(e,t){let r=0;return e.replace(/\.items(\??)\./g,(n,o)=>{const i=t[r++];return i===void 0?n:`.${i}${o}.`})}const le=(e,t)=>r=>e(r)?t(r):r,K=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e,j=e=>{const{$formIsInvalid:t,$errors:r}=Ke(e);return{...e,widgetFlags:{...wn(e,r,t),...Pn(e,r,t)}}};function wn(e,t,r){return Mt(Object.values(e.flatForm),n=>{if(n.uid?.includes("["))return rt;if(ie(n)){const o=n({$form:e.data,errors:void 0,touched:void 0,translate:void 0});return o.uid=n.uid,o}return n}).filter(n=>!!(n.include&&("in"in n.include||"when"in n.include)||n.exclude&&("from"in n.exclude||"when"in n.exclude)||(D(n)||ee(n))&&K(n.disabled)||D(n)&&K(n.readonly))).reduce((n,o)=>(n[o.uid]=n[o.uid]||{},o.include&&"in"in o.include?n[o.uid].hidden=!o.include.in.some(i=>e.currentStates.includes(i)):o.include&&"when"in o.include&&(n[o.uid].hidden=!U(o.include.when,e.data,e.meta,t,r)),o.exclude&&"from"in o.exclude?n[o.uid].hidden=o.exclude.from.some(i=>e.currentStates.includes(i)):o.exclude&&"when"in o.exclude&&(n[o.uid].hidden=U(o.exclude.when,e.data,e.meta,t,r)),(D(o)||ee(o))&&K(o.disabled)&&(n[o.uid].disabled=U(o.disabled.when,e.data,e.meta,t,r)),D(o)&&K(o.readonly)&&(n[o.uid].readonly=U(o.readonly.when,e.data,e.meta,t,r)),n),{})}function Pn(e,t,r){return In(Object.values(e.flatForm),n=>!ie(n)&&n.type==="repeater",(n,o)=>({...n,...Ht(e,o,[],t,r)}),{})}function Ht(e,t,r,n,o){const i=t.props.template,s=k(e.data,t.path);if(!Array.isArray(s))return{};const u={};return s.forEach((c,p)=>{const A=[...r,p];Ge([i]).forEach(m=>{let f;if(ie(m)?(f=m({$form:e.data,errors:void 0,touched:void 0,translate:void 0}),f.uid=m.uid):f=m,f.type==="repeater"){const x=Vt(f,A);Object.assign(u,Ht(e,x,A,n,o));return}const w=Bt(f.uid,A);u[w]=u[w]||{},f.include&&"in"in f.include?u[w].hidden=!f.include.in.some(x=>e.currentStates.includes(x)):f.include&&"when"in f.include&&(u[w].hidden=!U(ce(f.include.when,A),e.data,e.meta,n,o)),f.exclude&&"from"in f.exclude?u[w].hidden=f.exclude.from.some(x=>e.currentStates.includes(x)):f.exclude&&"when"in f.exclude&&(u[w].hidden=U(ce(f.exclude.when,A),e.data,e.meta,n,o)),(D(f)||ee(f))&&K(f.disabled)&&(u[w].disabled=U(ce(f.disabled.when,A),e.data,e.meta,n,o)),D(f)&&K(f.readonly)&&(u[w].readonly=U(ce(f.readonly.when,A),e.data,e.meta,n,o))})}),u}const N=e=>t=>({...t,calculatedWidgets:Dn(t,e)});function Dn(e,t){const{$formIsInvalid:r,$errors:n}=Ke(e),o=Xn(e,t,r,n),i={};for(const s of Object.keys(e.calculatedWidgets)){if(e.widgetFlags[s]?.hidden)continue;const u=e.calculatedWidgets[s],c=u.source;if(ie(c)){i[s]=Fn(s,c,e,t);continue}i[s]=Tn(u,c,e,o)}return i}function Fn(e,t,r,n){const o=t({$form:r.data,errors:t.path?r.validations[t.path]:void 0,touched:t.path?r.touchedControls[t.path]:void 0,translate:n.translate});return o.uid=e,{source:t,current:o}}function Tn(e,t,r,n){const o=new Kn(t,e.current);return o.write("uid",t.uid),o.write("type",t.type),o.write("kind",t.kind),nr(t)?Wn(o,n):ee(t)?Rn(o,n):D(t)?kn(o,n):Te(t)&&_n(o,n),Nn(t,o,n,r),(ee(t)||D(t))&&Un(t,o,n),Te(t)&&Ln(t,o,r),o.changed?{source:e.source,current:o.current}:e}function Wn(e,t){v(e,t,"size"),v(e,t,"include"),v(e,t,"exclude")}function Rn(e,t){v(e,t,"size"),v(e,t,"include"),v(e,t,"exclude"),v(e,t,"label"),v(e,t,"disabled")}function kn(e,t){v(e,t,"size"),v(e,t,"include"),v(e,t,"exclude"),v(e,t,"label"),v(e,t,"disabled"),v(e,t,"readonly"),v(e,t,"validator"),v(e,t,"path"),v(e,t,"defaultValue")}function _n(e,t){v(e,t,"size"),v(e,t,"include"),v(e,t,"exclude")}function Nn(e,t,r,n){const o=n.widgetPropOverrides[e.uid]??{},i={...e.props??{},...o};for(const s of Xt(Object.keys(i)))jn(t,r,s)}function Un(e,t,r){const n=e.on??{};for(const o of Xt(Object.keys(n)))Mn(t,r,o)}function Ln(e,t,r){const n=Qn(e.uid),o=Jn(e.children,n,r.widgetFlags);t.current.children=o;const i=t.previous.children??[];i.length===o.length&&o.every((u,c)=>i[c]&&i[c].uid===o[c].uid)||t.markChanged()}function v(e,t,r){const n=e.source;if(!zn(n,r))return;const o=ot(n,r,t.sortedStates);let i;switch(r){case"disabled":case"readonly":i=Bn(o,t,e.source.uid,r);break;default:i=Kt(o,t)}e.write(r,i)}function jn(e,t,r){const n=e.source.props,o=ot(n,r,t.sortedStates);let i=Kt(o,t);const s=t.widgetPropOverrides[e.source.uid]?.[r];s!==void 0&&(i=s),e.write(`props.${r}`,i)}function Mn(e,t,r){const n=e.source.on,o=ot(n,r,t.sortedStates);e.write(`on.${r}`,Hn(o,t))}function nt(e,t){return e({$form:t.$form,translate:t.localization.translate})}function Vn(e,t){return t.localization.translate(e.key,Gn(e.params,t),e.default)}function Gt(e,t){return vr(e,{resolveFormPath:r=>k(t.$form,r)??e,resolveMetaPath:r=>k(t.$meta,r)??e,resolveErrorsPath:r=>k(t.$errors,r)??e,resolveFormIsInvalid:()=>String(t.$formIsInvalid)})}function Kt(e,t){return typeof e=="function"?nt(e,t):pr(e)?Vn(e,t):typeof e=="string"?Gt(e,t):e}function Bn(e,t,r,n){return typeof e=="function"?nt(e,t):K(e)?t.widgetFlags[r]?.[n]:typeof e=="string"?Gt(e,t):e}function Hn(e,t){return typeof e=="function"?nt(e,t):e}function ot(e,t,r){if(e){for(const n of r){const o=e[`${t}.${n}`];if(o!==void 0)return o}return e[t]}}function Gn(e,t){return e&&Object.keys(e).reduce((r,n)=>{const o=String(e[n]);return Ar(o)?r[n]=Ir(o,{resolveFormPath:i=>k(t.$form,i)??o,resolveMetaPath:i=>k(t.$meta,i)??o,resolveErrorsPath:i=>k(t.$errors,i)??o,resolveFormIsInvalid:()=>t.$formIsInvalid}):r[n]=o,r},{})}class Kn{constructor(t,r){this._changed=!1,this.source=t,this.previous=r,this.current={}}get changed(){return this._changed}markChanged(){this._changed=!0}write(t,r){He(this.current,t,r),k(this.previous,t)!==r&&(this._changed=!0)}}function Xn(e,t,r,n){return{sortedStates:[...e.currentStates].sort((o,i)=>i.length-o.length),widgetPropOverrides:e.widgetPropOverrides,widgetFlags:e.widgetFlags,$form:e.data,$meta:e.meta,$formIsInvalid:r,$errors:n,localization:t}}function zn(e,t){if(t in e)return!0;const r=`${t}.`;return Object.keys(e).some(n=>n.startsWith(r))}function Xt(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function Jn(e,t,r){const n=t.map(o=>`[${o}]`).join("");return e.filter(o=>{const i=o.uid+n,s=r[i];return!s||s.hidden!==!0})}const Qn=e=>[...e.matchAll(/\[(\d+)\]/g)].map(t=>parseInt(t[1],10)),qn=({lang:e},t)=>{const r={...mt(e),formName:t.payload.formName};let n=t.payload.formDef,o={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(u){const c=u,p=b.initializeParseError;o={status:"errored",message:`[${p}] ${c.message}`,code:p}}if(o.status==="errored")return{...r,formHealth:o}}if(Array.isArray(n.form)){const u=n,c=u.form;u.form={uid:"",type:"flex",kind:"layout",children:c}}const i=gt.decode(n);if(i.isOk()){o={status:"ok"};let u={};try{u=Ge([i.value.form]).reduce((c,p)=>{const A=p.uid;if(c[A])throw{existingWidget:c[A],newWidget:p};return c[A]=p,c},{})}catch(c){const p=b.initializeUidCollisionError;o={status:"errored",message:`[${p}] ${Yn(c.existingWidget,c.newWidget)}`,code:p},u={}}return{...r,formDef:i.value,flatForm:u,formHealth:o}}const s=b.initializeUnknownError;return{...r,formHealth:{status:"errored",message:`[${s}] ${i.error}`,code:s}}};function Yn(e,t){const r=n=>D(n)?` at "${n.path}"`:"";return`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`}function Zn(e,t){return{...e,injectedValidations:{...e.injectedValidations,[t.payload.path]:t.payload.issues}}}const xn=(e,{payload:t})=>{let r;if("path"in t){if(r=Object.values(e.calculatedWidgets).find(({source:i})=>D(i)&&i.path===t.path),!r)return console.warn(`Input with path "${t.path}" not found`),e}else if(r=e.calculatedWidgets[t.uid],!r)return console.warn(`Widget with uid "${t.uid}" not found`),e;const n=r.source.uid,o=e.widgetPropOverrides[n]||{};return{...e,widgetPropOverrides:{...e.widgetPropOverrides,[n]:{...o,[t.prop]:t.value}}}};function bn(e,t){return{...e,widgetFlags:{...ue(e.widgetFlags,t.payload.uid)},calculatedWidgets:{...ue(e.calculatedWidgets,t.payload.uid)},widgetPropOverrides:{...ue(e.widgetPropOverrides,t.payload.uid)},touchedControls:{..._(e.touchedControls,r=>{const n=e.flatForm[t.payload.uid];return n&&D(n)?ue(r,n.path):r})}}}const eo=(e,t)=>({...e,data:{...t.payload.data}}),to=(e,t)=>({...e,formHealth:t.payload.formHealth}),ro=(e,t)=>({...e,lang:t.payload.lang}),no=(e,t)=>({...e,meta:{...t.payload.meta}}),oo=(e,t)=>{const r=k(e.data,t.payload.path);return t.type==="SET_WIDGET_DATA"||t.type==="SET_WIDGET_INITIAL_DATA"&&r===void 0?{...e,data:{...He(e.data,t.payload.path,t.payload.data)}}:e},Pe=(e,t)=>r=>{const n=Mt(Object.values(r.calculatedWidgets),({current:i})=>D(i)?i:rt),o=r.validations;return{...r,validations:n.reduce((i,s)=>{if(i[s.path]=null,s.validator){const u=e(s.validator,t),c=k(r.data,s.path),p=at(u,c);i[s.path]=ft(p)?null:p.issues.map(A=>A.message)}return Array.isArray(i[s.path])&&Array.isArray(o[s.path])&&Cn(i[s.path],o[s.path],(u,c)=>u===c)&&(i[s.path]=o[s.path]),i},{})}},io=({validators:e,validateOn:t,localization:r})=>(n,o)=>{switch(o.type){case"INITIALIZE":return qn(n,o);case"SET_DATA":return _(eo(n,o),L,j,N(r));case"SET_META":return _(no(n,o),L,j,N(r));case"SET_LANGUAGE":return _(ro(n,o),N(r));case"ADD_WIDGET":return _(yr(n,o),le(De,L),le(De,j),le(De,N(r)));case"REMOVE_WIDGET":return _(bn(n,o),L,j,N(r));case"SET_WIDGET_INITIAL_DATA":case"SET_WIDGET_DATA":return _(oo(n,o),L,j,N(r));case"OVERRIDE_WIDGET_PROP":return _(xn(n,o),L,j,N(r),le(i=>{let s=!1,u="";"path"in o.payload?(s=!0,u=o.payload.path):D(i.calculatedWidgets[o.payload.uid].current)&&(s=!0,u=i.calculatedWidgets[o.payload.uid].current.path);const c=s&&i.touchedControls[u];return i.touched&&c},Pe(e,r)));case"SET_FORM_HEALTH":return to(n,o);case"VALIDATE_ALL":return _({...n,touched:!0,touchedControls:Object.keys(n.calculatedWidgets).reduce((i,s)=>{const u=n.calculatedWidgets[s].source;return D(u)&&(i[u.path]=!0),i},{})},Pe(e,r),L,j,N(r));case"ATTEMPT_VALIDATION":{const i=o.payload.reason,s=o.payload.path;return t==="eager"||i===t||t.includes(i)?_({...n,touched:!0,touchedControls:{...n.touchedControls,[s]:!0}},Pe(e,r),L,j,N(r),c=>{const p=o.payload.uid,A=c.calculatedWidgets[p],m=A.source;if(ie(m)){const f=m({$form:c.data,errors:c.validations[s],touched:!0,translate:r.translate});return{...c,calculatedWidgets:{...c.calculatedWidgets,[p]:{source:A.source,current:f}}}}return c}):n}case"INJECT_VALIDATION_ISSUES":return Zn(n,o);default:return mr(o)}},De=e=>e.formHealth.status==="ok";function so(e=[],t,r,n){const o=new a.BehaviorSubject(mt(n.lang)),i=o.asObservable().pipe(a.distinctUntilChanged()),s=io({validators:t,validateOn:r,localization:n});function u(m){const f=o.getValue(),w=s(f,m);o.next(w)}let c=u;const p={getState:()=>o.getValue(),dispatch:m=>c(m)};return c=e.map(m=>m(p)).reduceRight((m,f)=>f(m),u),{state$:i,dispatch:c,getState:()=>o.getValue()}}class uo{constructor(){this.widgetRegistry=new Re,this.store={},this.events$=new a.Subject,this.uuid=crypto.randomUUID(),this.itemRenderers={},this.dependencies={}}initialize(t,r=[],n,o,i,s=yt(),u){this.localization=s,this.dependencies=u,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=i,this.store=so(r,n,o,s)}emitEvent(t,r,n){const i=this.store.getState().currentStates.filter(s=>r.on?.[`${t}.${s}`]!==void 0);if(i.length>0)i.forEach(s=>{const u=r.on?.[`${t}.${s}`];this.attemptValidation(t,u,r),u&&this.events$.next({name:u,data:this.store.getState().data,detail:n??void 0,callback:c=>{this.store.dispatch(c)}})});else{const s=r.on?.[t];this.attemptValidation(t,s,r),s&&this.events$.next({name:s,data:this.store.getState().data,detail:n,callback:u=>{this.store.dispatch(u)}})}}attemptValidation(t,r,n){n.kind!=="layout"&&(t==="change"?this.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"change",path:n.path,uid:n.uid}}):t==="click"&&r==="submit"&&this.store.dispatch({type:"VALIDATE_ALL"}))}}function co(e="GolemUI Form Store"){return t=>{const n=(typeof window<"u"?window.__REDUX_DEVTOOLS_EXTENSION__:void 0)?.connect({name:e});return n?.init(t.getState()),o=>i=>{o(i),n&&n.send(i,t.getState())}}}const lo=a.pipe(a.map(e=>e.data),a.distinctUntilChanged()),ao=e=>a.pipe(lo,a.map(t=>k(t,e)),a.distinctUntilChanged()),fo=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.validations),a.distinctUntilChanged()),ho=e=>a.pipe(fo,a.map(t=>t[e]),a.distinctUntilChanged()),po=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.injectedValidations),a.distinctUntilChanged()),go=e=>a.pipe(po,a.map(t=>t[e]),a.distinctUntilChanged(),a.startWith(null)),mo=a.pipe(a.map(e=>e.lang),a.distinctUntilChanged()),zt=a.pipe(a.map(e=>e.calculatedWidgets),a.distinctUntilChanged()),yo=e=>t=>a.combineLatest([t.pipe(mo),t.pipe(zt)]).pipe(a.map(([r,n])=>({lang:r,widget:n[e]})),a.filter(r=>r.widget!==void 0),a.distinctUntilChanged((r,n)=>r.lang===n.lang&&r.widget===n.widget),a.map(r=>r.widget.current)),$o=e=>a.pipe(zt,a.map(t=>t[e]),a.filter(t=>t!==void 0),a.map(t=>t.current.children),a.distinctUntilChanged());a.pipe(a.map(e=>e.widgetFlags),a.distinctUntilChanged());const Ao=a.pipe(a.map(e=>e.touchedControls),a.distinctUntilChanged()),So=e=>a.pipe(Ao,a.map(t=>t[e]),a.distinctUntilChanged()),Eo=a.pipe(a.map(e=>e.formHealth),a.distinctUntilChanged((e,t)=>!(e.status!==t.status||e.status==="errored"))),vo=e=>e.pipe(Eo);let Jt=!1;function Io(){Jt=!0}function Co(){return Jt}function Oo(e,t,r){if(!Co())return;const n=Object.keys(t??{}).filter(o=>o in r);if(n.length>0)throw new Error(`[GolemUI] Widget "${e}": prop keys [${n.join(", ")}] collide with widget fields`)}exports.FormContext=uo;exports.assertNoPropCollisions=Oo;exports.calculatedLayoutChildrenByUid$=$o;exports.calculatedWidgetsByUid$=yo;exports.cloneObject=ke;exports.dataByPath$=ao;exports.defineForm=hr;exports.devToolsMiddleware=co;exports.enableDevMode=Io;exports.errorCodes=b;exports.filterTap=vn;exports.formHealth=vo;exports.getDirectionFromLanguage=gr;exports.identityTranslator=yt;exports.injectedValidationByPath$=go;exports.isStandardValidateSuccess=ft;exports.makeRepeaterItemConfig=Vt;exports.shortUUID=je;exports.standardValidate=at;exports.touchedControlsByPath$=So;exports.validationByPath$=ho;
4
+ `,""+i}${s}${u}`)},$t=(e,t=h)=>(Array.isArray(e)&&(e.loc=t),e),Z=(e,t=h,r)=>{for(;r=e(g.charCodeAt(h));)h+=r;return g.slice(t,h)},O=(e=1)=>g[h+=e],je=e=>h=e,v=(e=0,t)=>{let r,n,i,o,s;for(t&&A.asi&&(A.newline=!1);(r=A.space())&&(s=A.newline,1)&&r!==t&&(i=(n&&r===91&&_e&&A.asi?.(n,e,v)||null)??((o=R[r])&&o(n,e))??(n&&s&&A.asi?.(n,e,v))??(!n&&Z(A.id)));)n=i;return t&&(r==t?(h++,t===125&&A.asi&&(A.newline=!0)):J("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),n},B=(e,t=h)=>{for(_e=!1;(e=g.charCodeAt(h))<=Xe;)A.asi&&e===10&&(A.newline=_e=!0),h++;return e},Or=(e=h)=>{for(;g.charCodeAt(e)<=Xe;)e++;return g.charCodeAt(e)};A.id=e=>e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e==36||e==95||e>=192&&e!=215&&e!=247;let wr=(e,t=e.length)=>g.substr(h,t)===e&&!A.id(g.charCodeAt(h+t)),R=[],ot={},W=(e,t=Xe,r,n=e.charCodeAt(0),i=e.length,o=R[n],s=e.toUpperCase()!==e,u,c)=>(t=ot[e]=!o&&ot[e]||t,R[n]=(p,S,m,f=h)=>(u=m,(m?e==m:(i<2||e.charCodeAt(1)===g.charCodeAt(h+1)&&(i<3||g.substr(h,i)==e))&&(!s||!A.id(g.charCodeAt(h+i)))&&(u=m=e))&&S<t&&(h+=i,(c=r(p))?$t(c,f):(h=f,u=0,!s&&!o&&!p&&J()),c)||o?.(p,S,u))),$=(e,t,r=!1)=>W(e,t,n=>n&&(i=>i&&[e,n,i])(v(t-(r?.5:0)))),H=(e,t,r)=>W(e,t,n=>!n&&(n=v(t-.5))&&[e,n]),de=(e,t)=>W(e,200,r=>!r&&[,t]),St=(e,t,r)=>W(e,t,(n,i)=>(i=v(t-(r?.5:0)),n?.[0]!==e&&(n=[e,n||null]),i?.[0]===e?n.push(...i.slice(1)):n.push(i||null),n)),ze=(e,t)=>W(e[0],t,r=>!r&&[e,v(0,e.charCodeAt(1))||null]),vt=(e,t)=>W(e[0],t,r=>r&&[e,r,v(0,e.charCodeAt(1))||null]),ue=(e,t,r,n=e.charCodeAt(0),i=e.length,o=R[n],s)=>R[n]=(u,c,p,S=h)=>!u&&(p?e==p:(i<2||g.substr(h,i)==e)&&(p=e))&&c<t&&!A.id(g.charCodeAt(h+i))&&(!A.prop||A.prop(h+i))&&(je(h+i),(s=r())?$t(s,S):je(S),s)||o?.(u,c,p);Object.defineProperty(A,"space",{configurable:!0,enumerable:!0,get:()=>B,set:e=>B=e});const Ne={},l=(e,t,r=Ne[e])=>Ne[e]=(...n)=>t(...n)||r?.(...n),d=e=>Array.isArray(e)?e[0]==null?(t=>()=>t)(e[1]):Ne[e[0]]?.(...e.slice(1))??J(`Unknown operator: ${e[0]}`,e?.loc):e===void 0?()=>{}:t=>t?.[e],he=46,re=48,pe=57,Fr=69,Pr=101,Dr=43,Tr=45,fe=95,Et=110,Wr=97,Rr=102,kr=65,_r=70,It=e=>e.indexOf("_")<0?e:e.replaceAll("_",""),Je=e=>{let t=It(Z(r=>r===he&&g.charCodeAt(h+1)!==he||r>=re&&r<=pe||r===fe||((r===Fr||r===Pr)&&((r=g.charCodeAt(h+1))>=re&&r<=pe||r===Dr||r===Tr)?2:0)));return g.charCodeAt(h)===Et?(O(),[,BigInt(t)]):(e=+t)!=e?J():[,e]},jr={2:e=>e===48||e===49||e===fe,8:e=>e>=48&&e<=55||e===fe,16:e=>e>=re&&e<=pe||e>=Wr&&e<=Rr||e>=kr&&e<=_r||e===fe};A.number=null;R[he]=e=>!e&&g.charCodeAt(h+1)!==he&&Je();for(let e=re;e<=pe;e++)R[e]=t=>t?void 0:Je();R[re]=e=>{if(e)return;const t=A.number;if(t){for(const[r,n]of Object.entries(t))if(r[0]==="0"&&g[h+1]?.toLowerCase()===r[1]){O(2);const i=It(Z(jr[n]));return g.charCodeAt(h)===Et?(O(),[,BigInt("0"+r[1]+i)]):[,parseInt(i,n)]}}return Je()};const Nr=92,st=34,dt=39,Ur={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ct=e=>(t,r,n="")=>{if(!(t||!A.string?.[String.fromCharCode(e)]))return O(),Z(i=>i-e&&(i===Nr?(n+=Ur[g[h+1]]||g[h+1],2):(n+=g[h],1))),g[h]===String.fromCharCode(e)?O():J("Bad string"),[,n]};R[st]=Ct(st);R[dt]=Ct(dt);A.string={'"':!0};const Lr=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(e=>$(e,Lr,!0));const Ot=(e,t,r,n)=>typeof e=="string"?i=>t(i,e,i):e[0]==="."?(r=d(e[1]),n=e[2],i=>t(r(i),n,i)):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),i=>t(r(i),n(i),i)):e[0]==="()"&&e.length===2?Ot(e[1],t):(()=>{throw Error("Invalid assignment target")})(),ut={"=":(e,t,r)=>e[t]=r,"+=":(e,t,r)=>e[t]+=r,"-=":(e,t,r)=>e[t]-=r,"*=":(e,t,r)=>e[t]*=r,"/=":(e,t,r)=>e[t]/=r,"%=":(e,t,r)=>e[t]%=r,"|=":(e,t,r)=>e[t]|=r,"&=":(e,t,r)=>e[t]&=r,"^=":(e,t,r)=>e[t]^=r,">>=":(e,t,r)=>e[t]>>=r,"<<=":(e,t,r)=>e[t]<<=r};for(const e in ut)l(e,(t,r)=>(r=d(r),Ot(t,(n,i,o)=>ut[e](n,i,r(o)))));const Vr=30,Mr=40,Br=140;H("!",Br);$("||",Vr);$("&&",Mr);l("!",e=>(e=d(e),t=>!e(t)));l("||",(e,t)=>(e=d(e),t=d(t),r=>e(r)||t(r)));l("&&",(e,t)=>(e=d(e),t=d(t),r=>e(r)&&t(r)));const Hr=50,Gr=60,Kr=70,wt=100,Xr=140;$("|",Hr);$("&",Kr);$("^",Gr);$(">>",wt);$("<<",wt);H("~",Xr);l("~",e=>(e=d(e),t=>~e(t)));l("|",(e,t)=>(e=d(e),t=d(t),r=>e(r)|t(r)));l("&",(e,t)=>(e=d(e),t=d(t),r=>e(r)&t(r)));l("^",(e,t)=>(e=d(e),t=d(t),r=>e(r)^t(r)));l(">>",(e,t)=>(e=d(e),t=d(t),r=>e(r)>>t(r)));l("<<",(e,t)=>(e=d(e),t=d(t),r=>e(r)<<t(r)));const Ie=90;$("<",Ie);$(">",Ie);$("<=",Ie);$(">=",Ie);l(">",(e,t)=>(e=d(e),t=d(t),r=>e(r)>t(r)));l("<",(e,t)=>(e=d(e),t=d(t),r=>e(r)<t(r)));l(">=",(e,t)=>(e=d(e),t=d(t),r=>e(r)>=t(r)));l("<=",(e,t)=>(e=d(e),t=d(t),r=>e(r)<=t(r)));const Ft=80;$("==",Ft);$("!=",Ft);l("==",(e,t)=>(e=d(e),t=d(t),r=>e(r)==t(r)));l("!=",(e,t)=>(e=d(e),t=d(t),r=>e(r)!=t(r)));const Pt=110,Qe=120,Dt=140;$("+",Pt);$("-",Pt);$("*",Qe);$("/",Qe);$("%",Qe);H("+",Dt);H("-",Dt);l("+",(e,t)=>t!==void 0?(e=d(e),t=d(t),r=>e(r)+t(r)):(e=d(e),r=>+e(r)));l("-",(e,t)=>t!==void 0?(e=d(e),t=d(t),r=>e(r)-t(r)):(e=d(e),r=>-e(r)));l("*",(e,t)=>(e=d(e),t=d(t),r=>e(r)*t(r)));l("/",(e,t)=>(e=d(e),t=d(t),r=>e(r)/t(r)));l("%",(e,t)=>(e=d(e),t=d(t),r=>e(r)%t(r)));const ge=150;W("++",ge,e=>e?["++",e,null]:["++",v(ge-1)]);W("--",ge,e=>e?["--",e,null]:["--",v(ge-1)]);const qe=(e,t,r,n)=>typeof e=="string"?i=>t(i,e):e[0]==="."?(r=d(e[1]),n=e[2],i=>t(r(i),n)):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),i=>t(r(i),n(i))):e[0]==="()"&&e.length===2?qe(e[1],t):(()=>{throw Error("Invalid increment target")})();l("++",(e,t)=>qe(e,t===null?(r,n)=>r[n]++:(r,n)=>++r[n]));l("--",(e,t)=>qe(e,t===null?(r,n)=>r[n]--:(r,n)=>--r[n]));const zr=5,Jr=10;St(",",Jr);St(";",zr,!0);const Tt=(...e)=>(e=e.map(d),t=>{let r;for(const n of e)r=n(t);return r});l(",",Tt);l(";",Tt);const Qr=170;ze("()",Qr);const M=e=>e?.[0]==="_"&&e[1]==="_"||e==="constructor"||e==="prototype",Ye=170;vt("[]",Ye);$(".",Ye);vt("()",Ye);const me=e=>{throw Error(e)};l("[]",(e,t)=>t===void 0?(e=e?e[0]===","?e.slice(1):[e]:[],e=e.map(r=>r==null?(()=>{}):r[0]==="..."?(r=d(r[1]),n=>r(n)):(r=d(r),n=>[r(n)])),r=>e.flatMap(n=>n(r))):(t==null&&me("Missing index"),e=d(e),t=d(t),r=>{const n=t(r);return M(n)?void 0:e(r)[n]}));l(".",(e,t)=>(e=d(e),t=t[0]?t:t[1],M(t)?()=>{}:r=>e(r)[t]));l("()",(e,t)=>{if(t===void 0)return e==null?me("Empty ()"):d(e);const r=i=>i?.[0]===","&&i.slice(1).some(o=>o==null||r(o));r(t)&&me("Empty argument");const n=t?t[0]===","?(t=t.slice(1).map(d),i=>t.map(o=>o(i))):(t=d(t),i=>[t(i)]):()=>[];return Ze(e,(i,o,s)=>i[o](...n(s)))});const Q=e=>typeof e=="string"||Array.isArray(e)&&(e[0]==="."||e[0]==="?."||e[0]==="[]"&&e.length===3||e[0]==="?.[]"||e[0]==="()"&&e.length===2&&Q(e[1])||e[0]==="{}"),Ze=(e,t,r,n)=>e==null?me("Empty ()"):e[0]==="()"&&e.length==2?Ze(e[1],t):typeof e=="string"?i=>t(i,e,i):e[0]==="."?(r=d(e[1]),n=e[2],i=>t(r(i),n,i)):e[0]==="?."?(r=d(e[1]),n=e[2],i=>{const o=r(i);return o==null?void 0:t(o,n,i)}):e[0]==="[]"&&e.length===3?(r=d(e[1]),n=d(e[2]),i=>t(r(i),n(i),i)):e[0]==="?.[]"?(r=d(e[1]),n=d(e[2]),i=>{const o=r(i);return o==null?void 0:t(o,n(i),i)}):(e=d(e),i=>t([e(i)],0,i)),x=Ze,qr=32,Yr=A.space;A.comment??={"//":`
6
+ `,"/*":"*/"};let Oe;A.space=()=>{Oe||(Oe=Object.entries(A.comment).map(([i,o])=>[i,o,i.charCodeAt(0)]));for(var e;e=Yr();){for(var t=0,r;r=Oe[t++];)if(e===r[2]&&g.substr(h,r[0].length)===r[0]){var n=h+r[0].length;if(r[1]===`
7
+ `)for(;g.charCodeAt(n)>=qr;)n++;else{for(;g[n]&&g.substr(n,r[1].length)!==r[1];)n++;g[n]&&(n+=r[1].length)}je(n),e=0;break}if(e)return e}return e};const Wt=80;$("===",Wt);$("!==",Wt);l("===",(e,t)=>(e=d(e),t=d(t),r=>e(r)===t(r)));l("!==",(e,t)=>(e=d(e),t=d(t),r=>e(r)!==t(r)));const Zr=30;$("??",Zr);l("??",(e,t)=>(e=d(e),t=d(t),r=>e(r)??t(r)));const xr=130,br=20;$("**",xr,!0);$("**=",br,!0);l("**",(e,t)=>(e=d(e),t=d(t),r=>e(r)**t(r)));const en=e=>{throw Error(e)};l("**=",(e,t)=>(Q(e)||en("Invalid assignment target"),t=d(t),x(e,(r,n,i)=>r[n]**=t(i))));const Rt=90;$("in",Rt);$("of",Rt);l("in",(e,t)=>(e=d(e),t=d(t),r=>e(r)in t(r)));const tn=20,rn=100,nn=e=>{throw Error(e)};$(">>>",rn);$(">>>=",tn,!0);l(">>>",(e,t)=>(e=d(e),t=d(t),r=>e(r)>>>t(r)));l(">>>=",(e,t)=>(Q(e)||nn("Invalid assignment target"),t=d(t),x(e,(r,n,i)=>r[n]>>>=t(i))));const xe=5,on=10,sn=20,dn=e=>e[0]?.[0]===","?e[0].slice(1):e,ye=(e,t,r)=>{if(typeof e=="string"){r[e]=t;return}const[n,...i]=e,o=dn(i);if(n==="{}"){const s=[];for(const u of o){if(Array.isArray(u)&&u[0]==="..."){const f={};for(const w in t)s.includes(w)||(f[w]=t[w]);r[u[1]]=f;break}let c,p,S;typeof u=="string"?c=p=u:u[0]==="="?(typeof u[1]=="string"?c=p=u[1]:[,c,p]=u[1],S=u[2]):[,c,p]=u,s.push(c);let m=t[c];m===void 0&&S&&(m=d(S)(r)),ye(p,m,r)}}else if(n==="[]"){let s=0;for(const u of o){if(u===null){s++;continue}if(Array.isArray(u)&&u[0]==="..."){r[u[1]]=t.slice(s);break}let c=u,p;Array.isArray(u)&&u[0]==="="&&([,c,p]=u);let S=t[s++];S===void 0&&p&&(S=d(p)(r)),ye(c,S,r)}}},kt=e=>{let t=v(on-1);return t?.[0]==="in"||t?.[0]==="of"?[t[0],[e,t[1]],t[2]]:t?.[0]===","?[e,...t.slice(1)]:[e,t]};ue("let",xe+1,()=>kt("let"));ue("const",xe+1,()=>kt("const"));ue("var",xe,()=>(B(),["var",v(sn)]));const _t=(...e)=>(e=e.map(t=>{if(typeof t=="string")return r=>{r[t]=void 0};if(t[0]==="="){const[,r,n]=t,i=d(n);return typeof r=="string"?o=>{o[r]=i(o)}:o=>ye(r,i(o),o)}return d(t)}),t=>{for(const r of e)r(t)});l("let",_t);l("const",_t);l("var",e=>typeof e=="string"?t=>{t[e]=void 0}:()=>{});const be=20,Ce=e=>{throw Error(e)};$("||=",be,!0);$("&&=",be,!0);$("??=",be,!0);l("=",(e,t)=>{if(Array.isArray(e)&&(e[0]==="let"||e[0]==="const"||e[0]==="var")){const r=e[1];return t=d(t),typeof r=="string"?n=>{n[r]=t(n)}:n=>ye(r,t(n),n)}return Q(e)||Ce("Invalid assignment target"),t=d(t),x(e,(r,n,i)=>r[n]=t(i))});l("||=",(e,t)=>(Q(e)||Ce("Invalid assignment target"),t=d(t),x(e,(r,n,i)=>r[n]||=t(i))));l("&&=",(e,t)=>(Q(e)||Ce("Invalid assignment target"),t=d(t),x(e,(r,n,i)=>r[n]&&=t(i))));l("??=",(e,t)=>(Q(e)||Ce("Invalid assignment target"),t=d(t),x(e,(r,n,i)=>r[n]??=t(i))));de("true",!0);de("false",!1);de("null",null);ue("undefined",200,()=>[]);de("NaN",NaN);de("Infinity",1/0);const we=20;W("?",we,(e,t,r)=>e&&(t=v(we-1))&&Z(n=>n===58)&&(r=v(we-1),["?",e,t,r]));l("?",(e,t,r)=>(e=d(e),t=d(t),r=d(r),n=>e(n)?t(n):r(n)));const un=[],cn=20;$("=>",cn,!0);l("=>",(e,t)=>{e=e?.[0]==="()"?e[1]:e;const r=e?e[0]===","?e.slice(1):[e]:[];let n=-1,i=null;const o=r[r.length-1];Array.isArray(o)&&o[0]==="..."&&(n=r.length-1,i=o[1],r.length--);const s=t?.[0]==="{}";return t=d(s?["{",t[1]]:t),u=>(...c)=>{const p={};r.forEach((m,f)=>p[m]=c[f]),i&&(p[i]=c.slice(n));const S=new Proxy(p,{get:(m,f)=>f in m?m[f]:u?.[f],set:(m,f,w)=>((f in m?m:u)[f]=w,!0),has:(m,f)=>f in m||(u?f in u:!1)});try{const m=t(S);return s?void 0:m}catch(m){if(m===un)return m[0];throw m}}});const ln=140;H("...",ln);l("...",e=>(e=d(e),t=>Object.entries(e(t))));const ct=170;W("?.",ct,(e,t)=>{if(!e)return;const r=B();return r===40?(O(),["?.()",e,v(0,41)||null]):r===91?(O(),["?.[]",e,v(0,93)]):(t=v(ct),t?["?.",e,t]:void 0)});l("?.",(e,t)=>(e=d(e),M(t)?()=>{}:r=>e(r)?.[t]));l("?.[]",(e,t)=>(e=d(e),t=d(t),r=>{const n=t(r);return M(n)?void 0:e(r)?.[n]}));l("?.()",(e,t)=>{const r=t?t[0]===","?(t=t.slice(1).map(d),i=>t.map(o=>o(i))):(t=d(t),i=>[t(i)]):()=>[];if(e[0]==="?."){const i=d(e[1]),o=e[2];return M(o)?()=>{}:s=>i(s)?.[o]?.(...r(s))}if(e[0]==="?.[]"){const i=d(e[1]),o=d(e[2]);return s=>{const u=i(s),c=o(s);return M(c)?void 0:u?.[c]?.(...r(s))}}if(e[0]==="."){const i=d(e[1]),o=e[2];return M(o)?()=>{}:s=>i(s)?.[o]?.(...r(s))}if(e[0]==="[]"&&e.length===3){const i=d(e[1]),o=d(e[2]);return s=>{const u=i(s),c=o(s);return M(c)?void 0:u?.[c]?.(...r(s))}}const n=d(e);return i=>n(i)?.(...r(i))});const ne=140;H("typeof",ne);H("void",ne);H("delete",ne);ue("new",ne,()=>wr(".target")?(O(7),["new.target"]):["new",v(ne)]);l("typeof",e=>(e=d(e),t=>typeof e(t)));l("void",e=>(e=d(e),t=>(e(t),void 0)));l("delete",e=>{if(e[0]==="."){const t=d(e[1]),r=e[2];return n=>delete t(n)[r]}if(e[0]==="[]"){const t=d(e[1]),r=d(e[2]);return n=>delete t(n)[r(n)]}return()=>!0});l("new",e=>{const t=d(e?.[0]==="()"?e[1]:e),r=e?.[0]==="()"?e[2]:null,n=r?r[0]===","?(i=>o=>i.map(s=>s(o)))(r.slice(1).map(d)):(i=>o=>[i(o)])(d(r)):()=>[];return i=>new(t(i))(...n(i))});const et=Symbol("accessor"),tt=20,an=40,jt=41,Nt=123,Ut=125,Lt=e=>t=>{if(t)return;B();const r=Z(A.id);if(!r||(B(),g.charCodeAt(h)!==an))return!1;O();const n=v(0,jt);return B(),g.charCodeAt(h)!==Nt?!1:(O(),[e,r,n,v(0,Ut)])};W("get",tt-1,Lt("get"));W("set",tt-1,Lt("set"));W("(",tt-1,e=>{if(!e||typeof e!="string")return;const t=v(0,jt)||null;if(B(),g.charCodeAt(h)===Nt)return O(),[":",e,["=>",["()",t],v(0,Ut)||null]]});l("get",(e,t)=>(t=t?d(t):()=>{},r=>[[et,e,{get:function(){const n=Object.create(r||{});return n.this=this,t(n)}}]]));l("set",(e,t,r)=>(r=r?d(r):()=>{},n=>[[et,e,{set:function(i){const o=Object.create(n||{});o.this=this,o[t]=i,r(o)}}]]));const fn=20,Vt=200;A.prop=e=>Or(e)!==58;const hn=e=>e==null||typeof e=="string"||[":",",","...","get","set"].includes(e[0]);ze("[]",Vt);ze("{}",Vt);$(":",fn-1,!0);l("{}",(e,t)=>{if(t!==void 0)return;if(!hn(e))return d(["{",e]);e=e?e[0]!==","?[e]:e.slice(1):[];const r=e.map(n=>d(typeof n=="string"?[":",n,n]:n));return n=>{const i={},o={};for(const s of r.flatMap(u=>u(n)))if(s[0]===et){const[,u,c]=s;o[u]={...o[u],...c,configurable:!0,enumerable:!0}}else i[s[0]]=s[1];for(const s in o)Object.defineProperty(i,s,o[s]);return i}});l("{",e=>(e=e?d(e):()=>{},t=>e(Object.create(t))));l(":",(e,t)=>(t=d(t),Array.isArray(e)?(e=d(e),r=>[[e(r),t(r)]]):r=>[[e,t(r)]]));const pn=170,Ae=96,gn=36,mn=123,yn=92,An={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},lt=()=>{const e=[];for(let t="",r;(r=g.charCodeAt(h))!==Ae;)r?r===yn?(O(),t+=An[g[h]]||g[h],O()):r===gn&&g.charCodeAt(h+1)===mn?(t&&e.push([,t]),t="",O(2),e.push(v(0,125))):(t+=g[h],O(),r=g.charCodeAt(h),r===Ae&&t&&e.push([,t])):J("Unterminated template");return O(),e},$n=R[Ae];R[Ae]=(e,t)=>e&&t<pn?A.asi&&A.newline?void 0:(O(),["``",e,...lt()]):e?$n?.(e,t):(O(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(lt()));l("`",(...e)=>(e=e.map(d),t=>e.map(r=>r(t)).join("")));l("``",(e,...t)=>{e=d(e);const r=[],n=[];for(const o of t)Array.isArray(o)&&o[0]===void 0?r.push(o[1]):n.push(d(o));const i=Object.assign([...r],{raw:r});return o=>e(o)(i,...n.map(s=>s(o)))});A.string["'"]=!0;A.number={"0x":16,"0b":2,"0o":8};const Sn={log:(e,t)=>(t?console.log(t,e):console.log(e),e)};function N(e,t,r,n,i){const o=A(vn(e));return d(o)({$form:t,$meta:r,$errors:n,$formIsInvalid:i,$log:Sn.log})===!0}function vn(e){return e.replace(/\?\.(\d+)/g,"?.[$1]").replace(/\.(\d+)/g,"[$1]")}const U=e=>{let t=e.formDef.states;if(!t||Object.keys(t).length===0||e.formHealth.status==="errored")return e;const{$formIsInvalid:r,$errors:n}=Ke(e);t=En(t);let i=[],o={status:"ok"};try{i=Object.keys(t).map(s=>{const u=t[s];let c;try{c=N(u,e.data,e.meta,n,r)}catch{c=!1}return c===!0?s:void 0}).filter(s=>s!==void 0)}catch(s){const u=s,c=ee.calculateCurrentStateError;o={status:"errored",message:`[${c}] ${u.message}`,code:c}}return{...e,currentStates:i,formHealth:o}};function En(e){const t={};function r(n){const i=n.split(":"),o=[];for(let s=0;s<i.length;s++)o.push(i.slice(0,s+1).join(":"));return o}for(const[n,i]of Object.entries(e)){const o=r(n),s=[];for(const u of o)e[u]&&s.push(`(${e[u]})`);t[n]=s.join(" && ")}return t}const rt=Symbol("filterMap.skip");function Mt(e,t){const r=[];for(let n=0;n<e.length;n++){const i=t(e[n],n,e);i!==rt&&r.push(i)}return r}function In(e,t,r){for(let n=0;n<e.length;n++)t(e[n],n,e)&&r(e[n],n,e)}function Cn(e,t,r,n){let i=n;for(let o=0;o<e.length;o++)t(e[o],o,e)&&(i=r(i,e[o],o,e));return i}function On(e,t,r){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!r(e[n],t[n],n,e,t))return!1;return!0}function Bt(e,t){const r=Ht(e.uid,t);return P(e)?{...e,uid:r,path:wn(e.path,t)}:{...e,uid:r}}function Ht(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r=t.reduce((n,i)=>`${n}[${i}]`,"");return`${e}${r}`}function wn(e,t){if(t.length===0)throw new Error("Repeater indexes cannot be an empty array");const r="items",n=e.split(`.${r}`),i=n.length-1;if(i!==t.length)throw new Error(`Path contains ${i} '${r}' occurrences, but ${t.length} indexes were provided.`);return n.reduce((o,s,u)=>u===0?s:`${o}.${t[u-1]}${s}`)}function le(e,t){let r=0;return e.replace(/\.items(\??)\./g,(n,i)=>{const o=t[r++];return o===void 0?n:`.${o}${i}.`})}const ae=(e,t)=>r=>e(r)?t(r):r,K=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e,L=e=>{const{$formIsInvalid:t,$errors:r}=Ke(e);return{...e,widgetFlags:{...Fn(e,r,t),...Pn(e,r,t)}}};function Fn(e,t,r){return Mt(Object.values(e.flatForm),n=>{if(n.uid?.includes("["))return rt;if(se(n)){const i=n({$form:e.data,errors:void 0,touched:void 0,translate:void 0});return i.uid=n.uid,i}return n}).filter(n=>!!(n.include&&("in"in n.include||"when"in n.include)||n.exclude&&("from"in n.exclude||"when"in n.exclude)||(P(n)||te(n))&&K(n.disabled)||P(n)&&K(n.readonly))).reduce((n,i)=>(n[i.uid]=n[i.uid]||{},i.include&&"in"in i.include?n[i.uid].hidden=!i.include.in.some(o=>e.currentStates.includes(o)):i.include&&"when"in i.include&&(n[i.uid].hidden=!N(i.include.when,e.data,e.meta,t,r)),i.exclude&&"from"in i.exclude?n[i.uid].hidden=i.exclude.from.some(o=>e.currentStates.includes(o)):i.exclude&&"when"in i.exclude&&(n[i.uid].hidden=N(i.exclude.when,e.data,e.meta,t,r)),(P(i)||te(i))&&K(i.disabled)&&(n[i.uid].disabled=N(i.disabled.when,e.data,e.meta,t,r)),P(i)&&K(i.readonly)&&(n[i.uid].readonly=N(i.readonly.when,e.data,e.meta,t,r)),n),{})}function Pn(e,t,r){return Cn(Object.values(e.flatForm),n=>!se(n)&&n.type==="repeater",(n,i)=>({...n,...Gt(e,i,[],t,r)}),{})}function Gt(e,t,r,n,i){const o=t.props.template,s=k(e.data,t.path);if(!Array.isArray(s))return{};const u={};return s.forEach((c,p)=>{const S=[...r,p];Ge([o]).forEach(m=>{let f;if(se(m)?(f=m({$form:e.data,errors:void 0,touched:void 0,translate:void 0}),f.uid=m.uid):f=m,f.type==="repeater"){const b=Bt(f,S);Object.assign(u,Gt(e,b,S,n,i));return}const w=Ht(f.uid,S);u[w]=u[w]||{},f.include&&"in"in f.include?u[w].hidden=!f.include.in.some(b=>e.currentStates.includes(b)):f.include&&"when"in f.include&&(u[w].hidden=!N(le(f.include.when,S),e.data,e.meta,n,i)),f.exclude&&"from"in f.exclude?u[w].hidden=f.exclude.from.some(b=>e.currentStates.includes(b)):f.exclude&&"when"in f.exclude&&(u[w].hidden=N(le(f.exclude.when,S),e.data,e.meta,n,i)),(P(f)||te(f))&&K(f.disabled)&&(u[w].disabled=N(le(f.disabled.when,S),e.data,e.meta,n,i)),P(f)&&K(f.readonly)&&(u[w].readonly=N(le(f.readonly.when,S),e.data,e.meta,n,i))})}),u}const j=e=>t=>({...t,calculatedWidgets:Dn(t,e)});function Dn(e,t){const{$formIsInvalid:r,$errors:n}=Ke(e),i=zn(e,t,r,n),o={};for(const s of Object.keys(e.calculatedWidgets)){if(e.widgetFlags[s]?.hidden)continue;const u=e.calculatedWidgets[s],c=u.source;if(se(c)){o[s]=Tn(s,c,e,t);continue}o[s]=Wn(u,c,e,i)}return o}function Tn(e,t,r,n){const i=t({$form:r.data,errors:t.path?r.validations[t.path]:void 0,touched:t.path?r.touchedControls[t.path]:void 0,translate:n.translate});return i.uid=e,{source:t,current:i}}function Wn(e,t,r,n){const i=new Xn(t,e.current);return i.write("uid",t.uid),i.write("type",t.type),i.write("kind",t.kind),ir(t)?Rn(i,n):te(t)?kn(i,n):P(t)?_n(i,n):Te(t)&&jn(i,n),Nn(t,i,n,r),(te(t)||P(t))&&Un(t,i,n),Te(t)&&Ln(t,i,r),i.changed?{source:e.source,current:i.current}:e}function Rn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude")}function kn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude"),E(e,t,"label"),E(e,t,"disabled"),E(e,t,"actionType")}function _n(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude"),E(e,t,"label"),E(e,t,"disabled"),E(e,t,"readonly"),E(e,t,"validator"),E(e,t,"path"),E(e,t,"defaultValue")}function jn(e,t){E(e,t,"size"),E(e,t,"include"),E(e,t,"exclude")}function Nn(e,t,r,n){const i=n.widgetPropOverrides[e.uid]??{},o={...e.props??{},...i};for(const s of zt(Object.keys(o)))Vn(t,r,s)}function Un(e,t,r){const n=e.on??{};for(const i of zt(Object.keys(n)))Mn(t,r,i)}function Ln(e,t,r){const n=qn(e.uid),i=Qn(e.children,n,r.widgetFlags);t.current.children=i;const o=t.previous.children??[];o.length===i.length&&i.every((u,c)=>o[c]&&o[c].uid===i[c].uid)||t.markChanged()}function E(e,t,r){const n=e.source;if(!Jn(n,r))return;const i=it(n,r,t.sortedStates);let o;switch(r){case"disabled":case"readonly":o=Hn(i,t,e.source.uid,r);break;default:o=Xt(i,t)}e.write(r,o)}function Vn(e,t,r){const n=e.source.props,i=it(n,r,t.sortedStates);let o=Xt(i,t);const s=t.widgetPropOverrides[e.source.uid]?.[r];s!==void 0&&(o=s),e.write(`props.${r}`,o)}function Mn(e,t,r){const n=e.source.on,i=it(n,r,t.sortedStates);e.write(`on.${r}`,Gn(i,t))}function nt(e,t){return e({$form:t.$form,translate:t.localization.translate})}function Bn(e,t){return t.localization.translate(e.key,Kn(e.params,t),e.default)}function Kt(e,t){return Ir(e,{resolveFormPath:r=>k(t.$form,r)??e,resolveMetaPath:r=>k(t.$meta,r)??e,resolveErrorsPath:r=>k(t.$errors,r)??e,resolveFormIsInvalid:()=>String(t.$formIsInvalid)})}function Xt(e,t){return typeof e=="function"?nt(e,t):gr(e)?Bn(e,t):typeof e=="string"?Kt(e,t):e}function Hn(e,t,r,n){return typeof e=="function"?nt(e,t):K(e)?t.widgetFlags[r]?.[n]:typeof e=="string"?Kt(e,t):e}function Gn(e,t){return typeof e=="function"?nt(e,t):e}function it(e,t,r){if(e){for(const n of r){const i=e[`${t}.${n}`];if(i!==void 0)return i}return e[t]}}function Kn(e,t){return e&&Object.keys(e).reduce((r,n)=>{const i=String(e[n]);return Sr(i)?r[n]=Cr(i,{resolveFormPath:o=>k(t.$form,o)??i,resolveMetaPath:o=>k(t.$meta,o)??i,resolveErrorsPath:o=>k(t.$errors,o)??i,resolveFormIsInvalid:()=>t.$formIsInvalid}):r[n]=i,r},{})}class Xn{constructor(t,r){this._changed=!1,this.source=t,this.previous=r,this.current={}}get changed(){return this._changed}markChanged(){this._changed=!0}write(t,r){He(this.current,t,r),k(this.previous,t)!==r&&(this._changed=!0)}}function zn(e,t,r,n){return{sortedStates:[...e.currentStates].sort((i,o)=>o.length-i.length),widgetPropOverrides:e.widgetPropOverrides,widgetFlags:e.widgetFlags,$form:e.data,$meta:e.meta,$formIsInvalid:r,$errors:n,localization:t}}function Jn(e,t){if(t in e)return!0;const r=`${t}.`;return Object.keys(e).some(n=>n.startsWith(r))}function zt(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function Qn(e,t,r){const n=t.map(i=>`[${i}]`).join("");return e.filter(i=>{const o=i.uid+n,s=r[o];return!s||s.hidden!==!0})}const qn=e=>[...e.matchAll(/\[(\d+)\]/g)].map(t=>parseInt(t[1],10)),Yn=({lang:e},t)=>{const r={...yt(e),formName:t.payload.formName};let n=t.payload.formDef,i={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(u){const c=u,p=ee.initializeParseError;i={status:"errored",message:`[${p}] ${c.message}`,code:p}}if(i.status==="errored")return{...r,formHealth:i}}if(Array.isArray(n.form)){const u=n,c=u.form;u.form={uid:"",type:"flex",kind:"layout",children:c}}const o=mt.decode(n);if(o.isOk()){i={status:"ok"};let u={};try{u=Ge([o.value.form]).reduce((c,p)=>{const S=p.uid;if(c[S])throw{existingWidget:c[S],newWidget:p};return c[S]=p,c},{})}catch(c){const p=ee.initializeUidCollisionError;i={status:"errored",message:`[${p}] ${Zn(c.existingWidget,c.newWidget)}`,code:p},u={}}return{...r,formDef:o.value,flatForm:u,formHealth:i}}const s=ee.initializeUnknownError;return{...r,formHealth:{status:"errored",message:`[${s}] ${o.error}`,code:s}}};function Zn(e,t){const r=n=>P(n)?` at "${n.path}"`:"";return`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`}function xn(e,t){return{...e,injectedValidations:{...e.injectedValidations,[t.payload.path]:t.payload.issues}}}const bn=(e,{payload:t})=>{let r;if("path"in t){if(r=Object.values(e.calculatedWidgets).find(({source:o})=>P(o)&&o.path===t.path),!r)return console.warn(`Input with path "${t.path}" not found`),e}else if(r=e.calculatedWidgets[t.uid],!r)return console.warn(`Widget with uid "${t.uid}" not found`),e;const n=r.source.uid,i=e.widgetPropOverrides[n]||{};return{...e,widgetPropOverrides:{...e.widgetPropOverrides,[n]:{...i,[t.prop]:t.value}}}};function ei(e,t){return{...e,widgetFlags:{...ce(e.widgetFlags,t.payload.uid)},calculatedWidgets:{...ce(e.calculatedWidgets,t.payload.uid)},widgetPropOverrides:{...ce(e.widgetPropOverrides,t.payload.uid)},touchedControls:{..._(e.touchedControls,r=>{const n=e.flatForm[t.payload.uid];return n&&P(n)?ce(r,n.path):r})}}}const ti=(e,t)=>({...e,data:{...t.payload.data}}),ri=(e,t)=>({...e,formHealth:t.payload.formHealth}),ni=(e,t)=>({...e,lang:t.payload.lang}),ii=(e,t)=>({...e,meta:{...t.payload.meta}}),oi=(e,t)=>{const r=k(e.data,t.payload.path);return t.type==="SET_WIDGET_DATA"||t.type==="SET_WIDGET_INITIAL_DATA"&&r===void 0?{...e,data:{...He(e.data,t.payload.path,t.payload.data)}}:e},Fe=(e,t)=>r=>{const n=Mt(Object.values(r.calculatedWidgets),({current:o})=>P(o)?o:rt),i=r.validations;return{...r,validations:n.reduce((o,s)=>{if(o[s.path]=null,s.validator){const u=e(s.validator,t),c=k(r.data,s.path),p=ft(u,c);o[s.path]=ht(p)?null:p.issues.map(S=>S.message)}return Array.isArray(o[s.path])&&Array.isArray(i[s.path])&&On(o[s.path],i[s.path],(u,c)=>u===c)&&(o[s.path]=i[s.path]),o},{})}},si=({validators:e,validateOn:t,localization:r})=>(n,i)=>{switch(i.type){case"INITIALIZE":return Yn(n,i);case"SET_DATA":return _(ti(n,i),U,L,j(r));case"SET_META":return _(ii(n,i),U,L,j(r));case"SET_LANGUAGE":return _(ni(n,i),j(r));case"ADD_WIDGET":return _(Ar(n,i),ae(Pe,U),ae(Pe,L),ae(Pe,j(r)));case"REMOVE_WIDGET":return _(ei(n,i),U,L,j(r));case"SET_WIDGET_INITIAL_DATA":case"SET_WIDGET_DATA":return _(oi(n,i),U,L,j(r));case"OVERRIDE_WIDGET_PROP":return _(bn(n,i),U,L,j(r),ae(o=>{let s=!1,u="";"path"in i.payload?(s=!0,u=i.payload.path):P(o.calculatedWidgets[i.payload.uid].current)&&(s=!0,u=o.calculatedWidgets[i.payload.uid].current.path);const c=s&&o.touchedControls[u];return o.touched&&c},Fe(e,r)));case"SET_FORM_HEALTH":return ri(n,i);case"VALIDATE_ALL":return _({...n,touched:!0,touchedControls:Object.keys(n.calculatedWidgets).reduce((o,s)=>{const u=n.calculatedWidgets[s].source;return P(u)&&(o[u.path]=!0),o},{})},Fe(e,r),U,L,j(r),at);case"ATTEMPT_VALIDATION":{const o=i.payload.reason,s=i.payload.path;return t==="eager"||o===t||t.includes(o)?_({...n,touched:!0,touchedControls:{...n.touchedControls,[s]:!0}},Fe(e,r),U,L,j(r),c=>{const p=i.payload.uid,S=c.calculatedWidgets[p],m=S.source;if(se(m)){const f=m({$form:c.data,errors:c.validations[s],touched:!0,translate:r.translate});return{...c,calculatedWidgets:{...c.calculatedWidgets,[p]:{source:S.source,current:f}}}}return c},at):n}case"INJECT_VALIDATION_ISSUES":return xn(n,i);default:return yr(i)}},Pe=e=>e.formHealth.status==="ok";function at(e){const t=Object.keys(e.injectedValidations),r=Object.keys(e.validations);if(t.length===0&&r.length===0)return{...e,isFormValid:!0};let n=t.find(i=>e.injectedValidations[i]!==null&&Array.isArray(e.injectedValidations[i]));return n!==void 0?{...e,isFormValid:!1}:(n=r.find(i=>e.validations[i]!==null&&Array.isArray(e.validations[i])),n!==void 0?{...e,isFormValid:!1}:{...e,isFormValid:!0})}function di(e=[],t,r,n){const i=new a.BehaviorSubject(yt(n.lang)),o=i.asObservable().pipe(a.distinctUntilChanged()),s=si({validators:t,validateOn:r,localization:n});function u(m){const f=i.getValue(),w=s(f,m);i.next(w)}let c=u;const p={getState:()=>i.getValue(),dispatch:m=>c(m)};return c=e.map(m=>m(p)).reduceRight((m,f)=>f(m),u),{state$:o,dispatch:c,getState:()=>i.getValue()}}class ui{constructor(){this.widgetRegistry=new Re,this.store={},this.events$=new a.Subject,this.submit$=new a.Subject,this.uuid=crypto.randomUUID(),this.itemRenderers={},this.dependencies={}}initialize(t,r=[],n,i,o,s=At(),u){this.localization=s,this.dependencies=u,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=o,this.store=di(r,n,i,s)}emitEvent(t,r,n){const o=this.store.getState().currentStates.filter(s=>r.on?.[`${t}.${s}`]!==void 0);if(o.length>0)o.forEach(s=>{const u=r.on?.[`${t}.${s}`];this.attemptValidation(t,r),u&&this.events$.next({name:u,data:this.store.getState().data,detail:n??void 0,callback:c=>{this.store.dispatch(c)}})});else{const s=r.on?.[t];this.attemptValidation(t,r),s&&this.events$.next({name:s,data:this.store.getState().data,detail:n,callback:u=>{this.store.dispatch(u)}})}}emitSubmitEvent(){this.store.dispatch({type:"VALIDATE_ALL"}),this.store.getState().isFormValid&&this.submit$.next({data:this.store.getState().data,callback:t=>{this.store.dispatch(t)}})}attemptValidation(t,r){r.kind!=="layout"&&(t==="change"?this.store.dispatch({type:"ATTEMPT_VALIDATION",payload:{reason:"change",path:r.path,uid:r.uid}}):t==="click"&&r.kind==="action"&&r.actionType==="submit"&&this.store.dispatch({type:"VALIDATE_ALL"}))}}function ci(e="GolemUI Form Store"){return t=>{const n=(typeof window<"u"?window.__REDUX_DEVTOOLS_EXTENSION__:void 0)?.connect({name:e});return n?.init(t.getState()),i=>o=>{i(o),n&&n.send(o,t.getState())}}}const li=a.pipe(a.map(e=>e.data),a.distinctUntilChanged()),ai=e=>a.pipe(li,a.map(t=>k(t,e)),a.distinctUntilChanged()),fi=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.validations),a.distinctUntilChanged()),hi=e=>a.pipe(fi,a.map(t=>t[e]),a.distinctUntilChanged()),pi=a.pipe(a.filter(e=>e.touched===!0),a.map(e=>e.injectedValidations),a.distinctUntilChanged()),gi=e=>a.pipe(pi,a.map(t=>t[e]),a.distinctUntilChanged(),a.startWith(null)),mi=a.pipe(a.map(e=>e.lang),a.distinctUntilChanged()),Jt=a.pipe(a.map(e=>e.calculatedWidgets),a.distinctUntilChanged()),yi=e=>t=>a.combineLatest([t.pipe(mi),t.pipe(Jt)]).pipe(a.map(([r,n])=>({lang:r,widget:n[e]})),a.filter(r=>r.widget!==void 0),a.distinctUntilChanged((r,n)=>r.lang===n.lang&&r.widget===n.widget),a.map(r=>r.widget.current)),Ai=e=>a.pipe(Jt,a.map(t=>t[e]),a.filter(t=>t!==void 0),a.map(t=>t.current.children),a.distinctUntilChanged());a.pipe(a.map(e=>e.widgetFlags),a.distinctUntilChanged());const $i=a.pipe(a.map(e=>e.touchedControls),a.distinctUntilChanged()),Si=e=>a.pipe($i,a.map(t=>t[e]),a.distinctUntilChanged()),vi=a.pipe(a.map(e=>e.formHealth),a.distinctUntilChanged((e,t)=>e.status!==t.status?!1:e.status==="errored"&&t.status==="errored"?e.message===t.message&&e.code===t.code:!0)),Ei=e=>e.pipe(vi);let Qt=!1;function Ii(){Qt=!0}function Ci(){return Qt}function Oi(e,t,r){if(!Ci())return;const n=Object.keys(t??{}).filter(i=>i in r);if(n.length>0)throw new Error(`[GolemUI] Widget "${e}": prop keys [${n.join(", ")}] collide with widget fields`)}exports.FormContext=ui;exports.assertNoPropCollisions=Oi;exports.calculatedLayoutChildrenByUid$=Ai;exports.calculatedWidgetsByUid$=yi;exports.cloneObject=ke;exports.dataByPath$=ai;exports.defineForm=pr;exports.devToolsMiddleware=ci;exports.enableDevMode=Ii;exports.errorCodes=ee;exports.filterTap=In;exports.formHealth=Ei;exports.getDirectionFromLanguage=mr;exports.identityTranslator=At;exports.injectedValidationByPath$=gi;exports.isStandardValidateSuccess=ht;exports.makeRepeaterItemConfig=Bt;exports.shortUUID=Le;exports.standardValidate=ft;exports.touchedControlsByPath$=Si;exports.validationByPath$=hi;
@@ -4,7 +4,7 @@ import { ValidatorFn } from '../form-validator';
4
4
  import { ActionWidget, InputWidget, LayoutWidget, On } from '../form-widget';
5
5
  import { I18nTranslator } from '../i18n';
6
6
  import { ItemRenderer } from '../item-renderer';
7
- import { FormEvent, ValidateOn } from '../shared';
7
+ import { FormEvent, FormSubmitEvent, ValidateOn } from '../shared';
8
8
  import { Action } from '../store/actions';
9
9
  import { Middleware, State } from '../store/model';
10
10
  import { WidgetLoaders, WidgetRegistry } from './widget-registry';
@@ -12,6 +12,7 @@ export declare class FormContext<ComponentType> {
12
12
  widgetRegistry: WidgetRegistry<ComponentType>;
13
13
  store: FormStore;
14
14
  events$: Subject<FormEvent>;
15
+ submit$: Subject<FormSubmitEvent>;
15
16
  uuid: `${string}-${string}-${string}-${string}-${string}`;
16
17
  itemRenderers: Record<string, ItemRenderer>;
17
18
  localization: I18nTranslator;
@@ -22,5 +23,6 @@ export declare class FormContext<ComponentType> {
22
23
  dependencies: Record<string, unknown>;
23
24
  initialize(widgetLoaders: WidgetLoaders<ComponentType>, middlewares: Middleware<State, Action>[] | undefined, validators: ValidatorFn<any>, validateOn: ValidateOn, itemRenderers: Record<string, ItemRenderer>, localization: I18nTranslator | undefined, dependencies: Record<string, unknown>): void;
24
25
  emitEvent(eventType: keyof On<string>, widget: InputWidget<any, string> | ActionWidget<string> | LayoutWidget<string>, detail?: any): void;
26
+ emitSubmitEvent(): void;
25
27
  private attemptValidation;
26
28
  }
@@ -47,6 +47,7 @@ export type DisplayWidget<StateKeys extends UiState = never, FormType extends Re
47
47
  }, never, StateKeys>;
48
48
  export type ActionWidget<StateKeys extends UiState = never, FormType extends Record<string, any> = any, Props extends Record<string, any> = any> = SomeSuffixable<BaseWidget<StateKeys, FormType, Props> & {
49
49
  kind: 'action';
50
+ actionType?: 'button' | 'submit';
50
51
  label?: ReactiveWidgetPropertyValue<Localizable, FormType>;
51
52
  disabled?: boolean | {
52
53
  when: ReactiveExpression;
package/lib/shared.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NonFunctionWidget } from './form-widget';
1
+ import { ActionWidget, NonFunctionWidget } from './form-widget';
2
2
  import { I18nTranslator } from './i18n';
3
3
  import { OVERRIDE_WIDGET_PROP } from './store/actions';
4
4
  import { ImmutableRecord } from './utils/types';
@@ -58,14 +58,13 @@ export type FunctionWidgetParams<FormType> = {
58
58
  /**
59
59
  * Defines when widget validation should run.
60
60
  * - `'eager'` validates on `'change'`, `'blur'` and `'submit'`.
61
- * - When using 'submit', validation triggers when the 'submit' event is emitted. When that happens, all widgets are also _touched_ first.
61
+ * - When using 'submit', validation triggers when the submit button is clicked or Enter is pressed. When that happens, all widgets are also _touched_ first.
62
62
  * ```ts
63
63
  * {
64
- * widget: 'button',
65
- * label: 'Create User',
66
- * on: {
67
- * click: 'submit',
68
- * }
64
+ * type: 'button',
65
+ * kind: 'action',
66
+ * actionType: 'submit',
67
+ * label: 'Create User'
69
68
  * }
70
69
  * ```
71
70
  */
@@ -93,6 +92,7 @@ export type FormEvent<T = any> = {
93
92
  /** Actions that the client can execute to interact with the forms engine from the application scope */
94
93
  callback: (action: EventHandlerCallback) => void;
95
94
  };
95
+ export type FormSubmitEvent<T = any> = Omit<FormEvent<T>, 'name' | 'detail'>;
96
96
  /**
97
97
  * Control adapter templateData
98
98
  */
@@ -150,6 +150,7 @@ export type DisplayWidgetTemplateData = {
150
150
  * Action widget adapter templateData
151
151
  */
152
152
  export type ActionWidgetTemplateData = {
153
+ actionType?: ActionWidget['actionType'];
153
154
  lang?: string;
154
155
  deps?: Record<string, unknown>;
155
156
  label?: string;
@@ -40,6 +40,10 @@ export type State = {
40
40
  * for contextual validations that cannot be expressed declaratively.
41
41
  */
42
42
  injectedValidations: Record<DotPath, ValidationStatus>;
43
+ /**
44
+ * caclulated each time the validation kicks-in. It atkes into account both `validations` and `injectedValidations`.
45
+ */
46
+ isFormValid: boolean;
43
47
  /**
44
48
  * Tracks widgets with state expressions.
45
49
  * When data changes, these widgets are updated and their flags recalculated.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemui/core",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
4
4
  "type": "module",
5
5
  "main": "./index.umd.cjs",
6
6
  "module": "./index.js",