@golemui/core 1.4.0 → 1.5.0-rc.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/index.umd.cjs CHANGED
@@ -1,8 +1,8 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const W=require("rxjs");require("@standard-schema/spec");function Ct(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function It(e){return e.issues===void 0}var yr=class{value;constructor(e){this.value=e}map(e){return j(e(this.value))}isOk(){return!0}},vr=class jt{issues;constructor(t){this.issues=t}map(t){return new jt(this.issues)}isOk(){return!1}};function j(e){return new yr(e)}function E(e){return new vr(e)}function kt(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t.length===0?String(r):`${t}.${r}`,"")}function ut(e){return e.map(t=>t.path.length===0?t.message:`${kt(t.path)}: ${t.message}`).join("; ")}var C=class Pe{decodeFn;constructor(t){this.decodeFn=t}parse(t){let r=this.decode(t);if(r.isOk())return r.value;{let n=r;throw Error(ut(n.issues),{cause:n.issues})}}decode(t){return this.decodeFn(t)}"~standard"={version:1,vendor:"ts.data.json",validate:t=>{let r=this.decode(t);return r.isOk()?{value:r.value}:{issues:r.issues.map(n=>({message:n.message,path:n.path.length>0?n.path.map(o=>({key:o})):void 0}))}}};decodePromise(t){return new Promise((r,n)=>{let o=this.decode(t);if(o.isOk())return r(o.value);{let s=o;return n(Error(ut(s.issues),{cause:s.issues}))}})}map(t){return new Pe(r=>{let n=this.decodeFn(r);return n.isOk()?j(t(n.value)):E(n.issues)})}flatMap(t){return new Pe(r=>{let n=this.decodeFn(r);return n.isOk()?t(n.value).decode(r):E(n.issues)})}},z=(e,t)=>[{message:`${JSON.stringify(e)} is not a valid ${t}`,path:[]}],_e=(e,t)=>e.map(r=>({...r,path:[t,...r.path]}));function Le(e){return new C(t=>{if(t instanceof Array){let r=[],n=[];for(let o=0;o<t.length;o++){let s=e.decode(t[o]);s.isOk()?r.push(s.value):n.push(..._e(s.issues,o))}return n.length>0?E(n):j(r)}else return E(z(t,"array"))})}function $r(){return new C(e=>typeof e=="boolean"?j(e):E(z(e,"boolean")))}function Sr(e,t){return new C(r=>{if(typeof r!="object"||!r)return E(z(r,"object"));let n=r[e];return Object.prototype.hasOwnProperty.call(t,n)?t[n].decode(r):E([{message:`"${e}" must be one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(", ")}, but got ${JSON.stringify(n)}`,path:[e]}])})}function Pt(e){return new C(t=>e().decode(t))}function K(e){return new C(t=>t===e?j(e):E([{message:`${JSON.stringify(t)} is not exactly ${JSON.stringify(e)}`,path:[]}]))}function ye(){return new C(e=>typeof e=="number"?j(e):E(z(e,"number")))}function te(e){return new C(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let s,i=e[o];s=i instanceof C?i.decode(t[o]):i.decoder.decode(t[i.fromKey]),s.isOk()?r[o]=s.value:n.push(..._e(s.issues,o))}return n.length>0?E(n):j(r)}else return E(z(t,"object"))})}function x(e){return new C(t=>{let r=[];for(let n=0;n<e.length;n++){let o=e[n].decode(t);if(o.isOk())return o;r.push(o.issues)}return E([{message:`no alternative matched (tried ${e.length})`,path:[]},...Ar(r)])})}function Ar(e){let t=new Map;for(let r of e)for(let n of r){let o=JSON.stringify(n.path),s=t.get(o);s?s.messages.includes(n.message)||s.messages.push(n.message):t.set(o,{path:n.path,messages:[n.message]})}return Array.from(t.values()).map(({path:r,messages:n})=>({message:n.join(" or "),path:r}))}function y(e){return new C(t=>t===void 0?j(void 0):e.decode(t))}function Er(e){return new C(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let s=e.decode(t[o]);s.isOk()?r[o]=s.value:n.push(..._e(s.issues,o))}return n.length>0?E(n):j(r)}else return E(z(t,"object"))})}function w(){return new C(e=>typeof e=="string"?j(e):E(z(e,"string")))}function b(){return new C(e=>j(e))}function re(e){return new C(t=>{if(typeof t!="object"||t===null)return E([{message:`Expected object literal, got "${typeof t}"`,path:[]}]);const r={};for(const[n,o]of Object.entries(e)){const s=o.decoder.decode(t[n]);if(!s.isOk())return E(s.issues.map(i=>({message:i.message,path:[n,...i.path]})));if(r[n]=s.value,o.suffixed){for(const[i,u]of Object.entries(t))if(i.startsWith(n+".")){const d=o.decoder.decode(u);if(!d.isOk())return E(d.issues.map(l=>({message:l.message,path:[i,...l.path]})));r[i]=d.value}}}return j(r)})}const Ft=()=>crypto.randomUUID().slice(0,8),wr=e=>typeof e!="function"&&e.kind==="display",de=e=>typeof e!="function"&&e.kind==="action",P=e=>typeof e!="function"&&e.kind==="input",H=e=>typeof e!="function"&&e.kind==="layout",T=e=>typeof e=="function",Or=te({in:Le(w())}),Ue=te({when:w()}),ve=x([Or,Ue]),Cr=te({from:Le(w())}),$e=x([Cr,Ue]),Fe=x([$r(),Ue]),Ir=new C(e=>{const t=typeof e;return t==="function"?j(e):E([{message:`Expected a function, got '${t}'`,path:[]}])}),N=e=>x([e,Ir]),be=re({load:{suffixed:!0,decoder:N(y(w()))},click:{suffixed:!0,decoder:N(y(w()))},change:{suffixed:!0,decoder:N(y(w()))},filter:{suffixed:!0,decoder:N(y(w()))},blur:{suffixed:!0,decoder:N(y(w()))}}),jr=te({key:w(),default:y(w()),params:y(b())}),Dt=x([w(),jr]),He=y(w()),kr=re({kind:{decoder:K("display")},uid:{decoder:He},type:{decoder:w()},size:{suffixed:!0,decoder:y(ye())},include:{decoder:y(ve)},exclude:{decoder:y($e)},props:{decoder:y(b())}}),Pr=re({kind:{decoder:K("action")},uid:{decoder:He},type:{decoder:w()},actionType:{decoder:y(x([K("button"),K("submit")]))},size:{suffixed:!0,decoder:y(ye())},include:{decoder:y(ve)},exclude:{decoder:y($e)},label:{suffixed:!0,decoder:N(y(Dt))},disabled:{suffixed:!0,decoder:y(Fe)},on:{decoder:y(be)},props:{decoder:y(b())}}),Fr=new C(e=>{const t=typeof e;if(t==="function"){const r=e,n=r({$form:{},errors:void 0,touched:void 0,translate:void 0});return r.uid=r.uid||n.uid||Ft(),r.type=n.type,r.path=n.path,j(r)}else return E([{message:`Expected a function, got '${t}'`,path:[]}])}),Dr=re({kind:{decoder:K("input")},uid:{decoder:y(w())},type:{decoder:w()},size:{suffixed:!0,decoder:y(ye())},include:{decoder:y(ve)},exclude:{decoder:y($e)},disabled:{suffixed:!0,decoder:y(Fe)},readonly:{suffixed:!0,decoder:y(Fe)},on:{decoder:y(be)},props:{decoder:y(b())},label:{suffixed:!0,decoder:N(y(Dt))},path:{decoder:w()},defaultValue:{decoder:y(b())},validator:{suffixed:!0,decoder:N(y(b()))}}).map(e=>{const t={...e};if(e.uid||(t.uid=`${e.path}-${e.type}`),e.type==="repeater"){const r=e.props;t.props={...r,template:ze.parse(r.template)}}return t}),Wr=Pt(()=>{const e=Sr("kind",{input:Dr,layout:ze,display:kr,action:Pr});return new C(t=>typeof t=="function"?Fr.decode(t):e.decode(t))}),ze=re({kind:{decoder:K("layout")},uid:{decoder:He},type:{decoder:w()},size:{suffixed:!0,decoder:y(ye())},include:{decoder:y(ve)},exclude:{decoder:y($e)},props:{decoder:y(b())},on:{decoder:y(be)},children:{decoder:Le(Wr)}}),U=class U{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(!U.sharedCache.has(r)){const n=r().catch(o=>(U.sharedCache.delete(r),Promise.reject(o)));U.sharedCache.set(r,n)}return U.sharedCache.get(r)}};U.sharedCache=new Map;let De=U;function Tr(e){We(e,"#0")}function We(e,t){if(!T(e)&&(e.uid||(e.uid=t),H(e)&&e.children.forEach((r,n)=>{We(r,`${t}.${n}`)}),P(e)&&e.type==="repeater")){const r=e.props?.template;r&&We(r,`${t}.t`)}}function Nr(e){return{...e,form:{uid:"",type:"flex",kind:"layout",children:e.form}}}const Wt=te({states:y(Er(w())),form:Pt(()=>ze)}).map(e=>(Tr(e.form),e)),Tt=e=>({formName:"",formDef:Wt.parse({form:{kind:"layout",type:"flex",children:[]}}),flatForm:{},resolvedSources:{},currentStates:[],calculatedWidgets:{},validations:{},touchedControls:{},injectedValidations:{},isFormValid:!0,widgetFlags:{},repeaterItemScopes:{},widgetPropOverrides:{},data:{},meta:{},formHealth:{status:"ok"},touched:!1,allControlsValidated:!1,lang:e}),Vr={submit:"formSubmit",health:"formHealth",event:"formEvent"},Rr=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 Nt=(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))}}},k={calculateCurrentStateError:10,calculateWidgetFlagsError:11,calculateWidgetPropsError:12,initializeParseError:20,initializeUidCollisionError:21,initializeUnknownError:22,initializeMalformedFormShapeError:23,widgetCouldNotBeLoaded:30,resolveStringInterpolationError:40},_r=e=>{throw new Error(`Unhandled case: ${JSON.stringify(e)}`)},_=(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)},Lr=(e,t)=>{if(t==="")return!1;let r=e;for(const n of t.split(".")){if(r===null||typeof r!="object")return!1;if(Array.isArray(r)){const o=parseInt(n,10);if(!(o in r))return!1;r=r[o]}else{if(!(n in r))return!1;r=r[n]}}return!0},Te=(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 i=0;i<n.length-1;i++){const u=n[i],d=n[i+1];(o[u]==null||typeof o[u]!="object")&&(o[u]=Rt(d)?[]:{}),o=o[u]}const s=n[n.length-1];return o[s]=r,e},Vt=(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("."),o=ct(e);let s=o;for(let i=0;i<n.length-1;i++){const u=n[i],d=n[i+1];s[u]==null||typeof s[u]!="object"?s[u]=Rt(d)?[]:{}:s[u]=ct(s[u]),s=s[u]}return s[n[n.length-1]]=r,o},ct=e=>Array.isArray(e)?e.slice():{...e},Ur=(e,t)=>{if(t==="")return e;const r=t.split("."),n=[e];for(let i=0;i<r.length-1;i++){const u=n[i];if(u==null||typeof u!="object")return e;const d=r[i],l=Array.isArray(u)?u[parseInt(d,10)]:u[d];if(l==null||typeof l!="object")return e;n.push(l)}const o=n[n.length-1],s=r[r.length-1];Array.isArray(o)?o.splice(parseInt(s,10),1):delete o[s];for(let i=n.length-1;i>=1;i--){const u=n[i];if(Array.isArray(u)||!br(u))break;const d=n[i-1],l=r[i-1];if(Array.isArray(d))break;delete d[l]}return e};function Rt(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}function br(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}function q(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>q(r));const t={};for(const r of Object.keys(e))t[r]=q(e[r]);return t}function Be(e){return e.flatMap(t=>[t,...H(t)?Be(t.children):[]])}function Se(e){return Object.entries(e.validations).sort(([n],[o])=>n.split(".").length-o.split(".").length).reduce((n,[o,s])=>(s!==null&&(n.$formIsInvalid=!0,Te(n.$errors,o,[...s])),n),{$formIsInvalid:!1,$errors:{}})}function R(e){if(e!==void 0)return P(e)||T(e)?e.path:void 0}function Ie(e){const t=q(e.data);for(const[r,n]of Object.entries(e.widgetFlags))if(n.hidden===!0){const o=R(e.resolvedSources[r]);o!==void 0&&Ur(t,o)}return t}const Ae=e=>!T(e)&&e.type==="repeater",ne=e=>[...e.matchAll(/\[(\d+)\]/g)].map(t=>parseInt(t[1],10));function Ne(e,t){const r={resolvedSources:{},repeaterItemScopes:{}};for(const n of Object.values(e))r.resolvedSources[n.uid]=n,Ae(n)&&Mt(n,[],t,r);return r}function Mt(e,t,r,n){const o=_(r,e.path);if(!Array.isArray(o))return;const s=Be([e.props.template]);o.forEach((i,u)=>{const d=[...t,u],l={itemPath:`${e.path}.${u}`,index:u};for(const a of s){const p=Ge(a,d);n.resolvedSources[p.uid]=p,n.repeaterItemScopes[p.uid]=l;const g=Hr(a,p,d,r,i,u);g&&Mt(g,d,r,n)}})}function Hr(e,t,r,n,o,s){if(Ae(t))return t;if(!T(e))return;const i=e({$form:n,$item:o,$index:s,errors:void 0,touched:void 0,translate:void 0});if(i.type!=="repeater")return;const u={...i,uid:e.uid};return Ge(u,r)}function Ge(e,t){const r=Ke(e.uid,t);if(T(e)){const n=o=>e(o);return n.uid=r,n.type=e.type,e.path!==void 0&&(n.path=dt(e.path,t)),n}return P(e)?{...e,uid:r,path:dt(e.path,t)}:{...e,uid:r}}function Ke(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 dt(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((s,i,u)=>u===0?i:`${s}.${t[u-1]}${i}`)}function zr(e,t){let r=0;return e.replace(/\.items(\??)\./g,(n,o)=>{const s=t[r++];return s===void 0?n:`.${s}${o}.`})}const lt=["include","exclude","disabled","readonly"];function Br(e,t){if(!lt.some(o=>at(e[o])))return e;const n={...e};for(const o of lt){const s=n[o];at(s)&&(n[o]={...s,when:zr(s.when,t)})}return n}function at(e){return e!==null&&typeof e=="object"&&"when"in e&&typeof e.when=="string"}const Gr=50,Kr=e=>{let t=e.data,r=Ne(e.flatForm,t);for(let n=0;n<Gr;n++){let o=!1;for(const s of Object.values(r.resolvedSources))!P(s)||Lr(t,s.path)||(t=Vt(t,s.path,q(s.defaultValue)),s.defaultValue!==void 0&&(o=!0));if(!o)break;r=Ne(e.flatForm,t)}return{...e,data:t,...r}},xe=32;let Ve,h,m,v=e=>(h=0,m=e,v.newline=!1,e=S(),m[h]?B():e||""),B=(e="Unexpected token",t=h,r=m.slice(0,t).split(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("rxjs");require("@standard-schema/spec");function Ct(e,t){const r=e["~standard"].validate(t);if(r instanceof Promise)throw new TypeError("Schema validation must be synchronous");return r}function It(e){return e.issues===void 0}var gr=class{value;constructor(e){this.value=e}map(e){return j(e(this.value))}isOk(){return!0}},yr=class jt{issues;constructor(t){this.issues=t}map(t){return new jt(this.issues)}isOk(){return!1}};function j(e){return new gr(e)}function w(e){return new yr(e)}function kt(e){return e.reduce((t,r)=>typeof r=="number"?`${t}[${r}]`:t.length===0?String(r):`${t}.${r}`,"")}function ut(e){return e.map(t=>t.path.length===0?t.message:`${kt(t.path)}: ${t.message}`).join("; ")}var C=class Pe{decodeFn;constructor(t){this.decodeFn=t}parse(t){let r=this.decode(t);if(r.isOk())return r.value;{let n=r;throw Error(ut(n.issues),{cause:n.issues})}}decode(t){return this.decodeFn(t)}"~standard"={version:1,vendor:"ts.data.json",validate:t=>{let r=this.decode(t);return r.isOk()?{value:r.value}:{issues:r.issues.map(n=>({message:n.message,path:n.path.length>0?n.path.map(o=>({key:o})):void 0}))}}};decodePromise(t){return new Promise((r,n)=>{let o=this.decode(t);if(o.isOk())return r(o.value);{let s=o;return n(Error(ut(s.issues),{cause:s.issues}))}})}map(t){return new Pe(r=>{let n=this.decodeFn(r);return n.isOk()?j(t(n.value)):w(n.issues)})}flatMap(t){return new Pe(r=>{let n=this.decodeFn(r);return n.isOk()?t(n.value).decode(r):w(n.issues)})}},z=(e,t)=>[{message:`${JSON.stringify(e)} is not a valid ${t}`,path:[]}],Me=(e,t)=>e.map(r=>({...r,path:[t,...r.path]}));function _e(e){return new C(t=>{if(t instanceof Array){let r=[],n=[];for(let o=0;o<t.length;o++){let s=e.decode(t[o]);s.isOk()?r.push(s.value):n.push(...Me(s.issues,o))}return n.length>0?w(n):j(r)}else return w(z(t,"array"))})}function vr(){return new C(e=>typeof e=="boolean"?j(e):w(z(e,"boolean")))}function $r(e,t){return new C(r=>{if(typeof r!="object"||!r)return w(z(r,"object"));let n=r[e];return Object.prototype.hasOwnProperty.call(t,n)?t[n].decode(r):w([{message:`"${e}" must be one of ${Object.keys(t).map(o=>JSON.stringify(o)).join(", ")}, but got ${JSON.stringify(n)}`,path:[e]}])})}function Ft(e){return new C(t=>e().decode(t))}function K(e){return new C(t=>t===e?j(e):w([{message:`${JSON.stringify(t)} is not exactly ${JSON.stringify(e)}`,path:[]}]))}function ve(){return new C(e=>typeof e=="number"?j(e):w(z(e,"number")))}function te(e){return new C(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in e)if(Object.prototype.hasOwnProperty.call(e,o)){let s,i=e[o];s=i instanceof C?i.decode(t[o]):i.decoder.decode(t[i.fromKey]),s.isOk()?r[o]=s.value:n.push(...Me(s.issues,o))}return n.length>0?w(n):j(r)}else return w(z(t,"object"))})}function x(e){return new C(t=>{let r=[];for(let n=0;n<e.length;n++){let o=e[n].decode(t);if(o.isOk())return o;r.push(o.issues)}return w([{message:`no alternative matched (tried ${e.length})`,path:[]},...Sr(r)])})}function Sr(e){let t=new Map;for(let r of e)for(let n of r){let o=JSON.stringify(n.path),s=t.get(o);s?s.messages.includes(n.message)||s.messages.push(n.message):t.set(o,{path:n.path,messages:[n.message]})}return Array.from(t.values()).map(({path:r,messages:n})=>({message:n.join(" or "),path:r}))}function y(e){return new C(t=>t===void 0?j(void 0):e.decode(t))}function Ar(e){return new C(t=>{if(typeof t=="object"&&t){let r={},n=[];for(let o in t)if(Object.prototype.hasOwnProperty.call(t,o)){let s=e.decode(t[o]);s.isOk()?r[o]=s.value:n.push(...Me(s.issues,o))}return n.length>0?w(n):j(r)}else return w(z(t,"object"))})}function E(){return new C(e=>typeof e=="string"?j(e):w(z(e,"string")))}function b(){return new C(e=>j(e))}function re(e){return new C(t=>{if(typeof t!="object"||t===null)return w([{message:`Expected object literal, got "${typeof t}"`,path:[]}]);const r={};for(const[n,o]of Object.entries(e)){const s=o.decoder.decode(t[n]);if(!s.isOk())return w(s.issues.map(i=>({message:i.message,path:[n,...i.path]})));if(r[n]=s.value,o.suffixed){for(const[i,u]of Object.entries(t))if(i.startsWith(n+".")){const d=o.decoder.decode(u);if(!d.isOk())return w(d.issues.map(l=>({message:l.message,path:[i,...l.path]})));r[i]=d.value}}}return j(r)})}const wr=e=>typeof e!="function"&&e.kind==="display",de=e=>typeof e!="function"&&e.kind==="action",F=e=>typeof e!="function"&&e.kind==="input",H=e=>typeof e!="function"&&e.kind==="layout",N=e=>typeof e=="function",Er=te({in:_e(E())}),Ue=te({when:E()}),$e=x([Er,Ue]),Or=te({from:_e(E())}),Se=x([Or,Ue]),We=x([vr(),Ue]),Cr=new C(e=>{const t=typeof e;return t==="function"?j(e):w([{message:`Expected a function, got '${t}'`,path:[]}])}),V=e=>x([e,Cr]),be=re({load:{suffixed:!0,decoder:V(y(E()))},click:{suffixed:!0,decoder:V(y(E()))},change:{suffixed:!0,decoder:V(y(E()))},filter:{suffixed:!0,decoder:V(y(E()))},blur:{suffixed:!0,decoder:V(y(E()))}}),Ir=te({key:E(),default:y(E()),params:y(b())}),Pt=x([E(),Ir]),He=y(E()),jr=re({kind:{decoder:K("display")},uid:{decoder:He},type:{decoder:E()},size:{suffixed:!0,decoder:y(ve())},include:{decoder:y($e)},exclude:{decoder:y(Se)},props:{decoder:y(b())}}),kr=re({kind:{decoder:K("action")},uid:{decoder:He},type:{decoder:E()},actionType:{decoder:y(x([K("button"),K("submit")]))},size:{suffixed:!0,decoder:y(ve())},include:{decoder:y($e)},exclude:{decoder:y(Se)},label:{suffixed:!0,decoder:V(y(Pt))},disabled:{suffixed:!0,decoder:y(We)},on:{decoder:y(be)},props:{decoder:y(b())}}),Fr=new C(e=>{const t=typeof e;if(t==="function"){const r=e,n=r({$form:{},errors:void 0,touched:void 0,translate:void 0});return r.uid=r.uid||n.uid,r.type=n.type,r.path=n.path,j(r)}else return w([{message:`Expected a function, got '${t}'`,path:[]}])}),Pr=re({kind:{decoder:K("input")},uid:{decoder:y(E())},type:{decoder:E()},size:{suffixed:!0,decoder:y(ve())},include:{decoder:y($e)},exclude:{decoder:y(Se)},disabled:{suffixed:!0,decoder:y(We)},readonly:{suffixed:!0,decoder:y(We)},on:{decoder:y(be)},props:{decoder:y(b())},label:{suffixed:!0,decoder:V(y(Pt))},path:{decoder:E()},defaultValue:{decoder:y(b())},validator:{suffixed:!0,decoder:V(y(b()))}}).map(e=>{const t={...e};if(e.uid||(t.uid=`${e.path}-${e.type}`),e.type==="repeater"){const r=e.props;t.props={...r,template:ze.parse(r.template)}}return t}),Wr=Ft(()=>{const e=$r("kind",{input:Pr,layout:ze,display:jr,action:kr});return new C(t=>typeof t=="function"?Fr.decode(t):e.decode(t))}),ze=re({kind:{decoder:K("layout")},uid:{decoder:He},type:{decoder:E()},size:{suffixed:!0,decoder:y(ve())},include:{decoder:y($e)},exclude:{decoder:y(Se)},props:{decoder:y(b())},on:{decoder:y(be)},children:{decoder:_e(Wr)}}),D=class D{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(!D.sharedCache.has(r)){const n=r().catch(o=>(D.sharedCache.delete(r),Promise.reject(o)));D.sharedCache.set(r,n)}return D.sharedCache.get(r)}async preloadWidgets(t){const r=t??Object.keys(this.widgetLoaders);await Promise.all(r.map(async n=>{const o=await this.loadWidget(n);D.resolvedCache.set(this.widgetLoaders[n],o)}))}getIfLoaded(t){const r=this.widgetLoaders[t];if(r)return D.resolvedCache.get(r)}};D.sharedCache=new Map,D.resolvedCache=new Map;let le=D;async function Dr(e){const t=new le;t.setWidgetLoaders(e.widgetLoaders),await t.preloadWidgets()}function Tr(e){De(e,"#0")}function De(e,t){if(N(e)){e.uid||(e.uid=`${t}.f`);return}if(e.uid||(e.uid=t),H(e)&&e.children.forEach((r,n)=>{De(r,`${t}.${n}`)}),F(e)&&e.type==="repeater"){const r=e.props?.template;r&&De(r,`${t}.t`)}}function Nr(e){return{...e,form:{uid:"",type:"flex",kind:"layout",children:e.form}}}const Wt=te({states:y(Ar(E())),form:Ft(()=>ze)}).map(e=>(Tr(e.form),e)),Dt=e=>({formName:"",formDef:Wt.parse({form:{kind:"layout",type:"flex",children:[]}}),flatForm:{},resolvedSources:{},currentStates:[],calculatedWidgets:{},validations:{},touchedControls:{},injectedValidations:{},isFormValid:!0,widgetFlags:{},repeaterItemScopes:{},widgetPropOverrides:{},data:{},meta:{},formHealth:{status:"ok"},touched:!1,allControlsValidated:!1,lang:e}),Vr={submit:"formSubmit",health:"formHealth",event:"formEvent"},Rr=e=>!(typeof e!="object"||e===null||typeof e.key!="string");function Lr(e){const t=new Intl.Locale(e).maximize().script;return["Arab","Hebr","Thaa","Syrc","Tfng","Adlm","Rohg"].includes(t||"")?"rtl":"ltr"}const Tt=(e=typeof navigator<"u"&&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))}}},k={calculateCurrentStateError:10,calculateWidgetFlagsError:11,calculateWidgetPropsError:12,initializeParseError:20,initializeUidCollisionError:21,initializeUnknownError:22,initializeMalformedFormShapeError:23,widgetCouldNotBeLoaded:30,resolveStringInterpolationError:40},Mr=e=>{throw new Error(`Unhandled case: ${JSON.stringify(e)}`)},_=(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)},_r=(e,t)=>{if(t==="")return!1;let r=e;for(const n of t.split(".")){if(r===null||typeof r!="object")return!1;if(Array.isArray(r)){const o=parseInt(n,10);if(!(o in r))return!1;r=r[o]}else{if(!(n in r))return!1;r=r[n]}}return!0},Te=(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 i=0;i<n.length-1;i++){const u=n[i],d=n[i+1];(o[u]==null||typeof o[u]!="object")&&(o[u]=Vt(d)?[]:{}),o=o[u]}const s=n[n.length-1];return o[s]=r,e},Nt=(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("."),o=ct(e);let s=o;for(let i=0;i<n.length-1;i++){const u=n[i],d=n[i+1];s[u]==null||typeof s[u]!="object"?s[u]=Vt(d)?[]:{}:s[u]=ct(s[u]),s=s[u]}return s[n[n.length-1]]=r,o},ct=e=>Array.isArray(e)?e.slice():{...e},Ur=(e,t)=>{if(t==="")return e;const r=t.split("."),n=[e];for(let i=0;i<r.length-1;i++){const u=n[i];if(u==null||typeof u!="object")return e;const d=r[i],l=Array.isArray(u)?u[parseInt(d,10)]:u[d];if(l==null||typeof l!="object")return e;n.push(l)}const o=n[n.length-1],s=r[r.length-1];Array.isArray(o)?o.splice(parseInt(s,10),1):delete o[s];for(let i=n.length-1;i>=1;i--){const u=n[i];if(Array.isArray(u)||!br(u))break;const d=n[i-1],l=r[i-1];if(Array.isArray(d))break;delete d[l]}return e};function Vt(e){const t=Number(e);return Number.isInteger(t)&&t>=0&&t.toString()===e}function br(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0}function q(e){if(e===null||typeof e!="object")return e;if(Array.isArray(e))return e.map(r=>q(r));const t={};for(const r of Object.keys(e))t[r]=q(e[r]);return t}function Be(e){return e.flatMap(t=>[t,...H(t)?Be(t.children):[]])}function Ae(e){return Object.entries(e.validations).sort(([n],[o])=>n.split(".").length-o.split(".").length).reduce((n,[o,s])=>(s!==null&&(n.$formIsInvalid=!0,Te(n.$errors,o,[...s])),n),{$formIsInvalid:!1,$errors:{}})}function L(e){if(e!==void 0)return F(e)||N(e)?e.path:void 0}function je(e){const t=q(e.data);for(const[r,n]of Object.entries(e.widgetFlags))if(n.hidden===!0){const o=L(e.resolvedSources[r]);o!==void 0&&Ur(t,o)}return t}const we=e=>!N(e)&&e.type==="repeater",ne=e=>[...e.matchAll(/\[(\d+)\]/g)].map(t=>parseInt(t[1],10));function Ne(e,t){const r={resolvedSources:{},repeaterItemScopes:{}};for(const n of Object.values(e))r.resolvedSources[n.uid]=n,we(n)&&Rt(n,[],t,r);return r}function Rt(e,t,r,n){const o=_(r,e.path);if(!Array.isArray(o))return;const s=Be([e.props.template]);o.forEach((i,u)=>{const d=[...t,u],l={itemPath:`${e.path}.${u}`,index:u};for(const a of s){const p=Ge(a,d);n.resolvedSources[p.uid]=p,n.repeaterItemScopes[p.uid]=l;const g=Hr(a,p,d,r,i,u);g&&Rt(g,d,r,n)}})}function Hr(e,t,r,n,o,s){if(we(t))return t;if(!N(e))return;const i=e({$form:n,$item:o,$index:s,errors:void 0,touched:void 0,translate:void 0});if(i.type!=="repeater")return;const u={...i,uid:e.uid};return Ge(u,r)}function Ge(e,t){const r=Ke(e.uid,t);if(N(e)){const n=o=>e(o);return n.uid=r,n.type=e.type,e.path!==void 0&&(n.path=dt(e.path,t)),n}return F(e)?{...e,uid:r,path:dt(e.path,t)}:{...e,uid:r}}function Ke(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 dt(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((s,i,u)=>u===0?i:`${s}.${t[u-1]}${i}`)}function zr(e,t){let r=0;return e.replace(/\.items(\??)\./g,(n,o)=>{const s=t[r++];return s===void 0?n:`.${s}${o}.`})}const lt=["include","exclude","disabled","readonly"];function Br(e,t){if(!lt.some(o=>at(e[o])))return e;const n={...e};for(const o of lt){const s=n[o];at(s)&&(n[o]={...s,when:zr(s.when,t)})}return n}function at(e){return e!==null&&typeof e=="object"&&"when"in e&&typeof e.when=="string"}const Gr=50,Kr=e=>{let t=e.data,r=Ne(e.flatForm,t);for(let n=0;n<Gr;n++){let o=!1;for(const s of Object.values(r.resolvedSources))!F(s)||_r(t,s.path)||(t=Nt(t,s.path,q(s.defaultValue)),s.defaultValue!==void 0&&(o=!0));if(!o)break;r=Ne(e.flatForm,t)}return{...e,data:t,...r}},xe=32;let Ve,h,m,v=e=>(h=0,m=e,v.newline=!1,e=S(),m[h]?B():e||""),B=(e="Unexpected token",t=h,r=m.slice(0,t).split(`
2
2
  `),n=r.pop(),o=m.slice(Math.max(0,t-40),t),s="̭",i=(m[t]||" ")+s,u=m.slice(t+1,t+20))=>{throw SyntaxError(`${e} at ${r.length+1}:${n.length+1}
3
3
  ${m[t-41]!==`
4
- `,""+o}${i}${u}`)},_t=(e,t=h)=>(Array.isArray(e)&&(e.loc=t),e),X=(e,t=h,r)=>{for(;r=e(m.charCodeAt(h));)h+=r;return m.slice(t,h)},O=(e=1)=>m[h+=e],Re=e=>h=e,S=(e=0,t)=>{let r,n,o,s,i;for(t&&v.asi&&(v.newline=!1);(r=v.space())&&(i=v.newline,1)&&r!==t&&(o=(n&&r===91&&Ve&&v.asi?.(n,e,S)||null)??((s=D[r])&&s(n,e))??(n&&i&&v.asi?.(n,e,S))??(!n&&X(v.id)));)n=o;return t&&(r==t?(h++,t===125&&v.asi&&(v.newline=!0)):B("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),n},M=(e,t=h)=>{for(Ve=!1;(e=m.charCodeAt(h))<=xe;)v.asi&&e===10&&(v.newline=Ve=!0),h++;return e},xr=(e=h)=>{for(;m.charCodeAt(e)<=xe;)e++;return m.charCodeAt(e)};v.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 Xr=(e,t=e.length)=>m.substr(h,t)===e&&!v.id(m.charCodeAt(h+t)),D=[],ft={},F=(e,t=xe,r,n=e.charCodeAt(0),o=e.length,s=D[n],i=e.toUpperCase()!==e,u,d)=>(t=ft[e]=!s&&ft[e]||t,D[n]=(l,a,p,g=h)=>(u=p,(p?e==p:(o<2||e.charCodeAt(1)===m.charCodeAt(h+1)&&(o<3||m.substr(h,o)==e))&&(!i||!v.id(m.charCodeAt(h+o)))&&(u=p=e))&&a<t&&(h+=o,(d=r(l))?_t(d,g):(h=g,u=0,!i&&!s&&!l&&B()),d)||s?.(l,a,u))),$=(e,t,r=!1)=>F(e,t,n=>n&&(o=>o&&[e,n,o])(S(t-(r?.5:0)))),L=(e,t,r)=>F(e,t,n=>!n&&(n=S(t-.5))&&[e,n]),oe=(e,t)=>F(e,200,r=>!r&&[,t]),Lt=(e,t,r)=>F(e,t,(n,o)=>(o=S(t-(r?.5:0)),n?.[0]!==e&&(n=[e,n||null]),o?.[0]===e?n.push(...o.slice(1)):n.push(o||null),n)),Xe=(e,t)=>F(e[0],t,r=>!r&&[e,S(0,e.charCodeAt(1))||null]),Ut=(e,t)=>F(e[0],t,r=>r&&[e,r,S(0,e.charCodeAt(1))||null]),se=(e,t,r,n=e.charCodeAt(0),o=e.length,s=D[n],i)=>D[n]=(u,d,l,a=h)=>!u&&(l?e==l:(o<2||m.substr(h,o)==e)&&(l=e))&&d<t&&!v.id(m.charCodeAt(h+o))&&(!v.prop||v.prop(h+o))&&(Re(h+o),(i=r())?_t(i,a):Re(a),i)||s?.(u,d,l);Object.defineProperty(v,"space",{configurable:!0,enumerable:!0,get:()=>M,set:e=>M=e});const Me={},f=(e,t,r=Me[e])=>Me[e]=(...n)=>t(...n)||r?.(...n),c=e=>Array.isArray(e)?e[0]==null?(t=>()=>t)(e[1]):Me[e[0]]?.(...e.slice(1))??B(`Unknown operator: ${e[0]}`,e?.loc):e===void 0?()=>{}:t=>t?.[e],le=46,Z=48,ae=57,Jr=69,Qr=101,qr=43,Zr=45,ce=95,bt=110,Yr=97,en=102,tn=65,rn=70,Ht=e=>e.indexOf("_")<0?e:e.replaceAll("_",""),Je=e=>{let t=Ht(X(r=>r===le&&m.charCodeAt(h+1)!==le||r>=Z&&r<=ae||r===ce||((r===Jr||r===Qr)&&((r=m.charCodeAt(h+1))>=Z&&r<=ae||r===qr||r===Zr)?2:0)));return m.charCodeAt(h)===bt?(O(),[,BigInt(t)]):(e=+t)!=e?B():[,e]},nn={2:e=>e===48||e===49||e===ce,8:e=>e>=48&&e<=55||e===ce,16:e=>e>=Z&&e<=ae||e>=Yr&&e<=en||e>=tn&&e<=rn||e===ce};v.number=null;D[le]=e=>!e&&m.charCodeAt(h+1)!==le&&Je();for(let e=Z;e<=ae;e++)D[e]=t=>t?void 0:Je();D[Z]=e=>{if(e)return;const t=v.number;if(t){for(const[r,n]of Object.entries(t))if(r[0]==="0"&&m[h+1]?.toLowerCase()===r[1]){O(2);const o=Ht(X(nn[n]));return m.charCodeAt(h)===bt?(O(),[,BigInt("0"+r[1]+o)]):[,parseInt(o,n)]}}return Je()};const on=92,pt=34,ht=39,sn={n:`
5
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},zt=e=>(t,r,n="")=>{if(!(t||!v.string?.[String.fromCharCode(e)]))return O(),X(o=>o-e&&(o===on?(n+=sn[m[h+1]]||m[h+1],2):(n+=m[h],1))),m[h]===String.fromCharCode(e)?O():B("Bad string"),[,n]};D[pt]=zt(pt);D[ht]=zt(ht);v.string={'"':!0};const un=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(e=>$(e,un,!0));const Bt=(e,t,r,n)=>typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=c(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="[]"&&e.length===3?(r=c(e[1]),n=c(e[2]),o=>t(r(o),n(o),o)):e[0]==="()"&&e.length===2?Bt(e[1],t):(()=>{throw Error("Invalid assignment target")})(),mt={"=":(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 mt)f(e,(t,r)=>(r=c(r),Bt(t,(n,o,s)=>mt[e](n,o,r(s)))));const cn=30,dn=40,ln=140;L("!",ln);$("||",cn);$("&&",dn);f("!",e=>(e=c(e),t=>!e(t)));f("||",(e,t)=>(e=c(e),t=c(t),r=>e(r)||t(r)));f("&&",(e,t)=>(e=c(e),t=c(t),r=>e(r)&&t(r)));const an=50,fn=60,pn=70,Gt=100,hn=140;$("|",an);$("&",pn);$("^",fn);$(">>",Gt);$("<<",Gt);L("~",hn);f("~",e=>(e=c(e),t=>~e(t)));f("|",(e,t)=>(e=c(e),t=c(t),r=>e(r)|t(r)));f("&",(e,t)=>(e=c(e),t=c(t),r=>e(r)&t(r)));f("^",(e,t)=>(e=c(e),t=c(t),r=>e(r)^t(r)));f(">>",(e,t)=>(e=c(e),t=c(t),r=>e(r)>>t(r)));f("<<",(e,t)=>(e=c(e),t=c(t),r=>e(r)<<t(r)));const Ee=90;$("<",Ee);$(">",Ee);$("<=",Ee);$(">=",Ee);f(">",(e,t)=>(e=c(e),t=c(t),r=>e(r)>t(r)));f("<",(e,t)=>(e=c(e),t=c(t),r=>e(r)<t(r)));f(">=",(e,t)=>(e=c(e),t=c(t),r=>e(r)>=t(r)));f("<=",(e,t)=>(e=c(e),t=c(t),r=>e(r)<=t(r)));const Kt=80;$("==",Kt);$("!=",Kt);f("==",(e,t)=>(e=c(e),t=c(t),r=>e(r)==t(r)));f("!=",(e,t)=>(e=c(e),t=c(t),r=>e(r)!=t(r)));const xt=110,Qe=120,Xt=140;$("+",xt);$("-",xt);$("*",Qe);$("/",Qe);$("%",Qe);L("+",Xt);L("-",Xt);f("+",(e,t)=>t!==void 0?(e=c(e),t=c(t),r=>e(r)+t(r)):(e=c(e),r=>+e(r)));f("-",(e,t)=>t!==void 0?(e=c(e),t=c(t),r=>e(r)-t(r)):(e=c(e),r=>-e(r)));f("*",(e,t)=>(e=c(e),t=c(t),r=>e(r)*t(r)));f("/",(e,t)=>(e=c(e),t=c(t),r=>e(r)/t(r)));f("%",(e,t)=>(e=c(e),t=c(t),r=>e(r)%t(r)));const fe=150;F("++",fe,e=>e?["++",e,null]:["++",S(fe-1)]);F("--",fe,e=>e?["--",e,null]:["--",S(fe-1)]);const qe=(e,t,r,n)=>typeof e=="string"?o=>t(o,e):e[0]==="."?(r=c(e[1]),n=e[2],o=>t(r(o),n)):e[0]==="[]"&&e.length===3?(r=c(e[1]),n=c(e[2]),o=>t(r(o),n(o))):e[0]==="()"&&e.length===2?qe(e[1],t):(()=>{throw Error("Invalid increment target")})();f("++",(e,t)=>qe(e,t===null?(r,n)=>r[n]++:(r,n)=>++r[n]));f("--",(e,t)=>qe(e,t===null?(r,n)=>r[n]--:(r,n)=>--r[n]));const mn=5,gn=10;Lt(",",gn);Lt(";",mn,!0);const Jt=(...e)=>(e=e.map(c),t=>{let r;for(const n of e)r=n(t);return r});f(",",Jt);f(";",Jt);const yn=170;Xe("()",yn);const V=e=>e?.[0]==="_"&&e[1]==="_"||e==="constructor"||e==="prototype",Ze=170;Ut("[]",Ze);$(".",Ze);Ut("()",Ze);const pe=e=>{throw Error(e)};f("[]",(e,t)=>t===void 0?(e=e?e[0]===","?e.slice(1):[e]:[],e=e.map(r=>r==null?(()=>{}):r[0]==="..."?(r=c(r[1]),n=>r(n)):(r=c(r),n=>[r(n)])),r=>e.flatMap(n=>n(r))):(t==null&&pe("Missing index"),e=c(e),t=c(t),r=>{const n=t(r);return V(n)?void 0:e(r)[n]}));f(".",(e,t)=>(e=c(e),t=t[0]?t:t[1],V(t)?()=>{}:r=>e(r)[t]));f("()",(e,t)=>{if(t===void 0)return e==null?pe("Empty ()"):c(e);const r=o=>o?.[0]===","&&o.slice(1).some(s=>s==null||r(s));r(t)&&pe("Empty argument");const n=t?t[0]===","?(t=t.slice(1).map(c),o=>t.map(s=>s(o))):(t=c(t),o=>[t(o)]):()=>[];return Ye(e,(o,s,i)=>o[s](...n(i)))});const G=e=>typeof e=="string"||Array.isArray(e)&&(e[0]==="."||e[0]==="?."||e[0]==="[]"&&e.length===3||e[0]==="?.[]"||e[0]==="()"&&e.length===2&&G(e[1])||e[0]==="{}"),Ye=(e,t,r,n)=>e==null?pe("Empty ()"):e[0]==="()"&&e.length==2?Ye(e[1],t):typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=c(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="?."?(r=c(e[1]),n=e[2],o=>{const s=r(o);return s==null?void 0:t(s,n,o)}):e[0]==="[]"&&e.length===3?(r=c(e[1]),n=c(e[2]),o=>t(r(o),n(o),o)):e[0]==="?.[]"?(r=c(e[1]),n=c(e[2]),o=>{const s=r(o);return s==null?void 0:t(s,n(o),o)}):(e=c(e),o=>t([e(o)],0,o)),J=Ye,vn=32,$n=v.space;v.comment??={"//":`
6
- `,"/*":"*/"};let je;v.space=()=>{je||(je=Object.entries(v.comment).map(([o,s])=>[o,s,o.charCodeAt(0)]));for(var e;e=$n();){for(var t=0,r;r=je[t++];)if(e===r[2]&&m.substr(h,r[0].length)===r[0]){var n=h+r[0].length;if(r[1]===`
7
- `)for(;m.charCodeAt(n)>=vn;)n++;else{for(;m[n]&&m.substr(n,r[1].length)!==r[1];)n++;m[n]&&(n+=r[1].length)}Re(n),e=0;break}if(e)return e}return e};const Qt=80;$("===",Qt);$("!==",Qt);f("===",(e,t)=>(e=c(e),t=c(t),r=>e(r)===t(r)));f("!==",(e,t)=>(e=c(e),t=c(t),r=>e(r)!==t(r)));const Sn=30;$("??",Sn);f("??",(e,t)=>(e=c(e),t=c(t),r=>e(r)??t(r)));const An=130,En=20;$("**",An,!0);$("**=",En,!0);f("**",(e,t)=>(e=c(e),t=c(t),r=>e(r)**t(r)));const wn=e=>{throw Error(e)};f("**=",(e,t)=>(G(e)||wn("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]**=t(o))));const qt=90;$("in",qt);$("of",qt);f("in",(e,t)=>(e=c(e),t=c(t),r=>e(r)in t(r)));const On=20,Cn=100,In=e=>{throw Error(e)};$(">>>",Cn);$(">>>=",On,!0);f(">>>",(e,t)=>(e=c(e),t=c(t),r=>e(r)>>>t(r)));f(">>>=",(e,t)=>(G(e)||In("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]>>>=t(o))));const et=5,jn=10,kn=20,Pn=e=>e[0]?.[0]===","?e[0].slice(1):e,he=(e,t,r)=>{if(typeof e=="string"){r[e]=t;return}const[n,...o]=e,s=Pn(o);if(n==="{}"){const i=[];for(const u of s){if(Array.isArray(u)&&u[0]==="..."){const g={};for(const I in t)i.includes(I)||(g[I]=t[I]);r[u[1]]=g;break}let d,l,a;typeof u=="string"?d=l=u:u[0]==="="?(typeof u[1]=="string"?d=l=u[1]:[,d,l]=u[1],a=u[2]):[,d,l]=u,i.push(d);let p=t[d];p===void 0&&a&&(p=c(a)(r)),he(l,p,r)}}else if(n==="[]"){let i=0;for(const u of s){if(u===null){i++;continue}if(Array.isArray(u)&&u[0]==="..."){r[u[1]]=t.slice(i);break}let d=u,l;Array.isArray(u)&&u[0]==="="&&([,d,l]=u);let a=t[i++];a===void 0&&l&&(a=c(l)(r)),he(d,a,r)}}},Zt=e=>{let t=S(jn-1);return t?.[0]==="in"||t?.[0]==="of"?[t[0],[e,t[1]],t[2]]:t?.[0]===","?[e,...t.slice(1)]:[e,t]};se("let",et+1,()=>Zt("let"));se("const",et+1,()=>Zt("const"));se("var",et,()=>(M(),["var",S(kn)]));const Yt=(...e)=>(e=e.map(t=>{if(typeof t=="string")return r=>{r[t]=void 0};if(t[0]==="="){const[,r,n]=t,o=c(n);return typeof r=="string"?s=>{s[r]=o(s)}:s=>he(r,o(s),s)}return c(t)}),t=>{for(const r of e)r(t)});f("let",Yt);f("const",Yt);f("var",e=>typeof e=="string"?t=>{t[e]=void 0}:()=>{});const tt=20,we=e=>{throw Error(e)};$("||=",tt,!0);$("&&=",tt,!0);$("??=",tt,!0);f("=",(e,t)=>{if(Array.isArray(e)&&(e[0]==="let"||e[0]==="const"||e[0]==="var")){const r=e[1];return t=c(t),typeof r=="string"?n=>{n[r]=t(n)}:n=>he(r,t(n),n)}return G(e)||we("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]=t(o))});f("||=",(e,t)=>(G(e)||we("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]||=t(o))));f("&&=",(e,t)=>(G(e)||we("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]&&=t(o))));f("??=",(e,t)=>(G(e)||we("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]??=t(o))));oe("true",!0);oe("false",!1);oe("null",null);se("undefined",200,()=>[]);oe("NaN",NaN);oe("Infinity",1/0);const ke=20;F("?",ke,(e,t,r)=>e&&(t=S(ke-1))&&X(n=>n===58)&&(r=S(ke-1),["?",e,t,r]));f("?",(e,t,r)=>(e=c(e),t=c(t),r=c(r),n=>e(n)?t(n):r(n)));const Fn=[],Dn=20;$("=>",Dn,!0);f("=>",(e,t)=>{e=e?.[0]==="()"?e[1]:e;const r=e?e[0]===","?e.slice(1):[e]:[];let n=-1,o=null;const s=r[r.length-1];Array.isArray(s)&&s[0]==="..."&&(n=r.length-1,o=s[1],r.length--);const i=t?.[0]==="{}";return t=c(i?["{",t[1]]:t),u=>(...d)=>{const l={};r.forEach((p,g)=>l[p]=d[g]),o&&(l[o]=d.slice(n));const a=new Proxy(l,{get:(p,g)=>g in p?p[g]:u?.[g],set:(p,g,I)=>((g in p?p:u)[g]=I,!0),has:(p,g)=>g in p||(u?g in u:!1)});try{const p=t(a);return i?void 0:p}catch(p){if(p===Fn)return p[0];throw p}}});const Wn=140;L("...",Wn);f("...",e=>(e=c(e),t=>Object.entries(e(t))));const gt=170;F("?.",gt,(e,t)=>{if(!e)return;const r=M();return r===40?(O(),["?.()",e,S(0,41)||null]):r===91?(O(),["?.[]",e,S(0,93)]):(t=S(gt),t?["?.",e,t]:void 0)});f("?.",(e,t)=>(e=c(e),V(t)?()=>{}:r=>e(r)?.[t]));f("?.[]",(e,t)=>(e=c(e),t=c(t),r=>{const n=t(r);return V(n)?void 0:e(r)?.[n]}));f("?.()",(e,t)=>{const r=t?t[0]===","?(t=t.slice(1).map(c),o=>t.map(s=>s(o))):(t=c(t),o=>[t(o)]):()=>[];if(e[0]==="?."){const o=c(e[1]),s=e[2];return V(s)?()=>{}:i=>o(i)?.[s]?.(...r(i))}if(e[0]==="?.[]"){const o=c(e[1]),s=c(e[2]);return i=>{const u=o(i),d=s(i);return V(d)?void 0:u?.[d]?.(...r(i))}}if(e[0]==="."){const o=c(e[1]),s=e[2];return V(s)?()=>{}:i=>o(i)?.[s]?.(...r(i))}if(e[0]==="[]"&&e.length===3){const o=c(e[1]),s=c(e[2]);return i=>{const u=o(i),d=s(i);return V(d)?void 0:u?.[d]?.(...r(i))}}const n=c(e);return o=>n(o)?.(...r(o))});const Y=140;L("typeof",Y);L("void",Y);L("delete",Y);se("new",Y,()=>Xr(".target")?(O(7),["new.target"]):["new",S(Y)]);f("typeof",e=>(e=c(e),t=>typeof e(t)));f("void",e=>(e=c(e),t=>(e(t),void 0)));f("delete",e=>{if(e[0]==="."){const t=c(e[1]),r=e[2];return n=>delete t(n)[r]}if(e[0]==="[]"){const t=c(e[1]),r=c(e[2]);return n=>delete t(n)[r(n)]}return()=>!0});f("new",e=>{const t=c(e?.[0]==="()"?e[1]:e),r=e?.[0]==="()"?e[2]:null,n=r?r[0]===","?(o=>s=>o.map(i=>i(s)))(r.slice(1).map(c)):(o=>s=>[o(s)])(c(r)):()=>[];return o=>new(t(o))(...n(o))});const rt=Symbol("accessor"),nt=20,Tn=40,er=41,tr=123,rr=125,nr=e=>t=>{if(t)return;M();const r=X(v.id);if(!r||(M(),m.charCodeAt(h)!==Tn))return!1;O();const n=S(0,er);return M(),m.charCodeAt(h)!==tr?!1:(O(),[e,r,n,S(0,rr)])};F("get",nt-1,nr("get"));F("set",nt-1,nr("set"));F("(",nt-1,e=>{if(!e||typeof e!="string")return;const t=S(0,er)||null;if(M(),m.charCodeAt(h)===tr)return O(),[":",e,["=>",["()",t],S(0,rr)||null]]});f("get",(e,t)=>(t=t?c(t):()=>{},r=>[[rt,e,{get:function(){const n=Object.create(r||{});return n.this=this,t(n)}}]]));f("set",(e,t,r)=>(r=r?c(r):()=>{},n=>[[rt,e,{set:function(o){const s=Object.create(n||{});s.this=this,s[t]=o,r(s)}}]]));const Nn=20,or=200;v.prop=e=>xr(e)!==58;const Vn=e=>e==null||typeof e=="string"||[":",",","...","get","set"].includes(e[0]);Xe("[]",or);Xe("{}",or);$(":",Nn-1,!0);f("{}",(e,t)=>{if(t!==void 0)return;if(!Vn(e))return c(["{",e]);e=e?e[0]!==","?[e]:e.slice(1):[];const r=e.map(n=>c(typeof n=="string"?[":",n,n]:n));return n=>{const o={},s={};for(const i of r.flatMap(u=>u(n)))if(i[0]===rt){const[,u,d]=i;s[u]={...s[u],...d,configurable:!0,enumerable:!0}}else o[i[0]]=i[1];for(const i in s)Object.defineProperty(o,i,s[i]);return o}});f("{",e=>(e=e?c(e):()=>{},t=>e(Object.create(t))));f(":",(e,t)=>(t=c(t),Array.isArray(e)?(e=c(e),r=>[[e(r),t(r)]]):r=>[[e,t(r)]]));const Rn=170,me=96,Mn=36,_n=123,Ln=92,Un={n:`
8
- `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},yt=()=>{const e=[];for(let t="",r;(r=m.charCodeAt(h))!==me;)r?r===Ln?(O(),t+=Un[m[h]]||m[h],O()):r===Mn&&m.charCodeAt(h+1)===_n?(t&&e.push([,t]),t="",O(2),e.push(S(0,125))):(t+=m[h],O(),r=m.charCodeAt(h),r===me&&t&&e.push([,t])):B("Unterminated template");return O(),e},bn=D[me];D[me]=(e,t)=>e&&t<Rn?v.asi&&v.newline?void 0:(O(),["``",e,...yt()]):e?bn?.(e,t):(O(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(yt()));f("`",(...e)=>(e=e.map(c),t=>e.map(r=>r(t)).join("")));f("``",(e,...t)=>{e=c(e);const r=[],n=[];for(const s of t)Array.isArray(s)&&s[0]===void 0?r.push(s[1]):n.push(c(s));const o=Object.assign([...r],{raw:r});return s=>e(s)(o,...n.map(i=>i(s)))});v.string["'"]=!0;v.number={"0x":16,"0b":2,"0o":8};const Hn={log:(e,t)=>(t?console.log(t,e):console.log(e),e)},zn=2e3,ie=new Map;function ot(e){const t=ie.get(e);if(t!==void 0)return t;const r=c(v(Bn(e)));return ie.size>=zn&&ie.clear(),ie.set(e,r),r}function Q(e,t,r,n,o,s){return ot(e)({$form:t,$meta:r,$errors:n,$formIsInvalid:o,$log:Hn.log,$fn:{},...s})===!0}function Bn(e){return e.replace(/(\?\.|\.)(\d+)/g,(t,r,n,o)=>r==="."&&Gn(e,o)?t:r==="?."?`?.[${n}]`:`[${n}]`)}function Gn(e,t){let r=t-1,n=!1;for(;r>=0&&e[r]>="0"&&e[r]<="9";)n=!0,r--;if(r<0)return!0;const o=e[r];return n?!/[\w$.\]]/.test(o):!/[\w$)\]]/.test(o)}const Kn=e=>(t,r)=>{let n=t.formDef.states;if(!n||Object.keys(n).length===0||t.formHealth.status==="errored")return t;const{$formIsInvalid:o,$errors:s}=r??Se(t);n=xn(n);let i=[],u={status:"ok"};try{i=Object.keys(n).map(d=>{const l=n[d];let a;try{a=Q(l,t.data,t.meta,s,o,{$fn:e})}catch{a=!1}return a===!0?d:void 0}).filter(d=>d!==void 0)}catch(d){const l=d,a=k.calculateCurrentStateError;u={status:"errored",message:`[${a}] ${l.message}`,code:a}}return{...t,currentStates:i,formHealth:u}};function xn(e){const t={};function r(n){const o=n.split(":"),s=[];for(let i=0;i<o.length;i++)s.push(o.slice(0,i+1).join(":"));return s}for(const[n,o]of Object.entries(e)){const s=r(n),i=[];for(const u of s)e[u]&&i.push(`(${e[u]})`);t[n]=i.join(" && ")}return t}const ee=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e;function vt(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ge(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((r,n)=>ge(r,t[n]));if(vt(e)&&vt(t)){const r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(n=>n in t&&ge(e[n],t[n]))}return!1}const Xn=e=>(t,r)=>{const{$formIsInvalid:n,$errors:o}=r??Se(t);return{...t,widgetFlags:Jn(t,o,n,e)}};function Jn(e,t,r,n){const o=[];for(const[i,u]of Object.entries(e.resolvedSources))if(T(u)){const d=At(i,u,e);$t(d)&&o.push(d)}else $t(u)&&o.push(At(i,u,e));const s=o.reduce((i,u)=>{i[u.uid]=i[u.uid]||{};const d=e.repeaterItemScopes[u.uid],l=d?{$item:_(e.data,d.itemPath),$index:d.index,$fn:n}:{$fn:n};return u.include&&"in"in u.include?i[u.uid].hidden=!u.include.in.some(a=>e.currentStates.includes(a)):u.include&&"when"in u.include&&(i[u.uid].hidden=!Q(u.include.when,e.data,e.meta,t,r,l)),u.exclude&&"from"in u.exclude?i[u.uid].hidden=u.exclude.from.some(a=>e.currentStates.includes(a)):u.exclude&&"when"in u.exclude&&(i[u.uid].hidden=Q(u.exclude.when,e.data,e.meta,t,r,l)),(P(u)||de(u))&&ee(u.disabled)&&(i[u.uid].disabled=Q(u.disabled.when,e.data,e.meta,t,r,l)),P(u)&&ee(u.readonly)&&(i[u.uid].readonly=Q(u.readonly.when,e.data,e.meta,t,r,l)),i},{});return Qn(e,s),s}function $t(e){return!!(e.include&&("in"in e.include||"when"in e.include)||e.exclude&&("from"in e.exclude||"when"in e.exclude)||(P(e)||de(e))&&ee(e.disabled)||P(e)&&ee(e.readonly))}function Qn(e,t){const r=Object.keys(t).filter(n=>t[n].hidden===!0);for(const n of r)sr(n,e,t)}function sr(e,t,r){const n=t.resolvedSources[e];if(n!==void 0){if(Ae(n)||T(n)&&n.path!==void 0){const o=`${n.path}.`;for(const[s,i]of Object.entries(t.repeaterItemScopes))i.itemPath.startsWith(o)&&St(s,r)}if(H(n)){const o=ne(e);for(const s of n.children){const i=o.length>0?Ke(s.uid,o):s.uid;if(t.resolvedSources[i]===void 0)continue;const u=r[i]?.hidden===!0;St(i,r),u||sr(i,t,r)}}}}function St(e,t){t[e]=t[e]||{},t[e].hidden=!0}function At(e,t,r){const n=r.repeaterItemScopes[e];let o;T(t)?(o={...t({$form:r.data,$item:n?_(r.data,n.itemPath):void 0,$index:n?.index,errors:void 0,touched:void 0,translate:void 0})},o.uid=e):o=t;const s=ne(e);return s.length>0&&(o=Br(o,s)),o}const ir=(e,t)=>(r,n)=>{try{const o=n??Se(r);return{...r,calculatedWidgets:qn(r,e,t,o)}}catch(o){const s=o,i=s.code??k.calculateWidgetPropsError;return{...r,formHealth:{status:"errored",message:`[${i}] ${s.message}`,code:i}}}};function qn(e,t,r,{$formIsInvalid:n,$errors:o}){const s=yo(e,t,n,o,r),i={};for(const u of Object.keys(e.calculatedWidgets)){if(e.widgetFlags[u]?.hidden)continue;const d=e.calculatedWidgets[u],l=d.source,a=e.repeaterItemScopes[u];if(T(l)){i[u]=Zn(d,u,l,e,t,a);continue}const p=a?{...s,$item:_(s.$form,a.itemPath),$index:a.index}:s;i[u]=Yn(d,l,e,p)}return i}function Zn(e,t,r,n,o,s){const i={...r({$form:n.data,errors:r.path?n.validations[r.path]:void 0,touched:r.path?n.touchedControls[r.path]:void 0,translate:o.translate,$item:s?_(n.data,s.itemPath):void 0,$index:s?.index})};i.uid=t,r.path!==void 0&&(i.path=r.path);const u=n.widgetPropOverrides[t];return u!==void 0&&(i.props={...i.props,...u}),e.current&&ge(e.current,i)?e:{source:r,current:i}}function Yn(e,t,r,n){const o=new go(t,e.current);return o.write("uid",t.uid),o.write("type",t.type),o.write("kind",t.kind),wr(t)?eo(o,n):de(t)?to(o,n):P(t)?ro(o,n):H(t)&&no(o,n),oo(t,o,n,r),(de(t)||P(t))&&so(t,o,n),H(t)&&io(t,o,r),o.changed?{source:e.source,current:o.current}:e}function eo(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude")}function to(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude"),A(e,t,"label"),A(e,t,"disabled"),A(e,t,"actionType")}function ro(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude"),A(e,t,"label"),A(e,t,"disabled"),A(e,t,"readonly"),A(e,t,"validator"),A(e,t,"path"),A(e,t,"defaultValue")}function no(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude")}function oo(e,t,r,n){const o=n.widgetPropOverrides[e.uid]??{},s={...e.props??{},...o};for(const i of dr(Object.keys(s)))uo(t,r,i)}function so(e,t,r){const n=e.on??{};for(const o of dr(Object.keys(n)))co(t,r,o)}function io(e,t,r){const n=ne(e.uid),o=$o(e.children,n,r.widgetFlags);t.current.children=o;const s=t.previous.children??[];s.length===o.length&&o.every((u,d)=>s[d]&&s[d].uid===o[d].uid)||t.markChanged()}function A(e,t,r){const n=e.source;if(!vo(n,r))return;const o=it(n,r,t.sortedStates);let s;switch(r){case"disabled":case"readonly":s=fo(o,t,e.source.uid,r);break;case"defaultValue":s=o;break;default:s=cr(o,t)}e.write(r,s)}function uo(e,t,r){const n=e.source.props,o=it(n,r,t.sortedStates);let s=cr(o,t);const i=t.widgetPropOverrides[e.source.uid]?.[r];i!==void 0&&(s=i),e.write(`props.${r}`,s)}function co(e,t,r){const n=e.source.on,o=it(n,r,t.sortedStates);e.write(`on.${r}`,po(o,t))}function st(e,t){return e({$form:t.$form,translate:t.localization.translate,$item:t.$item,$index:t.$index})}function lo(e,t){return t.localization.translate(e.key,mo(e.params,t),e.default)}const ao=/\{\{([^}]+)\}\}/g;function ur(e,t){return e.includes("{{")?e.replace(ao,(r,n)=>{try{const o=ot(n.trim())({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid,$item:t.$item,$index:t.$index,$fn:t.$fn});return o==null?"":String(o)}catch(o){const s=o instanceof Error?o.message:String(o);throw new lr(`Failed to evaluate '{{${n.trim()}}}': ${s}`)}}):e}function cr(e,t){return typeof e=="function"?st(e,t):Rr(e)?lo(e,t):typeof e=="string"?ur(e,t):e}function fo(e,t,r,n){return typeof e=="function"?st(e,t):ee(e)?t.widgetFlags[r]?.[n]:typeof e=="string"?ur(e,t):e}function po(e,t){return typeof e=="function"?st(e,t):e}function it(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 ho(e){return e.startsWith("$form")||e.startsWith("$meta")||e.startsWith("$errors")||e.startsWith("$item")||e.startsWith("$index")||e.startsWith("$fn")||e==="$formIsInvalid"}function mo(e,t){return e&&Object.keys(e).reduce((r,n)=>{const o=String(e[n]);if(ho(o))try{const s=ot(o)({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid,$item:t.$item,$index:t.$index,$fn:t.$fn});r[n]=s??o}catch(s){const i=s instanceof Error?s.message:String(s);throw new lr(`Failed to evaluate i18n param '${o}': ${i}`)}else r[n]=o;return r},{})}class go{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){const n=_(this.previous,t);if(ge(n,r)){Te(this.current,t,n);return}Te(this.current,t,r),this._changed=!0}}function yo(e,t,r,n,o){return{sortedStates:[...e.currentStates].sort((s,i)=>i.length-s.length),widgetPropOverrides:e.widgetPropOverrides,widgetFlags:e.widgetFlags,$form:e.data,$meta:e.meta,$formIsInvalid:r,$errors:n,localization:t,$fn:o}}function vo(e,t){if(t in e)return!0;const r=`${t}.`;return Object.keys(e).some(n=>n.startsWith(r))}function dr(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function $o(e,t,r){const n=t.map(o=>`[${o}]`).join("");return e.filter(o=>{const s=o.uid+n,i=r[s];return!i||i.hidden!==!0})}class lr extends Error{constructor(){super(...arguments),this.code=k.resolveStringInterpolationError,this.name="StringInterpolationError"}}const So=e=>{const t=Ao(e.resolvedSources),r=ue(e.widgetPropOverrides,i=>i in e.resolvedSources),n=ue(e.touchedControls,i=>t.has(i)),o=ue(e.validations,i=>t.has(i)),s=ue(e.injectedValidations,i=>t.has(i));return r===e.widgetPropOverrides&&n===e.touchedControls&&o===e.validations&&s===e.injectedValidations?e:{...e,widgetPropOverrides:r,touchedControls:n,validations:o,injectedValidations:s}};function Ao(e){const t=new Set;for(const r of Object.values(e)){const n=R(r);n!==void 0&&t.add(n)}return t}function ue(e,t){const r=Object.keys(e).filter(t);if(r.length===Object.keys(e).length)return e;const n={};for(const o of r)n[o]=e[o];return n}const Eo=e=>{const t=Object.keys(e.resolvedSources),r={};let n=t.length!==Object.keys(e.calculatedWidgets).length;for(const o of t){const s=e.calculatedWidgets[o];s?r[o]=s:(r[o]={source:e.resolvedSources[o],current:{}},n=!0)}return n?{...e,calculatedWidgets:r}:e},wo=({lang:e},t)=>{const r={...Tt(e),formName:t.payload.formName};let n=t.payload.formDef,o={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(a){const p=a,g=k.initializeParseError;o={status:"errored",message:`[${g}] ${p.message}`,code:g}}if(o.status==="errored")return{...r,formHealth:o}}let s=n;if(Array.isArray(n.form)){const a=n.form;s={...n,form:{uid:"",type:"flex",kind:"layout",children:a}}}const i=Wt.decode(s);if(i.isOk()){o={status:"ok"};let a={};try{a=Be([i.value.form]).reduce((p,g)=>{const I=g.uid;if(p[I])throw{existingWidget:p[I],newWidget:g};return p[I]=g,p},{})}catch(p){o=Io(p.existingWidget,p.newWidget),a={}}return jo(a,i.value.states),{...r,formDef:i.value,flatForm:a,...Ne(a,{}),formHealth:o}}const u=Co(n);if(u)return{...r,formHealth:u};const d=k.initializeUnknownError,l=i.issues.map(a=>`${a.path.length>0?kt(a.path):"root"}: ${a.message}`).join("; ");return{...r,formHealth:{status:"errored",message:`[${d}] ${l}`,code:d}}};function ar(e,t){return{status:"errored",code:e,message:`[${e}] ${t}`}}function Oo(){return"Malformed form definition. Pass it directly as formDef - `config={{ formDef: { states, form: [...] } }}`. Do NOT wrap it in an extra `{ form: ... }`."}function Co(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.form;return t&&typeof t=="object"&&!Array.isArray(t)&&!H(t)?ar(k.initializeMalformedFormShapeError,Oo()):null}function Io(e,t){const r=o=>P(o)?` at "${o.path}"`:"",n=`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`;return ar(k.initializeUidCollisionError,n)}function jo(e,t){const r=new Set(Object.keys(t??{})),n=new Map;for(const s of Object.values(e)){const i=[],u=s.include;u&&Array.isArray(u.in)&&i.push(...u.in);const d=s.exclude;d&&Array.isArray(d.from)&&i.push(...d.from);for(const l of i){if(r.has(l))continue;const a=n.get(l)??[];a.push(s.uid||"(unknown)"),n.set(l,a)}}if(n.size===0)return;const o=r.size?[...r].join(", "):"(none declared)";for(const[s,i]of n)console.error(`[GolemUI] include/exclude references undefined state "${s}" (on ${i.join(", ")}); these widgets will stay hidden. Declared states: ${o}. Fix: declare "${s}" in formConfig.states, or correct the name.`)}function ko(e,t){const{path:r,issues:n}=t.payload,o=n?.length?{touched:!0,touchedControls:{...e.touchedControls,[r]:!0}}:{};return{...e,...o,injectedValidations:{...e.injectedValidations,[r]:n}}}const Po=(e,{payload:t})=>{const r="path"in t?Do(e,t.path):Fo(e,t.uid);if(r===void 0)return e;const n=e.widgetPropOverrides[r]||{};return{...e,widgetPropOverrides:{...e.widgetPropOverrides,[r]:{...n,[t.prop]:t.value}}}};function Fo(e,t){if(t in e.resolvedSources)return t;console.warn(`Widget with uid "${t}" not found`)}function Do(e,t){const r=Object.values(e.calculatedWidgets).find(({source:o,current:s})=>(R(s)??R(o))===t);if(r)return r.source.uid;const n=Object.keys(e.resolvedSources).find(o=>R(e.resolvedSources[o])===t);if(n!==void 0)return n;console.warn(`Input with path "${t}" not found`)}const Wo=(e,t)=>({...e,data:{...t.payload.data}}),To=(e,t)=>({...e,formHealth:t.payload.formHealth}),No=(e,t)=>({...e,lang:t.payload.lang}),Vo=(e,t)=>({...e,meta:{...t.payload.meta}}),Ro=(e,t)=>({...e,data:Vt(e.data,t.payload.path,t.payload.data)}),fr=Symbol("filterMap.skip");function Mo(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n,e);o!==fr&&r.push(o)}return r}function _o(e,t,r){for(let n=0;n<e.length;n++)t(e[n],n,e)&&r(e[n],n,e)}function Lo(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}const Uo=(e,t)=>r=>{const n=Mo(Object.values(r.calculatedWidgets),({current:s})=>P(s)?s:fr),o=r.validations;return{...r,validations:n.reduce((s,i)=>{if(s[i.path]=null,i.validator){const u=e(i.validator,t),d=_(r.data,i.path),l=Ct(u,d);s[i.path]=It(l)?null:l.issues.map(a=>a.message)}return Array.isArray(s[i.path])&&Array.isArray(o[i.path])&&Lo(s[i.path],o[i.path],(u,d)=>u===d)&&(s[i.path]=o[i.path]),s},{})}},bo=({validators:e,validateOn:t,localization:r,functions:n})=>{const o=Bo(r,n),s=Uo(e,r),i=ir(r,n),u=l=>Et(l,o,s,!1),d=l=>Et(l,o,s,!0);return(l,a)=>{switch(a.type){case"INITIALIZE":return wo(l,a);case"SET_DATA":return u(Wo(l,a));case"SET_META":return u(Vo(l,a));case"SET_WIDGET_DATA":return u(Ro(l,a));case"SET_LANGUAGE":return i(No(l,a));case"OVERRIDE_WIDGET_PROP":{const p=Po(l,a);if(p===l)return l;const g=u(p);return Xo(g,a)?s(g):g}case"SET_FORM_HEALTH":return To(l,a);case"VALIDATE_ALL":return d(s(Ko(l)));case"ATTEMPT_VALIDATION":{if(!xo(t,a.payload.reason))return l;const p={...l,touched:!0,touchedControls:{...l.touchedControls,[a.payload.path]:!0}};return d(s(p))}case"INJECT_VALIDATION_ISSUES":return ko(l,a);default:return _r(a)}}},Ho=new Set([k.calculateCurrentStateError,k.calculateWidgetFlagsError,k.calculateWidgetPropsError,k.resolveStringInterpolationError]),zo=e=>e.formHealth.status==="errored"&&!Ho.has(e.formHealth.code);function Bo(e,t){const r=Kn(t),n=Xn(t),o=ir(e,t);return function(i){if(zo(i))return i;const u=d=>({...i,formHealth:d});try{let d=i.formHealth.status==="ok"?i:{...i,formHealth:{status:"ok"}};d=Kr(d),d=So(d);const l=Se(d);return d=r(d,l),d.formHealth.status!=="ok"?u(d.formHealth):(d=n(d,l),d=Eo(d),d=o(d,l),d.formHealth.status==="ok"?d:u(d.formHealth))}catch(d){const l=k.calculateWidgetFlagsError;return u({status:"errored",code:l,message:`[${l}] ${d.message}`})}}}function Et(e,t,r,n){const o=a=>n?wt(a):a,s=e.resolvedSources,i=e.widgetFlags;let u=t(e);if(!u.allControlsValidated||u.formHealth.status!=="ok")return o(u);const d=Go(u,s,i);if(d.length===0)return o(u);const l={...u.touchedControls};for(const a of d)l[a]=!0;return u={...u,touchedControls:l},wt(t(r(u)))}function Go(e,t,r){const n=[];for(const[o,s]of Object.entries(e.resolvedSources)){const i=R(s);if(i===void 0||e.widgetFlags[o]?.hidden===!0||e.touchedControls[i]===!0)continue;const u=t[o]===void 0,d=r[o]?.hidden===!0;(u||d)&&n.push(i)}return n}function Ko(e){const t={};for(const{source:r,current:n}of Object.values(e.calculatedWidgets)){const o=R(n)??R(r);o!==void 0&&(t[o]=!0)}return{...e,touched:!0,allControlsValidated:!0,touchedControls:t}}function xo(e,t){return e==="eager"||t===e||Array.isArray(e)&&e.includes(t)}function Xo(e,t){if(!e.touched)return!1;let r;if("path"in t.payload)r=t.payload.path;else{const n=e.calculatedWidgets[t.payload.uid]?.current;n&&P(n)&&(r=n.path)}return r!==void 0&&e.touchedControls[r]===!0}function wt(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(o=>{const s=e.injectedValidations[o];return Array.isArray(s)&&s.length>0});return n!==void 0?{...e,isFormValid:!1}:(n=r.find(o=>{const s=e.validations[o];return Array.isArray(s)&&s.length>0}),n!==void 0?{...e,isFormValid:!1}:{...e,isFormValid:!0})}function Jo(e=[],t,r,n,o={}){const s=new W.BehaviorSubject(Tt(n.lang)),i=s.asObservable().pipe(W.distinctUntilChanged()),u=bo({validators:t,validateOn:r,localization:n,functions:o});function d(g){const I=s.getValue(),Oe=u(I,g);s.next(Oe)}let l=d;const a={getState:()=>s.getValue(),dispatch:g=>l(g)};return l=e.map(g=>g(a)).reduceRight((g,I)=>I(g),d),{state$:i,dispatch:l,getState:()=>s.getValue()}}class Qo{constructor(){this.widgetRegistry=new De,this.store={},this.events$=new W.Subject,this.submit$=new W.Subject,this.itemRenderers={},this.dependencies={}}initialize(t,r=[],n,o,s,i=Nt(),u,d={}){this.localization=i,this.dependencies=u,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=s,this.store=Jo(r,n,o,i,d)}emitEvent(t,r,n){const s=this.store.getState().currentStates.filter(i=>r.on?.[`${t}.${i}`]!==void 0);if(this.attemptValidation(t,r),s.length>0)s.forEach(i=>{const u=r.on?.[`${t}.${i}`];u&&this.events$.next({name:u,data:Ie(this.store.getState()),detail:n??void 0,callback:d=>{this.store.dispatch(d)}})});else{const i=r.on?.[t];i&&this.events$.next({name:i,data:Ie(this.store.getState()),detail:n,callback:u=>{this.store.dispatch(u)}})}}emitSubmitEvent(){this.store.dispatch({type:"VALIDATE_ALL"}),this.store.getState().isFormValid&&this.submit$.next({data:Ie(this.store.getState()),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 qo(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=>s=>{o(s),n&&n.send(s,t.getState())}}}const Zo=W.pipe(W.map(e=>e.formHealth),W.distinctUntilChanged((e,t)=>e.status!==t.status?!1:e.status==="errored"&&t.status==="errored"?e.message===t.message&&e.code===t.code:!0)),Yo=e=>e.pipe(Zo);function es(e,t){return mr(e,t,hr(e,t),void 0)}function pr(){const e=new Map;return(t,r)=>{const n=hr(t,r),o=e.get(r);if(o&&os(o.slices,n))return o.viewModel;const s=mr(t,r,n,o);return e.set(r,{slices:n,viewModel:s}),s}}const ts=e=>t=>{const r=pr();return t.pipe(W.map(n=>r(n,e)),W.distinctUntilChanged())},rs=[],Ot=[],ns=[];function hr(e,t){const r=ss(e,t);return[e.calculatedWidgets[t],e.lang,r===void 0?void 0:_(e.data,r),r!==void 0&&e.touched?e.validations[r]:null,r!==void 0&&e.touched?e.injectedValidations[r]:null,r!==void 0&&e.touchedControls[r]===!0,e.touched&&!e.isFormValid,e.widgetFlags[t]?.hidden===!0]}function os(e,t){return e.every((r,n)=>Object.is(r,t[n]))}function mr(e,t,r,n){const[o,s,i,u,d,l,a,p]=r,g=n===void 0||!Object.is(n.slices[0],o),I=n===void 0||!Object.is(n.slices[2],i),Oe=n===void 0||!Object.is(n.slices[3],u)||!Object.is(n.slices[4],d),Ce=o?.current;return{uid:t,widget:Ce,children:g?is(e,t,Ce):n.viewModel.children,rows:g||I?us(e,t,Ce,i):n.viewModel.rows,lang:s,value:i,errors:Oe?cs(u,d):n.viewModel.errors,touched:l,formInvalid:a,hidden:p}}function ss(e,t){return e.resolvedSources[t]?.path}function is(e,t,r){if(r===void 0||!H(r))return rs;const n=r.children,o=ne(t);if(o.length===0)return n;const s=o.map(i=>`[${i}]`).join("");return n.map(i=>e.resolvedSources[`${i.uid}${s}`]??i)}function us(e,t,r,n){if(r===void 0||!Array.isArray(n))return Ot;const o=e.resolvedSources[t];if(o===void 0||!Ae(o))return Ot;const s=o.props.template.uid,i=ne(t);return n.map((u,d)=>{const l=Ke(s,[...i,d]);return e.resolvedSources[l]}).filter(u=>u!==void 0)}function cs(e,t){return(e?.length??0)+(t?.length??0)===0?ns:[...e??[],...t??[]]}let gr=!1;function ds(){gr=!0}function ls(){return gr}function as(e,t,r){if(!ls())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=Qo;exports.assertNoPropCollisions=as;exports.cloneObject=q;exports.createWidgetViewModelReader=pr;exports.defineForm=Nr;exports.devToolsMiddleware=qo;exports.enableDevMode=ds;exports.errorCodes=k;exports.filterTap=_o;exports.formEventNames=Vr;exports.formHealth=Yo;exports.getDirectionFromLanguage=Mr;exports.identityTranslator=Nt;exports.isStandardValidateSuccess=It;exports.makeRepeaterItemConfig=Ge;exports.shortUUID=Ft;exports.standardValidate=Ct;exports.widgetViewModel=es;exports.widgetViewModel$=ts;
4
+ `,""+o}${i}${u}`)},Lt=(e,t=h)=>(Array.isArray(e)&&(e.loc=t),e),X=(e,t=h,r)=>{for(;r=e(m.charCodeAt(h));)h+=r;return m.slice(t,h)},O=(e=1)=>m[h+=e],Re=e=>h=e,S=(e=0,t)=>{let r,n,o,s,i;for(t&&v.asi&&(v.newline=!1);(r=v.space())&&(i=v.newline,1)&&r!==t&&(o=(n&&r===91&&Ve&&v.asi?.(n,e,S)||null)??((s=W[r])&&s(n,e))??(n&&i&&v.asi?.(n,e,S))??(!n&&X(v.id)));)n=o;return t&&(r==t?(h++,t===125&&v.asi&&(v.newline=!0)):B("Unclosed "+String.fromCharCode(t-(t>42?2:1)))),n},M=(e,t=h)=>{for(Ve=!1;(e=m.charCodeAt(h))<=xe;)v.asi&&e===10&&(v.newline=Ve=!0),h++;return e},xr=(e=h)=>{for(;m.charCodeAt(e)<=xe;)e++;return m.charCodeAt(e)};v.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 Xr=(e,t=e.length)=>m.substr(h,t)===e&&!v.id(m.charCodeAt(h+t)),W=[],ft={},P=(e,t=xe,r,n=e.charCodeAt(0),o=e.length,s=W[n],i=e.toUpperCase()!==e,u,d)=>(t=ft[e]=!s&&ft[e]||t,W[n]=(l,a,p,g=h)=>(u=p,(p?e==p:(o<2||e.charCodeAt(1)===m.charCodeAt(h+1)&&(o<3||m.substr(h,o)==e))&&(!i||!v.id(m.charCodeAt(h+o)))&&(u=p=e))&&a<t&&(h+=o,(d=r(l))?Lt(d,g):(h=g,u=0,!i&&!s&&!l&&B()),d)||s?.(l,a,u))),$=(e,t,r=!1)=>P(e,t,n=>n&&(o=>o&&[e,n,o])(S(t-(r?.5:0)))),U=(e,t,r)=>P(e,t,n=>!n&&(n=S(t-.5))&&[e,n]),oe=(e,t)=>P(e,200,r=>!r&&[,t]),Mt=(e,t,r)=>P(e,t,(n,o)=>(o=S(t-(r?.5:0)),n?.[0]!==e&&(n=[e,n||null]),o?.[0]===e?n.push(...o.slice(1)):n.push(o||null),n)),Xe=(e,t)=>P(e[0],t,r=>!r&&[e,S(0,e.charCodeAt(1))||null]),_t=(e,t)=>P(e[0],t,r=>r&&[e,r,S(0,e.charCodeAt(1))||null]),se=(e,t,r,n=e.charCodeAt(0),o=e.length,s=W[n],i)=>W[n]=(u,d,l,a=h)=>!u&&(l?e==l:(o<2||m.substr(h,o)==e)&&(l=e))&&d<t&&!v.id(m.charCodeAt(h+o))&&(!v.prop||v.prop(h+o))&&(Re(h+o),(i=r())?Lt(i,a):Re(a),i)||s?.(u,d,l);Object.defineProperty(v,"space",{configurable:!0,enumerable:!0,get:()=>M,set:e=>M=e});const Le={},f=(e,t,r=Le[e])=>Le[e]=(...n)=>t(...n)||r?.(...n),c=e=>Array.isArray(e)?e[0]==null?(t=>()=>t)(e[1]):Le[e[0]]?.(...e.slice(1))??B(`Unknown operator: ${e[0]}`,e?.loc):e===void 0?()=>{}:t=>t?.[e],ae=46,Z=48,fe=57,Jr=69,Qr=101,qr=43,Zr=45,ce=95,Ut=110,Yr=97,en=102,tn=65,rn=70,bt=e=>e.indexOf("_")<0?e:e.replaceAll("_",""),Je=e=>{let t=bt(X(r=>r===ae&&m.charCodeAt(h+1)!==ae||r>=Z&&r<=fe||r===ce||((r===Jr||r===Qr)&&((r=m.charCodeAt(h+1))>=Z&&r<=fe||r===qr||r===Zr)?2:0)));return m.charCodeAt(h)===Ut?(O(),[,BigInt(t)]):(e=+t)!=e?B():[,e]},nn={2:e=>e===48||e===49||e===ce,8:e=>e>=48&&e<=55||e===ce,16:e=>e>=Z&&e<=fe||e>=Yr&&e<=en||e>=tn&&e<=rn||e===ce};v.number=null;W[ae]=e=>!e&&m.charCodeAt(h+1)!==ae&&Je();for(let e=Z;e<=fe;e++)W[e]=t=>t?void 0:Je();W[Z]=e=>{if(e)return;const t=v.number;if(t){for(const[r,n]of Object.entries(t))if(r[0]==="0"&&m[h+1]?.toLowerCase()===r[1]){O(2);const o=bt(X(nn[n]));return m.charCodeAt(h)===Ut?(O(),[,BigInt("0"+r[1]+o)]):[,parseInt(o,n)]}}return Je()};const on=92,pt=34,ht=39,sn={n:`
5
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},Ht=e=>(t,r,n="")=>{if(!(t||!v.string?.[String.fromCharCode(e)]))return O(),X(o=>o-e&&(o===on?(n+=sn[m[h+1]]||m[h+1],2):(n+=m[h],1))),m[h]===String.fromCharCode(e)?O():B("Bad string"),[,n]};W[pt]=Ht(pt);W[ht]=Ht(ht);v.string={'"':!0};const un=20;"= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map(e=>$(e,un,!0));const zt=(e,t,r,n)=>typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=c(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="[]"&&e.length===3?(r=c(e[1]),n=c(e[2]),o=>t(r(o),n(o),o)):e[0]==="()"&&e.length===2?zt(e[1],t):(()=>{throw Error("Invalid assignment target")})(),mt={"=":(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 mt)f(e,(t,r)=>(r=c(r),zt(t,(n,o,s)=>mt[e](n,o,r(s)))));const cn=30,dn=40,ln=140;U("!",ln);$("||",cn);$("&&",dn);f("!",e=>(e=c(e),t=>!e(t)));f("||",(e,t)=>(e=c(e),t=c(t),r=>e(r)||t(r)));f("&&",(e,t)=>(e=c(e),t=c(t),r=>e(r)&&t(r)));const an=50,fn=60,pn=70,Bt=100,hn=140;$("|",an);$("&",pn);$("^",fn);$(">>",Bt);$("<<",Bt);U("~",hn);f("~",e=>(e=c(e),t=>~e(t)));f("|",(e,t)=>(e=c(e),t=c(t),r=>e(r)|t(r)));f("&",(e,t)=>(e=c(e),t=c(t),r=>e(r)&t(r)));f("^",(e,t)=>(e=c(e),t=c(t),r=>e(r)^t(r)));f(">>",(e,t)=>(e=c(e),t=c(t),r=>e(r)>>t(r)));f("<<",(e,t)=>(e=c(e),t=c(t),r=>e(r)<<t(r)));const Ee=90;$("<",Ee);$(">",Ee);$("<=",Ee);$(">=",Ee);f(">",(e,t)=>(e=c(e),t=c(t),r=>e(r)>t(r)));f("<",(e,t)=>(e=c(e),t=c(t),r=>e(r)<t(r)));f(">=",(e,t)=>(e=c(e),t=c(t),r=>e(r)>=t(r)));f("<=",(e,t)=>(e=c(e),t=c(t),r=>e(r)<=t(r)));const Gt=80;$("==",Gt);$("!=",Gt);f("==",(e,t)=>(e=c(e),t=c(t),r=>e(r)==t(r)));f("!=",(e,t)=>(e=c(e),t=c(t),r=>e(r)!=t(r)));const Kt=110,Qe=120,xt=140;$("+",Kt);$("-",Kt);$("*",Qe);$("/",Qe);$("%",Qe);U("+",xt);U("-",xt);f("+",(e,t)=>t!==void 0?(e=c(e),t=c(t),r=>e(r)+t(r)):(e=c(e),r=>+e(r)));f("-",(e,t)=>t!==void 0?(e=c(e),t=c(t),r=>e(r)-t(r)):(e=c(e),r=>-e(r)));f("*",(e,t)=>(e=c(e),t=c(t),r=>e(r)*t(r)));f("/",(e,t)=>(e=c(e),t=c(t),r=>e(r)/t(r)));f("%",(e,t)=>(e=c(e),t=c(t),r=>e(r)%t(r)));const pe=150;P("++",pe,e=>e?["++",e,null]:["++",S(pe-1)]);P("--",pe,e=>e?["--",e,null]:["--",S(pe-1)]);const qe=(e,t,r,n)=>typeof e=="string"?o=>t(o,e):e[0]==="."?(r=c(e[1]),n=e[2],o=>t(r(o),n)):e[0]==="[]"&&e.length===3?(r=c(e[1]),n=c(e[2]),o=>t(r(o),n(o))):e[0]==="()"&&e.length===2?qe(e[1],t):(()=>{throw Error("Invalid increment target")})();f("++",(e,t)=>qe(e,t===null?(r,n)=>r[n]++:(r,n)=>++r[n]));f("--",(e,t)=>qe(e,t===null?(r,n)=>r[n]--:(r,n)=>--r[n]));const mn=5,gn=10;Mt(",",gn);Mt(";",mn,!0);const Xt=(...e)=>(e=e.map(c),t=>{let r;for(const n of e)r=n(t);return r});f(",",Xt);f(";",Xt);const yn=170;Xe("()",yn);const R=e=>e?.[0]==="_"&&e[1]==="_"||e==="constructor"||e==="prototype",Ze=170;_t("[]",Ze);$(".",Ze);_t("()",Ze);const he=e=>{throw Error(e)};f("[]",(e,t)=>t===void 0?(e=e?e[0]===","?e.slice(1):[e]:[],e=e.map(r=>r==null?(()=>{}):r[0]==="..."?(r=c(r[1]),n=>r(n)):(r=c(r),n=>[r(n)])),r=>e.flatMap(n=>n(r))):(t==null&&he("Missing index"),e=c(e),t=c(t),r=>{const n=t(r);return R(n)?void 0:e(r)[n]}));f(".",(e,t)=>(e=c(e),t=t[0]?t:t[1],R(t)?()=>{}:r=>e(r)[t]));f("()",(e,t)=>{if(t===void 0)return e==null?he("Empty ()"):c(e);const r=o=>o?.[0]===","&&o.slice(1).some(s=>s==null||r(s));r(t)&&he("Empty argument");const n=t?t[0]===","?(t=t.slice(1).map(c),o=>t.map(s=>s(o))):(t=c(t),o=>[t(o)]):()=>[];return Ye(e,(o,s,i)=>o[s](...n(i)))});const G=e=>typeof e=="string"||Array.isArray(e)&&(e[0]==="."||e[0]==="?."||e[0]==="[]"&&e.length===3||e[0]==="?.[]"||e[0]==="()"&&e.length===2&&G(e[1])||e[0]==="{}"),Ye=(e,t,r,n)=>e==null?he("Empty ()"):e[0]==="()"&&e.length==2?Ye(e[1],t):typeof e=="string"?o=>t(o,e,o):e[0]==="."?(r=c(e[1]),n=e[2],o=>t(r(o),n,o)):e[0]==="?."?(r=c(e[1]),n=e[2],o=>{const s=r(o);return s==null?void 0:t(s,n,o)}):e[0]==="[]"&&e.length===3?(r=c(e[1]),n=c(e[2]),o=>t(r(o),n(o),o)):e[0]==="?.[]"?(r=c(e[1]),n=c(e[2]),o=>{const s=r(o);return s==null?void 0:t(s,n(o),o)}):(e=c(e),o=>t([e(o)],0,o)),J=Ye,vn=32,$n=v.space;v.comment??={"//":`
6
+ `,"/*":"*/"};let ke;v.space=()=>{ke||(ke=Object.entries(v.comment).map(([o,s])=>[o,s,o.charCodeAt(0)]));for(var e;e=$n();){for(var t=0,r;r=ke[t++];)if(e===r[2]&&m.substr(h,r[0].length)===r[0]){var n=h+r[0].length;if(r[1]===`
7
+ `)for(;m.charCodeAt(n)>=vn;)n++;else{for(;m[n]&&m.substr(n,r[1].length)!==r[1];)n++;m[n]&&(n+=r[1].length)}Re(n),e=0;break}if(e)return e}return e};const Jt=80;$("===",Jt);$("!==",Jt);f("===",(e,t)=>(e=c(e),t=c(t),r=>e(r)===t(r)));f("!==",(e,t)=>(e=c(e),t=c(t),r=>e(r)!==t(r)));const Sn=30;$("??",Sn);f("??",(e,t)=>(e=c(e),t=c(t),r=>e(r)??t(r)));const An=130,wn=20;$("**",An,!0);$("**=",wn,!0);f("**",(e,t)=>(e=c(e),t=c(t),r=>e(r)**t(r)));const En=e=>{throw Error(e)};f("**=",(e,t)=>(G(e)||En("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]**=t(o))));const Qt=90;$("in",Qt);$("of",Qt);f("in",(e,t)=>(e=c(e),t=c(t),r=>e(r)in t(r)));const On=20,Cn=100,In=e=>{throw Error(e)};$(">>>",Cn);$(">>>=",On,!0);f(">>>",(e,t)=>(e=c(e),t=c(t),r=>e(r)>>>t(r)));f(">>>=",(e,t)=>(G(e)||In("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]>>>=t(o))));const et=5,jn=10,kn=20,Fn=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,s=Fn(o);if(n==="{}"){const i=[];for(const u of s){if(Array.isArray(u)&&u[0]==="..."){const g={};for(const I in t)i.includes(I)||(g[I]=t[I]);r[u[1]]=g;break}let d,l,a;typeof u=="string"?d=l=u:u[0]==="="?(typeof u[1]=="string"?d=l=u[1]:[,d,l]=u[1],a=u[2]):[,d,l]=u,i.push(d);let p=t[d];p===void 0&&a&&(p=c(a)(r)),me(l,p,r)}}else if(n==="[]"){let i=0;for(const u of s){if(u===null){i++;continue}if(Array.isArray(u)&&u[0]==="..."){r[u[1]]=t.slice(i);break}let d=u,l;Array.isArray(u)&&u[0]==="="&&([,d,l]=u);let a=t[i++];a===void 0&&l&&(a=c(l)(r)),me(d,a,r)}}},qt=e=>{let t=S(jn-1);return t?.[0]==="in"||t?.[0]==="of"?[t[0],[e,t[1]],t[2]]:t?.[0]===","?[e,...t.slice(1)]:[e,t]};se("let",et+1,()=>qt("let"));se("const",et+1,()=>qt("const"));se("var",et,()=>(M(),["var",S(kn)]));const Zt=(...e)=>(e=e.map(t=>{if(typeof t=="string")return r=>{r[t]=void 0};if(t[0]==="="){const[,r,n]=t,o=c(n);return typeof r=="string"?s=>{s[r]=o(s)}:s=>me(r,o(s),s)}return c(t)}),t=>{for(const r of e)r(t)});f("let",Zt);f("const",Zt);f("var",e=>typeof e=="string"?t=>{t[e]=void 0}:()=>{});const tt=20,Oe=e=>{throw Error(e)};$("||=",tt,!0);$("&&=",tt,!0);$("??=",tt,!0);f("=",(e,t)=>{if(Array.isArray(e)&&(e[0]==="let"||e[0]==="const"||e[0]==="var")){const r=e[1];return t=c(t),typeof r=="string"?n=>{n[r]=t(n)}:n=>me(r,t(n),n)}return G(e)||Oe("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]=t(o))});f("||=",(e,t)=>(G(e)||Oe("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]||=t(o))));f("&&=",(e,t)=>(G(e)||Oe("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]&&=t(o))));f("??=",(e,t)=>(G(e)||Oe("Invalid assignment target"),t=c(t),J(e,(r,n,o)=>r[n]??=t(o))));oe("true",!0);oe("false",!1);oe("null",null);se("undefined",200,()=>[]);oe("NaN",NaN);oe("Infinity",1/0);const Fe=20;P("?",Fe,(e,t,r)=>e&&(t=S(Fe-1))&&X(n=>n===58)&&(r=S(Fe-1),["?",e,t,r]));f("?",(e,t,r)=>(e=c(e),t=c(t),r=c(r),n=>e(n)?t(n):r(n)));const Pn=[],Wn=20;$("=>",Wn,!0);f("=>",(e,t)=>{e=e?.[0]==="()"?e[1]:e;const r=e?e[0]===","?e.slice(1):[e]:[];let n=-1,o=null;const s=r[r.length-1];Array.isArray(s)&&s[0]==="..."&&(n=r.length-1,o=s[1],r.length--);const i=t?.[0]==="{}";return t=c(i?["{",t[1]]:t),u=>(...d)=>{const l={};r.forEach((p,g)=>l[p]=d[g]),o&&(l[o]=d.slice(n));const a=new Proxy(l,{get:(p,g)=>g in p?p[g]:u?.[g],set:(p,g,I)=>((g in p?p:u)[g]=I,!0),has:(p,g)=>g in p||(u?g in u:!1)});try{const p=t(a);return i?void 0:p}catch(p){if(p===Pn)return p[0];throw p}}});const Dn=140;U("...",Dn);f("...",e=>(e=c(e),t=>Object.entries(e(t))));const gt=170;P("?.",gt,(e,t)=>{if(!e)return;const r=M();return r===40?(O(),["?.()",e,S(0,41)||null]):r===91?(O(),["?.[]",e,S(0,93)]):(t=S(gt),t?["?.",e,t]:void 0)});f("?.",(e,t)=>(e=c(e),R(t)?()=>{}:r=>e(r)?.[t]));f("?.[]",(e,t)=>(e=c(e),t=c(t),r=>{const n=t(r);return R(n)?void 0:e(r)?.[n]}));f("?.()",(e,t)=>{const r=t?t[0]===","?(t=t.slice(1).map(c),o=>t.map(s=>s(o))):(t=c(t),o=>[t(o)]):()=>[];if(e[0]==="?."){const o=c(e[1]),s=e[2];return R(s)?()=>{}:i=>o(i)?.[s]?.(...r(i))}if(e[0]==="?.[]"){const o=c(e[1]),s=c(e[2]);return i=>{const u=o(i),d=s(i);return R(d)?void 0:u?.[d]?.(...r(i))}}if(e[0]==="."){const o=c(e[1]),s=e[2];return R(s)?()=>{}:i=>o(i)?.[s]?.(...r(i))}if(e[0]==="[]"&&e.length===3){const o=c(e[1]),s=c(e[2]);return i=>{const u=o(i),d=s(i);return R(d)?void 0:u?.[d]?.(...r(i))}}const n=c(e);return o=>n(o)?.(...r(o))});const Y=140;U("typeof",Y);U("void",Y);U("delete",Y);se("new",Y,()=>Xr(".target")?(O(7),["new.target"]):["new",S(Y)]);f("typeof",e=>(e=c(e),t=>typeof e(t)));f("void",e=>(e=c(e),t=>(e(t),void 0)));f("delete",e=>{if(e[0]==="."){const t=c(e[1]),r=e[2];return n=>delete t(n)[r]}if(e[0]==="[]"){const t=c(e[1]),r=c(e[2]);return n=>delete t(n)[r(n)]}return()=>!0});f("new",e=>{const t=c(e?.[0]==="()"?e[1]:e),r=e?.[0]==="()"?e[2]:null,n=r?r[0]===","?(o=>s=>o.map(i=>i(s)))(r.slice(1).map(c)):(o=>s=>[o(s)])(c(r)):()=>[];return o=>new(t(o))(...n(o))});const rt=Symbol("accessor"),nt=20,Tn=40,Yt=41,er=123,tr=125,rr=e=>t=>{if(t)return;M();const r=X(v.id);if(!r||(M(),m.charCodeAt(h)!==Tn))return!1;O();const n=S(0,Yt);return M(),m.charCodeAt(h)!==er?!1:(O(),[e,r,n,S(0,tr)])};P("get",nt-1,rr("get"));P("set",nt-1,rr("set"));P("(",nt-1,e=>{if(!e||typeof e!="string")return;const t=S(0,Yt)||null;if(M(),m.charCodeAt(h)===er)return O(),[":",e,["=>",["()",t],S(0,tr)||null]]});f("get",(e,t)=>(t=t?c(t):()=>{},r=>[[rt,e,{get:function(){const n=Object.create(r||{});return n.this=this,t(n)}}]]));f("set",(e,t,r)=>(r=r?c(r):()=>{},n=>[[rt,e,{set:function(o){const s=Object.create(n||{});s.this=this,s[t]=o,r(s)}}]]));const Nn=20,nr=200;v.prop=e=>xr(e)!==58;const Vn=e=>e==null||typeof e=="string"||[":",",","...","get","set"].includes(e[0]);Xe("[]",nr);Xe("{}",nr);$(":",Nn-1,!0);f("{}",(e,t)=>{if(t!==void 0)return;if(!Vn(e))return c(["{",e]);e=e?e[0]!==","?[e]:e.slice(1):[];const r=e.map(n=>c(typeof n=="string"?[":",n,n]:n));return n=>{const o={},s={};for(const i of r.flatMap(u=>u(n)))if(i[0]===rt){const[,u,d]=i;s[u]={...s[u],...d,configurable:!0,enumerable:!0}}else o[i[0]]=i[1];for(const i in s)Object.defineProperty(o,i,s[i]);return o}});f("{",e=>(e=e?c(e):()=>{},t=>e(Object.create(t))));f(":",(e,t)=>(t=c(t),Array.isArray(e)?(e=c(e),r=>[[e(r),t(r)]]):r=>[[e,t(r)]]));const Rn=170,ge=96,Ln=36,Mn=123,_n=92,Un={n:`
8
+ `,r:"\r",t:" ",b:"\b",f:"\f",v:"\v"},yt=()=>{const e=[];for(let t="",r;(r=m.charCodeAt(h))!==ge;)r?r===_n?(O(),t+=Un[m[h]]||m[h],O()):r===Ln&&m.charCodeAt(h+1)===Mn?(t&&e.push([,t]),t="",O(2),e.push(S(0,125))):(t+=m[h],O(),r=m.charCodeAt(h),r===ge&&t&&e.push([,t])):B("Unterminated template");return O(),e},bn=W[ge];W[ge]=(e,t)=>e&&t<Rn?v.asi&&v.newline?void 0:(O(),["``",e,...yt()]):e?bn?.(e,t):(O(),(r=>r.length<2&&r[0]?.[0]===void 0?r[0]||[,""]:["`",...r])(yt()));f("`",(...e)=>(e=e.map(c),t=>e.map(r=>r(t)).join("")));f("``",(e,...t)=>{e=c(e);const r=[],n=[];for(const s of t)Array.isArray(s)&&s[0]===void 0?r.push(s[1]):n.push(c(s));const o=Object.assign([...r],{raw:r});return s=>e(s)(o,...n.map(i=>i(s)))});v.string["'"]=!0;v.number={"0x":16,"0b":2,"0o":8};const Hn={log:(e,t)=>(t?console.log(t,e):console.log(e),e)},zn=2e3,ie=new Map;function ot(e){const t=ie.get(e);if(t!==void 0)return t;const r=c(v(Bn(e)));return ie.size>=zn&&ie.clear(),ie.set(e,r),r}function Q(e,t,r,n,o,s){return ot(e)({$form:t,$meta:r,$errors:n,$formIsInvalid:o,$log:Hn.log,$fn:{},...s})===!0}function Bn(e){return e.replace(/(\?\.|\.)(\d+)/g,(t,r,n,o)=>r==="."&&Gn(e,o)?t:r==="?."?`?.[${n}]`:`[${n}]`)}function Gn(e,t){let r=t-1,n=!1;for(;r>=0&&e[r]>="0"&&e[r]<="9";)n=!0,r--;if(r<0)return!0;const o=e[r];return n?!/[\w$.\]]/.test(o):!/[\w$)\]]/.test(o)}const Kn=e=>(t,r)=>{let n=t.formDef.states;if(!n||Object.keys(n).length===0||t.formHealth.status==="errored")return t;const{$formIsInvalid:o,$errors:s}=r??Ae(t);n=xn(n);let i=[],u={status:"ok"};try{i=Object.keys(n).map(d=>{const l=n[d];let a;try{a=Q(l,t.data,t.meta,s,o,{$fn:e})}catch{a=!1}return a===!0?d:void 0}).filter(d=>d!==void 0)}catch(d){const l=d,a=k.calculateCurrentStateError;u={status:"errored",message:`[${a}] ${l.message}`,code:a}}return{...t,currentStates:i,formHealth:u}};function xn(e){const t={};function r(n){const o=n.split(":"),s=[];for(let i=0;i<o.length;i++)s.push(o.slice(0,i+1).join(":"));return s}for(const[n,o]of Object.entries(e)){const s=r(n),i=[];for(const u of s)e[u]&&i.push(`(${e[u]})`);t[n]=i.join(" && ")}return t}const ee=e=>e!==void 0&&typeof e=="object"&&e!==null&&"when"in e;function vt(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ye(e,t){if(e===t)return!0;if(Array.isArray(e)&&Array.isArray(t))return e.length===t.length&&e.every((r,n)=>ye(r,t[n]));if(vt(e)&&vt(t)){const r=Object.keys(e);return r.length!==Object.keys(t).length?!1:r.every(n=>n in t&&ye(e[n],t[n]))}return!1}const Xn=e=>(t,r)=>{const{$formIsInvalid:n,$errors:o}=r??Ae(t);return{...t,widgetFlags:Jn(t,o,n,e)}};function Jn(e,t,r,n){const o=[];for(const[i,u]of Object.entries(e.resolvedSources))if(N(u)){const d=At(i,u,e);$t(d)&&o.push(d)}else $t(u)&&o.push(At(i,u,e));const s=o.reduce((i,u)=>{i[u.uid]=i[u.uid]||{};const d=e.repeaterItemScopes[u.uid],l=d?{$item:_(e.data,d.itemPath),$index:d.index,$fn:n}:{$fn:n};return u.include&&"in"in u.include?i[u.uid].hidden=!u.include.in.some(a=>e.currentStates.includes(a)):u.include&&"when"in u.include&&(i[u.uid].hidden=!Q(u.include.when,e.data,e.meta,t,r,l)),u.exclude&&"from"in u.exclude?i[u.uid].hidden=u.exclude.from.some(a=>e.currentStates.includes(a)):u.exclude&&"when"in u.exclude&&(i[u.uid].hidden=Q(u.exclude.when,e.data,e.meta,t,r,l)),(F(u)||de(u))&&ee(u.disabled)&&(i[u.uid].disabled=Q(u.disabled.when,e.data,e.meta,t,r,l)),F(u)&&ee(u.readonly)&&(i[u.uid].readonly=Q(u.readonly.when,e.data,e.meta,t,r,l)),i},{});return Qn(e,s),s}function $t(e){return!!(e.include&&("in"in e.include||"when"in e.include)||e.exclude&&("from"in e.exclude||"when"in e.exclude)||(F(e)||de(e))&&ee(e.disabled)||F(e)&&ee(e.readonly))}function Qn(e,t){const r=Object.keys(t).filter(n=>t[n].hidden===!0);for(const n of r)or(n,e,t)}function or(e,t,r){const n=t.resolvedSources[e];if(n!==void 0){if(we(n)||N(n)&&n.path!==void 0){const o=`${n.path}.`;for(const[s,i]of Object.entries(t.repeaterItemScopes))i.itemPath.startsWith(o)&&St(s,r)}if(H(n)){const o=ne(e);for(const s of n.children){const i=o.length>0?Ke(s.uid,o):s.uid;if(t.resolvedSources[i]===void 0)continue;const u=r[i]?.hidden===!0;St(i,r),u||or(i,t,r)}}}}function St(e,t){t[e]=t[e]||{},t[e].hidden=!0}function At(e,t,r){const n=r.repeaterItemScopes[e];let o;N(t)?(o={...t({$form:r.data,$item:n?_(r.data,n.itemPath):void 0,$index:n?.index,errors:void 0,touched:void 0,translate:void 0})},o.uid=e):o=t;const s=ne(e);return s.length>0&&(o=Br(o,s)),o}const sr=(e,t)=>(r,n)=>{try{const o=n??Ae(r);return{...r,calculatedWidgets:qn(r,e,t,o)}}catch(o){const s=o,i=s.code??k.calculateWidgetPropsError;return{...r,formHealth:{status:"errored",message:`[${i}] ${s.message}`,code:i}}}};function qn(e,t,r,{$formIsInvalid:n,$errors:o}){const s=yo(e,t,n,o,r),i={};for(const u of Object.keys(e.calculatedWidgets)){if(e.widgetFlags[u]?.hidden)continue;const d=e.calculatedWidgets[u],l=d.source,a=e.repeaterItemScopes[u];if(N(l)){i[u]=Zn(d,u,l,e,t,a);continue}const p=a?{...s,$item:_(s.$form,a.itemPath),$index:a.index}:s;i[u]=Yn(d,l,e,p)}return i}function Zn(e,t,r,n,o,s){const i={...r({$form:n.data,errors:r.path?n.validations[r.path]:void 0,touched:r.path?n.touchedControls[r.path]:void 0,translate:o.translate,$item:s?_(n.data,s.itemPath):void 0,$index:s?.index})};i.uid=t,r.path!==void 0&&(i.path=r.path);const u=n.widgetPropOverrides[t];return u!==void 0&&(i.props={...i.props,...u}),e.current&&ye(e.current,i)?e:{source:r,current:i}}function Yn(e,t,r,n){const o=new go(t,e.current);return o.write("uid",t.uid),o.write("type",t.type),o.write("kind",t.kind),wr(t)?eo(o,n):de(t)?to(o,n):F(t)?ro(o,n):H(t)&&no(o,n),oo(t,o,n,r),(de(t)||F(t))&&so(t,o,n),H(t)&&io(t,o,r),o.changed?{source:e.source,current:o.current}:e}function eo(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude")}function to(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude"),A(e,t,"label"),A(e,t,"disabled"),A(e,t,"actionType")}function ro(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude"),A(e,t,"label"),A(e,t,"disabled"),A(e,t,"readonly"),A(e,t,"validator"),A(e,t,"path"),A(e,t,"defaultValue")}function no(e,t){A(e,t,"size"),A(e,t,"include"),A(e,t,"exclude")}function oo(e,t,r,n){const o=n.widgetPropOverrides[e.uid]??{},s={...e.props??{},...o};for(const i of cr(Object.keys(s)))uo(t,r,i)}function so(e,t,r){const n=e.on??{};for(const o of cr(Object.keys(n)))co(t,r,o)}function io(e,t,r){const n=ne(e.uid),o=$o(e.children,n,r.widgetFlags);t.current.children=o;const s=t.previous.children??[];s.length===o.length&&o.every((u,d)=>s[d]&&s[d].uid===o[d].uid)||t.markChanged()}function A(e,t,r){const n=e.source;if(!vo(n,r))return;const o=it(n,r,t.sortedStates);let s;switch(r){case"disabled":case"readonly":s=fo(o,t,e.source.uid,r);break;case"defaultValue":s=o;break;default:s=ur(o,t)}e.write(r,s)}function uo(e,t,r){const n=e.source.props,o=it(n,r,t.sortedStates);let s=ur(o,t);const i=t.widgetPropOverrides[e.source.uid]?.[r];i!==void 0&&(s=i),e.write(`props.${r}`,s)}function co(e,t,r){const n=e.source.on,o=it(n,r,t.sortedStates);e.write(`on.${r}`,po(o,t))}function st(e,t){return e({$form:t.$form,translate:t.localization.translate,$item:t.$item,$index:t.$index})}function lo(e,t){return t.localization.translate(e.key,mo(e.params,t),e.default)}const ao=/\{\{([^}]+)\}\}/g;function ir(e,t){return e.includes("{{")?e.replace(ao,(r,n)=>{try{const o=ot(n.trim())({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid,$item:t.$item,$index:t.$index,$fn:t.$fn});return o==null?"":String(o)}catch(o){const s=o instanceof Error?o.message:String(o);throw new dr(`Failed to evaluate '{{${n.trim()}}}': ${s}`)}}):e}function ur(e,t){return typeof e=="function"?st(e,t):Rr(e)?lo(e,t):typeof e=="string"?ir(e,t):e}function fo(e,t,r,n){return typeof e=="function"?st(e,t):ee(e)?t.widgetFlags[r]?.[n]:typeof e=="string"?ir(e,t):e}function po(e,t){return typeof e=="function"?st(e,t):e}function it(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 ho(e){return e.startsWith("$form")||e.startsWith("$meta")||e.startsWith("$errors")||e.startsWith("$item")||e.startsWith("$index")||e.startsWith("$fn")||e==="$formIsInvalid"}function mo(e,t){return e&&Object.keys(e).reduce((r,n)=>{const o=String(e[n]);if(ho(o))try{const s=ot(o)({$form:t.$form,$meta:t.$meta,$errors:t.$errors,$formIsInvalid:t.$formIsInvalid,$item:t.$item,$index:t.$index,$fn:t.$fn});r[n]=s??o}catch(s){const i=s instanceof Error?s.message:String(s);throw new dr(`Failed to evaluate i18n param '${o}': ${i}`)}else r[n]=o;return r},{})}class go{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){const n=_(this.previous,t);if(ye(n,r)){Te(this.current,t,n);return}Te(this.current,t,r),this._changed=!0}}function yo(e,t,r,n,o){return{sortedStates:[...e.currentStates].sort((s,i)=>i.length-s.length),widgetPropOverrides:e.widgetPropOverrides,widgetFlags:e.widgetFlags,$form:e.data,$meta:e.meta,$formIsInvalid:r,$errors:n,localization:t,$fn:o}}function vo(e,t){if(t in e)return!0;const r=`${t}.`;return Object.keys(e).some(n=>n.startsWith(r))}function cr(e){return Array.from(new Set(e.map(t=>t.split(".")[0])))}function $o(e,t,r){const n=t.map(o=>`[${o}]`).join("");return e.filter(o=>{const s=o.uid+n,i=r[s];return!i||i.hidden!==!0})}class dr extends Error{constructor(){super(...arguments),this.code=k.resolveStringInterpolationError,this.name="StringInterpolationError"}}const So=e=>{const t=Ao(e.resolvedSources),r=ue(e.widgetPropOverrides,i=>i in e.resolvedSources),n=ue(e.touchedControls,i=>t.has(i)),o=ue(e.validations,i=>t.has(i)),s=ue(e.injectedValidations,i=>t.has(i));return r===e.widgetPropOverrides&&n===e.touchedControls&&o===e.validations&&s===e.injectedValidations?e:{...e,widgetPropOverrides:r,touchedControls:n,validations:o,injectedValidations:s}};function Ao(e){const t=new Set;for(const r of Object.values(e)){const n=L(r);n!==void 0&&t.add(n)}return t}function ue(e,t){const r=Object.keys(e).filter(t);if(r.length===Object.keys(e).length)return e;const n={};for(const o of r)n[o]=e[o];return n}const wo=e=>{const t=Object.keys(e.resolvedSources),r={};let n=t.length!==Object.keys(e.calculatedWidgets).length;for(const o of t){const s=e.calculatedWidgets[o];s?r[o]=s:(r[o]={source:e.resolvedSources[o],current:{}},n=!0)}return n?{...e,calculatedWidgets:r}:e},Eo=({lang:e},t)=>{const r={...Dt(e),formName:t.payload.formName};let n=t.payload.formDef,o={status:"ok"};if(typeof n=="string"){try{n=JSON.parse(n)}catch(a){const p=a,g=k.initializeParseError;o={status:"errored",message:`[${g}] ${p.message}`,code:g}}if(o.status==="errored")return{...r,formHealth:o}}let s=n;if(Array.isArray(n.form)){const a=n.form;s={...n,form:{uid:"",type:"flex",kind:"layout",children:a}}}const i=Wt.decode(s);if(i.isOk()){o={status:"ok"};let a={};try{a=Be([i.value.form]).reduce((p,g)=>{const I=g.uid;if(p[I])throw{existingWidget:p[I],newWidget:g};return p[I]=g,p},{})}catch(p){o=Io(p.existingWidget,p.newWidget),a={}}return jo(a,i.value.states),{...r,formDef:i.value,flatForm:a,...Ne(a,{}),formHealth:o}}const u=Co(n);if(u)return{...r,formHealth:u};const d=k.initializeUnknownError,l=i.issues.map(a=>`${a.path.length>0?kt(a.path):"root"}: ${a.message}`).join("; ");return{...r,formHealth:{status:"errored",message:`[${d}] ${l}`,code:d}}};function lr(e,t){return{status:"errored",code:e,message:`[${e}] ${t}`}}function Oo(){return"Malformed form definition. Pass it directly as formDef - `config={{ formDef: { states, form: [...] } }}`. Do NOT wrap it in an extra `{ form: ... }`."}function Co(e){if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e.form;return t&&typeof t=="object"&&!Array.isArray(t)&&!H(t)?lr(k.initializeMalformedFormShapeError,Oo()):null}function Io(e,t){const r=o=>F(o)?` at "${o.path}"`:"",n=`Duplicate UID "${t.uid}": Assigned to widget "${e.type}"${r(e)} and "${t.type}"${r(t)}.`;return lr(k.initializeUidCollisionError,n)}function jo(e,t){const r=new Set(Object.keys(t??{})),n=new Map;for(const s of Object.values(e)){const i=[],u=s.include;u&&Array.isArray(u.in)&&i.push(...u.in);const d=s.exclude;d&&Array.isArray(d.from)&&i.push(...d.from);for(const l of i){if(r.has(l))continue;const a=n.get(l)??[];a.push(s.uid||"(unknown)"),n.set(l,a)}}if(n.size===0)return;const o=r.size?[...r].join(", "):"(none declared)";for(const[s,i]of n)console.error(`[GolemUI] include/exclude references undefined state "${s}" (on ${i.join(", ")}); these widgets will stay hidden. Declared states: ${o}. Fix: declare "${s}" in formConfig.states, or correct the name.`)}function ko(e,t){const{path:r,issues:n}=t.payload,o=n?.length?{touched:!0,touchedControls:{...e.touchedControls,[r]:!0}}:{};return{...e,...o,injectedValidations:{...e.injectedValidations,[r]:n}}}const Fo=(e,{payload:t})=>{const r="path"in t?Wo(e,t.path):Po(e,t.uid);if(r===void 0)return e;const n=e.widgetPropOverrides[r]||{};return{...e,widgetPropOverrides:{...e.widgetPropOverrides,[r]:{...n,[t.prop]:t.value}}}};function Po(e,t){if(t in e.resolvedSources)return t;console.warn(`Widget with uid "${t}" not found`)}function Wo(e,t){const r=Object.values(e.calculatedWidgets).find(({source:o,current:s})=>(L(s)??L(o))===t);if(r)return r.source.uid;const n=Object.keys(e.resolvedSources).find(o=>L(e.resolvedSources[o])===t);if(n!==void 0)return n;console.warn(`Input with path "${t}" not found`)}const Do=(e,t)=>({...e,data:{...t.payload.data}}),To=(e,t)=>({...e,formHealth:t.payload.formHealth}),No=(e,t)=>({...e,lang:t.payload.lang}),Vo=(e,t)=>({...e,meta:{...t.payload.meta}}),Ro=(e,t)=>({...e,data:Nt(e.data,t.payload.path,t.payload.data)}),ar=Symbol("filterMap.skip");function Lo(e,t){const r=[];for(let n=0;n<e.length;n++){const o=t(e[n],n,e);o!==ar&&r.push(o)}return r}function Mo(e,t,r){for(let n=0;n<e.length;n++)t(e[n],n,e)&&r(e[n],n,e)}function _o(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}const Uo=(e,t)=>r=>{const n=Lo(Object.values(r.calculatedWidgets),({current:s})=>F(s)?s:ar),o=r.validations;return{...r,validations:n.reduce((s,i)=>{if(s[i.path]=null,i.validator){const u=e(i.validator,t),d=_(r.data,i.path),l=Ct(u,d);s[i.path]=It(l)?null:l.issues.map(a=>a.message)}return Array.isArray(s[i.path])&&Array.isArray(o[i.path])&&_o(s[i.path],o[i.path],(u,d)=>u===d)&&(s[i.path]=o[i.path]),s},{})}},bo=({validators:e,validateOn:t,localization:r,functions:n})=>{const o=Bo(r,n),s=Uo(e,r),i=sr(r,n),u=l=>wt(l,o,s,!1),d=l=>wt(l,o,s,!0);return(l,a)=>{switch(a.type){case"INITIALIZE":return Eo(l,a);case"SET_DATA":return u(Do(l,a));case"SET_META":return u(Vo(l,a));case"SET_WIDGET_DATA":return u(Ro(l,a));case"SET_LANGUAGE":return i(No(l,a));case"OVERRIDE_WIDGET_PROP":{const p=Fo(l,a);if(p===l)return l;const g=u(p);return Xo(g,a)?s(g):g}case"SET_FORM_HEALTH":return To(l,a);case"VALIDATE_ALL":return d(s(Ko(l)));case"ATTEMPT_VALIDATION":{if(!xo(t,a.payload.reason))return l;const p={...l,touched:!0,touchedControls:{...l.touchedControls,[a.payload.path]:!0}};return d(s(p))}case"INJECT_VALIDATION_ISSUES":return ko(l,a);default:return Mr(a)}}},Ho=new Set([k.calculateCurrentStateError,k.calculateWidgetFlagsError,k.calculateWidgetPropsError,k.resolveStringInterpolationError]),zo=e=>e.formHealth.status==="errored"&&!Ho.has(e.formHealth.code);function Bo(e,t){const r=Kn(t),n=Xn(t),o=sr(e,t);return function(i){if(zo(i))return i;const u=d=>({...i,formHealth:d});try{let d=i.formHealth.status==="ok"?i:{...i,formHealth:{status:"ok"}};d=Kr(d),d=So(d);const l=Ae(d);return d=r(d,l),d.formHealth.status!=="ok"?u(d.formHealth):(d=n(d,l),d=wo(d),d=o(d,l),d.formHealth.status==="ok"?d:u(d.formHealth))}catch(d){const l=k.calculateWidgetFlagsError;return u({status:"errored",code:l,message:`[${l}] ${d.message}`})}}}function wt(e,t,r,n){const o=a=>n?Et(a):a,s=e.resolvedSources,i=e.widgetFlags;let u=t(e);if(!u.allControlsValidated||u.formHealth.status!=="ok")return o(u);const d=Go(u,s,i);if(d.length===0)return o(u);const l={...u.touchedControls};for(const a of d)l[a]=!0;return u={...u,touchedControls:l},Et(t(r(u)))}function Go(e,t,r){const n=[];for(const[o,s]of Object.entries(e.resolvedSources)){const i=L(s);if(i===void 0||e.widgetFlags[o]?.hidden===!0||e.touchedControls[i]===!0)continue;const u=t[o]===void 0,d=r[o]?.hidden===!0;(u||d)&&n.push(i)}return n}function Ko(e){const t={};for(const{source:r,current:n}of Object.values(e.calculatedWidgets)){const o=L(n)??L(r);o!==void 0&&(t[o]=!0)}return{...e,touched:!0,allControlsValidated:!0,touchedControls:t}}function xo(e,t){return e==="eager"||t===e||Array.isArray(e)&&e.includes(t)}function Xo(e,t){if(!e.touched)return!1;let r;if("path"in t.payload)r=t.payload.path;else{const n=e.calculatedWidgets[t.payload.uid]?.current;n&&F(n)&&(r=n.path)}return r!==void 0&&e.touchedControls[r]===!0}function Et(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(o=>{const s=e.injectedValidations[o];return Array.isArray(s)&&s.length>0});return n!==void 0?{...e,isFormValid:!1}:(n=r.find(o=>{const s=e.validations[o];return Array.isArray(s)&&s.length>0}),n!==void 0?{...e,isFormValid:!1}:{...e,isFormValid:!0})}function Jo(e=[],t,r,n,o={}){const s=new T.BehaviorSubject(Dt(n.lang)),i=s.asObservable().pipe(T.distinctUntilChanged()),u=bo({validators:t,validateOn:r,localization:n,functions:o});function d(g){const I=s.getValue(),Ce=u(I,g);s.next(Ce)}let l=d;const a={getState:()=>s.getValue(),dispatch:g=>l(g)};return l=e.map(g=>g(a)).reduceRight((g,I)=>I(g),d),{state$:i,dispatch:l,getState:()=>s.getValue()}}class Qo{constructor(){this.widgetRegistry=new le,this.store={},this.events$=new T.Subject,this.submit$=new T.Subject,this.itemRenderers={},this.dependencies={}}initialize(t,r=[],n,o,s,i=Tt(),u,d={}){this.localization=i,this.dependencies=u,this.widgetRegistry.setWidgetLoaders(t),this.itemRenderers=s,this.store=Jo(r,n,o,i,d)}emitEvent(t,r,n){const s=this.store.getState().currentStates.filter(i=>r.on?.[`${t}.${i}`]!==void 0);if(this.attemptValidation(t,r),s.length>0)s.forEach(i=>{const u=r.on?.[`${t}.${i}`];u&&this.events$.next({name:u,data:je(this.store.getState()),detail:n??void 0,callback:d=>{this.store.dispatch(d)}})});else{const i=r.on?.[t];i&&this.events$.next({name:i,data:je(this.store.getState()),detail:n,callback:u=>{this.store.dispatch(u)}})}}emitSubmitEvent(){this.store.dispatch({type:"VALIDATE_ALL"}),this.store.getState().isFormValid&&this.submit$.next({data:je(this.store.getState()),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 qo(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=>s=>{o(s),n&&n.send(s,t.getState())}}}const Zo=T.pipe(T.map(e=>e.formHealth),T.distinctUntilChanged((e,t)=>e.status!==t.status?!1:e.status==="errored"&&t.status==="errored"?e.message===t.message&&e.code===t.code:!0)),Yo=e=>e.pipe(Zo);function es(e,t){return hr(e,t,pr(e,t),void 0)}function fr(){const e=new Map;return(t,r)=>{const n=pr(t,r),o=e.get(r);if(o&&os(o.slices,n))return o.viewModel;const s=hr(t,r,n,o);return e.set(r,{slices:n,viewModel:s}),s}}const ts=e=>t=>{const r=fr();return t.pipe(T.map(n=>r(n,e)),T.distinctUntilChanged())},rs=[],Ot=[],ns=[];function pr(e,t){const r=ss(e,t);return[e.calculatedWidgets[t],e.lang,r===void 0?void 0:_(e.data,r),r!==void 0&&e.touched?e.validations[r]:null,r!==void 0&&e.touched?e.injectedValidations[r]:null,r!==void 0&&e.touchedControls[r]===!0,e.touched&&!e.isFormValid,e.widgetFlags[t]?.hidden===!0]}function os(e,t){return e.every((r,n)=>Object.is(r,t[n]))}function hr(e,t,r,n){const[o,s,i,u,d,l,a,p]=r,g=n===void 0||!Object.is(n.slices[0],o),I=n===void 0||!Object.is(n.slices[2],i),Ce=n===void 0||!Object.is(n.slices[3],u)||!Object.is(n.slices[4],d),Ie=o?.current;return{uid:t,widget:Ie,children:g?is(e,t,Ie):n.viewModel.children,rows:g||I?us(e,t,Ie,i):n.viewModel.rows,lang:s,value:i,errors:Ce?cs(u,d):n.viewModel.errors,touched:l,formInvalid:a,hidden:p}}function ss(e,t){return e.resolvedSources[t]?.path}function is(e,t,r){if(r===void 0||!H(r))return rs;const n=r.children,o=ne(t);if(o.length===0)return n;const s=o.map(i=>`[${i}]`).join("");return n.map(i=>e.resolvedSources[`${i.uid}${s}`]??i)}function us(e,t,r,n){if(r===void 0||!Array.isArray(n))return Ot;const o=e.resolvedSources[t];if(o===void 0||!we(o))return Ot;const s=o.props.template.uid,i=ne(t);return n.map((u,d)=>{const l=Ke(s,[...i,d]);return e.resolvedSources[l]}).filter(u=>u!==void 0)}function cs(e,t){return(e?.length??0)+(t?.length??0)===0?ns:[...e??[],...t??[]]}let mr=!1;function ds(){mr=!0}function ls(){return mr}function as(e,t,r){if(!ls())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`)}const fs=()=>crypto.randomUUID().slice(0,8);exports.FormContext=Qo;exports.assertNoPropCollisions=as;exports.cloneObject=q;exports.createWidgetViewModelReader=fr;exports.defineForm=Nr;exports.devToolsMiddleware=qo;exports.enableDevMode=ds;exports.errorCodes=k;exports.filterTap=Mo;exports.formEventNames=Vr;exports.formHealth=Yo;exports.getDirectionFromLanguage=Lr;exports.identityTranslator=Tt;exports.isStandardValidateSuccess=It;exports.makeRepeaterItemConfig=Ge;exports.preloadFormWidgets=Dr;exports.shortUUID=fs;exports.standardValidate=Ct;exports.widgetViewModel=es;exports.widgetViewModel$=ts;
@@ -12,6 +12,7 @@ export declare class WidgetRegistry<ComponentType> {
12
12
  * Failed requests are automatically cleared so you can retry them later.
13
13
  */
14
14
  private static sharedCache;
15
+ private static resolvedCache;
15
16
  private widgetLoaders;
16
17
  private _ready;
17
18
  /**
@@ -20,4 +21,29 @@ export declare class WidgetRegistry<ComponentType> {
20
21
  get ready(): boolean;
21
22
  setWidgetLoaders(widgetLoaders: WidgetLoaders<ComponentType>): void;
22
23
  loadWidget(widget: NonFunctionWidget['type']): Promise<ComponentType>;
24
+ /**
25
+ * Loads the given widget types (default: every configured type) and stores each
26
+ * resolved component for synchronous access through `getIfLoaded`.
27
+ * A failed loader rejects the returned promise, stores nothing, and stays retryable.
28
+ */
29
+ preloadWidgets(types?: NonFunctionWidget['type'][]): Promise<void>;
30
+ /**
31
+ * Returns the resolved component for the given widget type, or `undefined` when it
32
+ * was never preloaded. Never starts a load.
33
+ */
34
+ getIfLoaded(widget: NonFunctionWidget['type']): ComponentType | undefined;
23
35
  }
36
+ /**
37
+ * Loads every widget component of a form config so that a later render can read
38
+ * them synchronously. Rendering a form in an environment that cannot wait for
39
+ * dynamic imports (a server render is one) requires this call to finish first.
40
+ *
41
+ * @param config - Any object that contains the `widgetLoaders` a form is
42
+ * configured with, e.g. a `FormInitConfig`.
43
+ * @example
44
+ * await preloadFormWidgets(config);
45
+ * // every widget component of `config.widgetLoaders` is now available synchronously
46
+ */
47
+ export declare function preloadFormWidgets<ComponentType>(config: {
48
+ widgetLoaders: WidgetLoaders<ComponentType>;
49
+ }): Promise<void>;
package/lib/i18n.d.ts CHANGED
@@ -89,15 +89,11 @@ export declare const isTranslationConfig: (value: unknown) => value is Translati
89
89
  */
90
90
  export declare function getDirectionFromLanguage(lang: string): 'ltr' | 'rtl';
91
91
  /**
92
- * Default no-op translator.
92
+ * Default translator used when no i18n system is configured. Returns every
93
+ * translation key unchanged, but still supports `setLang` and subscriber
94
+ * notifications.
93
95
  *
94
- * This implementation performs no localization and simply returns the
95
- * translation key unchanged. It is intended for use as a safe default
96
- * when no i18n system is configured while still supporting runtime language
97
- * changes and subscriber notifications.
98
- *
99
- * Call `setLang` to change the active language and notify any subscribed listeners.
100
- *
101
- * @param lang The initial BCP 47 language tag; defaults to `navigator.language || 'en-US'`.
96
+ * @param lang The initial BCP 47 language tag. Defaults to `navigator.language`
97
+ * when a navigator global exists, otherwise to 'en-US' (e.g. server runtimes)
102
98
  */
103
99
  export declare const identityTranslator: (lang?: string) => MutableI18nTranslator;
@@ -1,16 +1,11 @@
1
1
  import { FormWidget } from '../form-widget';
2
2
  /**
3
- * Assigns a position-based uid to every widget in the tree that has none.
4
- *
5
- * The generated format is a dot-separated index path prefixed with '#', with a
6
- * 't' segment for a repeater template, e.g. '#0.2.t.1' is the second template
7
- * child of the repeater found at position 2 of the root layout. The format must
8
- * never contain '[<digits>]' because repeater item uids append '[index]' and
9
- * are parsed back with a regex.
10
- *
11
- * @param root - The decoded root widget of a form. Widgets with an explicit uid
12
- * are left untouched, function widgets are skipped because the decoder assigns
13
- * their uid directly on the function object.
3
+ * Assigns a position-based uid to every widget in the tree that has none, e.g. '#0.2.t.1'
4
+ * (dot-separated indexes, 't' for a repeater template, a final 'f' for a function widget).
5
+ * The format must never contain '[<digits>]' because repeater item uids append '[index]'
6
+ * and are parsed back with a regex.
7
+ * A function widget's uid is written onto the function object itself, so a function reused
8
+ * across decodes keeps the uid of its first decode.
14
9
  *
15
10
  * @example
16
11
  * const decodedForm = formDefDecoder.parse(rawFormDef);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@golemui/core",
3
- "version": "1.4.0",
3
+ "version": "1.5.0-rc.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"