@kayr/umbika-web-renderer 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +46 -2
  3. package/THIRD_PARTY_LICENSES.txt +20 -0
  4. package/dist/browser/umbika.min.css +23 -0
  5. package/dist/browser/umbika.min.d.mts +437 -0
  6. package/dist/browser/umbika.min.d.ts +437 -0
  7. package/dist/browser/umbika.min.js +60 -0
  8. package/dist/browser/umbika.min.mjs +60 -0
  9. package/dist/casconda.d.ts +2 -0
  10. package/dist/casconda.d.ts.map +1 -0
  11. package/dist/contracts.d.ts +165 -0
  12. package/dist/contracts.d.ts.map +1 -0
  13. package/dist/dom-identity.d.ts +17 -0
  14. package/dist/dom-identity.d.ts.map +1 -0
  15. package/dist/field-presentation.d.ts +26 -0
  16. package/dist/field-presentation.d.ts.map +1 -0
  17. package/dist/index.d.ts +16 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/layout.d.ts +25 -0
  20. package/dist/layout.d.ts.map +1 -0
  21. package/dist/mount.d.ts +14 -0
  22. package/dist/mount.d.ts.map +1 -0
  23. package/dist/render-nodes.d.ts +18 -0
  24. package/dist/render-nodes.d.ts.map +1 -0
  25. package/dist/renderers/multi-select.d.ts +18 -0
  26. package/dist/renderers/multi-select.d.ts.map +1 -0
  27. package/dist/renderers/object.d.ts +6 -0
  28. package/dist/renderers/object.d.ts.map +1 -0
  29. package/dist/renderers/output.d.ts +6 -0
  30. package/dist/renderers/output.d.ts.map +1 -0
  31. package/dist/renderers/select.d.ts +6 -0
  32. package/dist/renderers/select.d.ts.map +1 -0
  33. package/dist/renderers/table.d.ts +6 -0
  34. package/dist/renderers/table.d.ts.map +1 -0
  35. package/dist/renderers/text.d.ts +8 -0
  36. package/dist/renderers/text.d.ts.map +1 -0
  37. package/dist/row-details.d.ts +89 -0
  38. package/dist/row-details.d.ts.map +1 -0
  39. package/dist/standalone/contracts.d.ts +77 -0
  40. package/dist/standalone/contracts.d.ts.map +1 -0
  41. package/dist/standalone/index.d.ts +7 -0
  42. package/dist/standalone/index.d.ts.map +1 -0
  43. package/dist/standalone/mount.d.ts +9 -0
  44. package/dist/standalone/mount.d.ts.map +1 -0
  45. package/dist/summary.d.ts +29 -0
  46. package/dist/summary.d.ts.map +1 -0
  47. package/dist/tags.d.ts +32 -0
  48. package/dist/tags.d.ts.map +1 -0
  49. package/package.json +78 -4
  50. package/src/casconda.js +10 -0
  51. package/src/contracts.js +79 -0
  52. package/src/dom-identity.js +31 -0
  53. package/src/field-presentation.js +71 -0
  54. package/src/index.js +9 -0
  55. package/src/layout.js +176 -0
  56. package/src/mount.js +569 -0
  57. package/src/render-nodes.js +77 -0
  58. package/src/renderers/multi-select.js +211 -0
  59. package/src/renderers/object.js +43 -0
  60. package/src/renderers/output.js +87 -0
  61. package/src/renderers/select.js +104 -0
  62. package/src/renderers/table.js +344 -0
  63. package/src/renderers/text.js +82 -0
  64. package/src/row-details.js +305 -0
  65. package/src/standalone/contracts.js +22 -0
  66. package/src/standalone/index.js +5 -0
  67. package/src/standalone/mount.js +128 -0
  68. package/src/summary.js +135 -0
  69. package/src/tags.js +69 -0
  70. package/styles/base.css +432 -0
  71. package/styles/standalone.css +2 -0
  72. package/styles/themes/default.css +99 -0
  73. package/vendor/LICENSE +21 -0
  74. package/vendor/README.md +33 -0
  75. package/vendor/casconda.min.d.mts +340 -0
  76. package/vendor/casconda.min.d.ts +340 -0
  77. package/vendor/casconda.min.mjs +1 -0
@@ -0,0 +1,60 @@
1
+ /*! Umbika and Casconda
2
+ MIT License
3
+
4
+ Copyright (c) 2026 Kayr
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+
24
+ Copyright (c) 2013 Stephen Oney, https://ericsmekens.github.io/jsep/
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining
27
+ a copy of this software and associated documentation files (the
28
+ "Software"), to deal in the Software without restriction, including
29
+ without limitation the rights to use, copy, modify, merge, publish,
30
+ distribute, sublicense, and/or sell copies of the Software, and to
31
+ permit persons to whom the Software is furnished to do so, subject to
32
+ the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be
35
+ included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
41
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
42
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
43
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
44
+ */
45
+ function ie(e,t,r,n){return On(n),nt(e,t,r,n,[])}function nt(e,t,r,n,i){let o=[...i,...n],[a,...s]=n,l=e.find(f=>f.id===a);if(!l||!a)return ye(o);let c=B(i,a);switch(l.type){case"object":{let f=t[l.id];return _n(f)?s.length===0?{kind:"object",node:l,path:c,values:f}:nt(l.children,f,r,s,c):ye(o)}case"table":{let f=t[l.id];if(!Array.isArray(f))return ye(o);if(s.length===0)return{kind:"table",node:l,path:c,rows:f};let[p,...g]=s,E=f.findIndex(y=>r.get(y)===p),v=f[E];if(E===-1||!v||!p)return ye(o);let $=B(c,p);return g.length===0?{kind:"row",node:l,path:$,rows:f,index:E,row:v}:nt(l.children,v,r,g,$)}default:return s.length>0?ye(o):{kind:"leaf",node:l,path:c,parentValues:t}}}function je(e,t,r,n){let i=ie(e,t,r,n);if(i.kind!=="leaf")throw new Error(`field path ${JSON.stringify(n)} identifies a ${i.kind}`);return i}function Vt(e,t,r,n){let i=ie(e,t,r,n);if(i.kind!=="table")throw new Error(`table path ${JSON.stringify(n)} identifies a ${i.kind}`);return i}function zt(e,t,r,n){let i=ie(e,t,r,n);if(i.kind!=="row")throw new Error(`row path ${JSON.stringify(n)} identifies a ${i.kind}`);return i}function Y(e,t){let r=e.get(t);if(!r)throw new Error("missing identity for table row");return r}function N(e){return JSON.stringify(e)}function B(e,t){return e.length===0?[t]:[e[0],...e.slice(1),t]}function oe(e){return[e[0],...e.slice(1)]}function On(e){if(!Array.isArray(e)||e.length===0||e.some(t=>typeof t!="string"||t.length===0))throw new TypeError("field path must be a non-empty array of ID segments")}function ye(e){throw new Error(`unknown field path ${JSON.stringify(e)}`)}function _n(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Kt(e){if(e!==null&&typeof e=="object"&&!Array.isArray(e)&&(Object.getPrototypeOf(e)===Object.prototype||Object.getPrototypeOf(e)===null)&&!Object.hasOwn(e,"value"))throw new TypeError("rich input must have an own value property");let t=structuredClone(e),r=t!==null&&typeof t=="object"&&!Array.isArray(t)&&Object.hasOwn(t,"value")?t.value:t;return{value:t,answer:r}}function Jt(e,t){if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(typeof e[r]!="string"||typeof t[r]!="string"||e[r]!==t[r])return!1;return!0}return e!==null&&typeof e=="object"||t!==null&&typeof t=="object"?!1:Object.is(e,t)}function it(e,t){if(e!==null&&(typeof e=="object"||typeof e=="function")&&typeof e.then=="function")throw new TypeError(`${t} must complete synchronously`);return e}function Wt(e){let t=e.split(".");if(t.some(r=>r.trim()===""))throw new TypeError(`malformed reference ${e}`);return t}function Ht(e,t,r,n,i,o,a){let s=[];for(let E=r.context;E;E=E.parent)E.kind!=="table"&&s.push(E);function l(E){let v=s[E];if(v)return new Proxy(Object.create(null),{get($,y){return y==="current"?v.data:y==="parent"?l(E+1):y==="form"?r.form:typeof y=="string"?v.data[y]:void 0},ownKeys(){return[...new Set([...Reflect.ownKeys(v.data),"current","parent","form"])]},getOwnPropertyDescriptor($,y){if(y==="current"||y==="parent"||y==="form"||Object.hasOwn(v.data,y))return{configurable:!0,enumerable:!0}}})}let c={vars:r.vars,value:t,current:r.parent,parent:l(1),form:r.form,context:r.context};function f(E){let v=Wt(E);if(!["value","current","parent","form","context","vars"].includes(v[0]??""))throw new TypeError(`unknown input scope root ${v[0]}`);let $=c;for(let y of v)$=$?.[y];return $}function p(E){let v=Wt(E),$=0;if(v[0]==="form")$=s.length-1,v.shift();else if(v[0]==="current")v.shift();else for(;v[0]==="parent";)$++,v.shift();let y=s[$];if(!y)throw new Error(`destination ${E} traverses above root`);if(v.length===0)throw new Error(`destination ${E} identifies a container`);return[...y.path,...v]}function g(E,v){let $=!0;function y(){if(!$)throw new Error("input setter facade has expired")}function A(){throw y(),new Error("input setter cannot mutate structure, descriptors or prototypes")}function O(x,S=!1){return new Proxy(Object.create(null),{get(b,u){if(y(),typeof u!="string")return;if(S){let d=s.findIndex(_=>N(_.path)===N(x));if(u==="current")return O(x);if(u==="form")return O([],!0);if(u==="parent"){let _=s[d+1];return _?O(_.path,!0):void 0}}let h=x.length?ie(n,i,o,x):void 0;if(h?.kind==="table"){if(u==="length")return h.rows.length;let d=/^(0|[1-9]\d*)$/.test(u)?h.rows[Number(u)]:void 0;if(!d)throw new Error(`unknown table position ${u}`);return O([...x,Y(o,d)])}let w=[...x,u],m=ie(n,i,o,w);return m.kind==="leaf"?structuredClone(m.parentValues[m.node.id]):O(w)},set(b,u,h){return y(),typeof u!="string"||S&&["current","parent","form"].includes(u)?A():(a([...x,u],h),!0)},deleteProperty:A,defineProperty:A,setPrototypeOf:A,preventExtensions:A})}try{it(E(O(s[0]?.path??[],!0),v),"setter")}finally{$=!1}}if(e.node.type!=="calculated")for(let[E,v]of(e.node.onChange?.copy??[]).entries()){let $="when";try{let y=typeof v.when=="function"?it(v.when(c),"when"):v.when??!0;if(typeof y!="boolean")throw new TypeError("when must return a boolean");if(!y)continue;$="value";let A=typeof v.value=="function"?it(v.value(c),"resolver"):f(v.value);$="destination",typeof v.to=="function"?g(v.to,A):a(p(v.to),A)}catch(y){let A=new Error(`input ${N(e.path)} copy ${E} ${$}${typeof v.to=="string"?` (${v.to})`:" (setter)"}: ${y instanceof Error?y.message:String(y)}`,{cause:y});throw Object.assign(A,{sourcePath:[...e.path],actionIndex:E,stage:$,destination:v.to}),A}}}function Xt(e,t){let r=new Map,n=[];function i(o,a){let s=N(a);if(r.has(s))return r.get(s);let l=n.findIndex(f=>N(f)===s);if(l!==-1){let f=[...n.slice(l),a];throw new Error(`Circular calculation: ${f.map(N).join(" \u2192 ")}`)}let c=e.get(s);if(!c)throw new Error(`missing calculation scope for ${s}`);n.push(a);try{let f=o.calculate(c);return $n(f,a),r.set(s,f),f}finally{n.pop()}}return{resolve:i,clearCalculatedValues(){for(let{node:o,parentValues:a}of t.values())delete a[o.id]},resolveAllCalculations(){for(let{node:o,path:a}of t.values())i(o,a)},commitCalculatedResults(){for(let[o,a]of r){let s=t.get(o);if(!s)throw new Error(`missing calculated field for ${o}`);s.parentValues[s.node.id]=a}}}}function $n(e,t){if(e!=null&&typeof e!="string"&&typeof e!="number"&&typeof e!="boolean")throw new TypeError(`calculation at ${JSON.stringify(t)} must return a primitive value`)}function Zt(e,t,r){return{relevant:r,required:r&&ot(e.required,!1,t,"required"),readOnly:e.type==="calculated"||r&&Gt(e,t)}}function we(e,t){return ot(e.relevant,!0,t,"relevant")}function Yt(e,t,r){let n=e;for(let i=0;i<t.length;i+=1){let o=n.find(({id:l})=>l===t[i]),a=N(t.slice(0,i+1)),s=r.get(a);if(!o||!s)throw new Error(`missing condition scope for ${a}`);if(!we(o,s))return!1;if(o.type==="object"||o.type==="table")n=o.children,o.type==="table"&&(i+=1);else return Gt(o,s)}throw new Error(`missing field for ${N(t)}`)}function Gt(e,t){return ot(e.readOnly,!1,t,"readOnly")}function er(e,t,r,n){let i=new Map,o=new WeakMap,a=new Map,s=new Map,l=null,c=O(e,t,[]),f={kind:"form",data:c,path:[],parent:null,id:null,index:null,previous:null};a.set(N([]),f);function p(x,S,b,u,h){for(let w of x){let m=B(h,w.id),d=N(m);if(g(w,b,u,m,d),w.type==="calculated"&&E(w,S,m,d),w.type==="object"){v(w,S,u,m,d);continue}w.type==="table"&&$(w,S,u,m,d)}}function g(x,S,b,u,h){if(i.has(h))return;let w={form:c,parent:S,context:b,vars:n};if(x.type==="table"){i.set(h,Object.freeze({...w,get value(){return S[x.id]},get rows(){return S[x.id]}}));return}let m=Object.freeze({...w,get value(){return S[x.id]}});i.set(h,m),x.type==="object"&&x.validate!==void 0&&o.set(m,Cn(x.validate,u,m))}function E(x,S,b,u){s.set(u,{node:x,path:b,parentValues:S})}function v(x,S,b,u,h){let w=S[x.id],m=a.get(h);m||(m={kind:"object",data:O(x.children,w,u),path:u,parent:b,id:null,index:null,previous:null},a.set(h,m)),p(x.children,w,m.data,m,u)}function $(x,S,b,u,h){let w=S[x.id],m=a.get(h);m||(m={kind:"table",data:[],path:u,parent:b,id:null,index:null,previous:null},a.set(h,m));let d=[];for(let j of w){let R=y(x,w,j,m,u),k=R.data;d.push(k),p(x.children,j,k,R,R.path)}let _=m.data;_.splice(0,_.length,...d)}function y(x,S,b,u,h){let w=Y(r,b),m=B(h,w),d=N(m),_=a.get(d);return _||(_={kind:"row",data:O(x.children,b,m),path:m,parent:u,id:w,get index(){return S.indexOf(b)},get previous(){let j=S.indexOf(b);if(j<=0)return null;let R=S[j-1],k=Y(r,R);return a.get(N(B(h,k)))??null}},a.set(d,_)),_}function A(){s.clear(),p(e,t,c,f,[])}return A(),{scopesByPath:i,objectValidators:o,beginEvaluation(){return l=Xt(i,s),l},endEvaluation(){l=null},sync:A,removeBelow(x){Qt(i,x),Qt(a,x)}};function O(x,S,b){let u=Object.create(null);for(let h of x){let w=B(b,h.id);Object.defineProperty(u,h.id,{enumerable:!0,get(){return h.type==="calculated"&&l?l.resolve(h,w):h.type==="object"||h.type==="table"?a.get(N(w))?.data:Object.hasOwn(S,h.id)?S[h.id]:void 0}})}for(let h of Object.keys(S))Object.hasOwn(u,h)||Object.defineProperty(u,h,{enumerable:!0,get(){return S[h]}});return u}}function Cn(e,t,r){let n,i=Object.freeze({form:r.form,parent:r.parent,context:r.context,vars:r.vars,get value(){return r.value},isRelevant(o){if(!n)throw new Error("isRelevant is only available during object validation");let a=typeof o=="string"?n.get(N(B(t,o))):void 0;if(a===void 0)throw new Error(`object ${N(t)} has no direct child ${JSON.stringify(o)}`);return a}});return o=>{n=o;try{return e(i)}finally{n=void 0}}}function Qt(e,t){for(let r of e.keys()){let n=JSON.parse(r);n.length>=t.length&&t.every((i,o)=>n[o]===i)&&e.delete(r)}}function ot(e,t,r,n){if(e===void 0)return t;if(typeof e=="boolean")return e;if(typeof e!="function")throw new TypeError(`${n} condition must be a boolean or function`);let i=e(r);if(typeof i!="boolean")throw new TypeError(`${n} condition must return a boolean`);return i}function tr(e,t,r,n,i=[]){let{value:o}=n;if(e.type==="multi-select"){if(o==null||Array.isArray(o)&&o.length===0)return r?[ce(t,"required",`${e.label} is required.`)]:[];if(!Array.isArray(o)||Sn(o))return[ce(t,"type",`${e.label} must be a list of option values.`)];if(new Set(o).size!==o.length||o.some(c=>!i.some(f=>f.value===c)))return[ce(t,"option",`${e.label} must contain only available options without duplicates.`)]}else{if(o==null||o==="")return r?[ce(t,"required",`${e.label} is required.`)]:[];if(e.type==="text"&&typeof o!="string")return[ce(t,"type",`${e.label} must be text.`)];if(e.type==="select"&&!i.some(s=>s.value===o))return[ce(t,"option",`${e.label} must be one of the available options.`)]}if(e.validate===void 0)return[];let a;switch(e.type){case"multi-select":a=e.validate(n);break;case"calculated":a=e.validate(n);break;default:a=e.validate(n)}return Ae(a,t,"field")}function Ae(e,t,r){if(e===void 0)return[];if(typeof e=="string"&&e.length>0)return[ce(t,"custom",e)];throw e instanceof Promise&&e.catch(()=>{}),new TypeError(`custom validator for ${r} ${JSON.stringify(t)} must return undefined or a non-empty string`)}function Sn(e){for(let t of e)if(typeof t!="string")return!0;return!1}function ce(e,t,r){return{path:[...e],code:t,message:r}}function Pe(e){rr(e,[])}function rr(e,t){let r=new Set;for(let n=0;n<e.length;n+=1){let i=e[n],o=t.length===0?`field ${n+1}`:`field ${n+1} under ${Te(t)}`;if(!De(i))throw new TypeError(`${o} must be an object`);if(typeof i.id!="string"||i.id.trim()==="")throw new TypeError(`${o} must have a non-empty id`);let a=[...t,i.id],s=t.length===0?`field "${i.id}"`:`field ${Te(a)}`;if(i.id==="__proto__")throw new TypeError(`${s} uses reserved id "__proto__"`);if(r.has(i.id))throw t.length>0?new TypeError(`parent ${Te(t)} has duplicate sibling id "${i.id}"`):new TypeError(`${s} has a duplicate id`);if(r.add(i.id),at(s,"relevant",i.relevant),Tn(s,i),i.type==="object"||i.type==="table"){An(i,a),rr(i.children,a);continue}if(typeof i.label!="string"||i.label.trim()==="")throw new TypeError(`${s} must have a non-empty label`);if(i.type==="calculated"){jn(s,i);continue}if(at(s,"required",i.required),at(s,"readOnly",i.readOnly),i.type!=="text"&&i.type!=="select"&&i.type!=="multi-select")throw new TypeError(`${s} has an unsupported type`);st(s,i.validate),(i.type==="select"||i.type==="multi-select")&&typeof i.options!="function"&&lt(s,i.options,!1)}}function jn(e,t){if(typeof t.calculate!="function")throw new TypeError(`${e} calculate must be a function`);if(Object.hasOwn(t,"required"))throw new TypeError(`${e} must not declare required`);if(Object.hasOwn(t,"readOnly"))throw new TypeError(`${e} must not declare readOnly`);if(Object.hasOwn(t,"options"))throw new TypeError(`${e} must not declare options`);st(e,t.validate)}function An(e,t){let r=`${e.type} ${Te(t)}`;if(e.label!==void 0&&(typeof e.label!="string"||e.label.trim()===""))throw new TypeError(`${r} label must be a non-empty string`);if(Object.hasOwn(e,"required"))throw new TypeError(`${r} must not declare required`);if(Object.hasOwn(e,"readOnly"))throw new TypeError(`${r} must not declare readOnly`);if(st(r,e.validate),!Array.isArray(e.children))throw new TypeError(`${r} must have a children array`)}function st(e,t){if(t!==void 0&&typeof t!="function")throw new TypeError(`${e} validate must be a function`)}function Te(e){return JSON.stringify(e)}function at(e,t,r){if(r!==void 0&&typeof r!="boolean"&&typeof r!="function")throw new TypeError(`${e} ${t} must be a boolean or function`)}function lt(e,t,r=!1){if(!Array.isArray(t)||!r&&t.length===0)throw new TypeError(`${e} must have at least one option`);let n=new Set;for(let i=0;i<t.length;i+=1){let o=t[i],a=`${e} option ${i+1}`;if(!De(o))throw new TypeError(`${a} must be an object`);if(typeof o.value!="string"||o.value.trim()==="")throw new TypeError(`${a} must have a non-empty string value`);if(n.has(o.value))throw new TypeError(`${e} has duplicate option value "${o.value}"`);if(n.add(o.value),typeof o.label!="string"||o.label.trim()==="")throw new TypeError(`${a} must have a non-empty label`)}}function De(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Tn(e,t){if(!Object.hasOwn(t,"onChange"))return;if(!["text","select","multi-select"].includes(String(t.type)))throw new TypeError(`${e} must not declare onChange`);let r=t.onChange;if(!De(r)||!Array.isArray(r.copy))throw new TypeError(`${e} onChange.copy must be an array`);for(let[n,i]of r.copy.entries()){if(!De(i))throw new TypeError(`${e} copy ${n} must be an object`);for(let o of["to","value"])if(!Object.hasOwn(i,o)||!(typeof i[o]=="function"||typeof i[o]=="string"&&i[o].trim()!==""))throw new TypeError(`${e} copy ${n} ${o} must be a reference or function`);if(Object.hasOwn(i,"when")&&typeof i.when!="boolean"&&typeof i.when!="function")throw new TypeError(`${e} copy ${n} when must be a boolean or function`)}}function nr(e,t,r){if(typeof e.options!="function")return e.options;let n=`field ${JSON.stringify(r)}`,i;try{i=e.options(t)}catch(a){throw new Error(`${n} options evaluation failed`,{cause:a})}if(i!=null&&(typeof i=="object"||typeof i=="function")&&typeof i.then=="function")throw new TypeError(`${n} options must complete synchronously`);let o=i??[];lt(n,o,!0);try{return structuredClone(o)}catch(a){throw new TypeError(`${n} options must have cloneable metadata`,{cause:a})}}function ir(e,t,r,n,i){let o=new Map,a=new Map,s=[];function l(f,p,g,E){let v=[];for(let $ of f){let y=B(g,$.id),A=N(y),O=n.get(A);if(!O)throw new Error(`missing condition scope for ${A}`);if($.type==="object"){let w=p[$.id],m=E&&we($,O);a.set(A,m);let d=l($.children,w,y,m);if(!m)continue;let _=Ae(i.get(O)?.(a),y,"object");s.push(..._),(d.length>0||_.length>0)&&v.push({kind:"object",id:$.id,...$.label===void 0?{}:{label:$.label},path:y,errors:_,children:d});continue}if($.type==="table"){let w=p[$.id],m=E&&we($,O);a.set(A,m);let d=m?Dn($,y,O):[];s.push(...d);let _=w.map(j=>{let R=Y(r,j),k=B(y,R);return{id:R,path:k,children:l($.children,j,k,m)}});m&&v.push({kind:"table",id:$.id,...$.label===void 0?{}:{label:$.label},path:y,errors:d,rows:_});continue}let x=E&&we($,O),S=x&&($.type==="select"||$.type==="multi-select")?nr($,O,y):void 0,b=Zt($,O,x);a.set(A,b.relevant);let u=O.value,h=b.relevant?tr($,y,b.required,O,S):[];o.set(A,{...b,errors:h,...S===void 0?{}:{options:S}}),s.push(...h),b.relevant&&v.push({kind:"leaf",field:$,path:y,value:u,required:b.required,readOnly:b.readOnly,errors:h,...S===void 0?{}:{options:S}})}return v}let c=l(e,t,[],!0);return{fieldsByPath:o,relevanceByPath:a,activeFields:c,errors:s,valid:s.length===0}}function Dn(e,t,r){return Ae(e.validate?.(r),t,"table")}function Ie(e){return e.map(ct)}function ct(e){if(e.type==="object"||e.type==="table")return{...e,children:Ie(e.children)};let t={...e};return e.type!=="calculated"&&e.onChange&&(t.onChange={copy:e.onChange.copy.map(r=>({...r}))}),e.type==="select"||e.type==="multi-select"?{...t,options:typeof e.options=="function"?e.options:structuredClone(e.options)}:t}function or(e,t,r,n){return ut(e,t,[],r,n)}function ut(e,t,r,n,i){let o=Object.create(null);for(let s of e)o[s.id]=s;let a={};for(let s of Object.keys(t)){let l=o[s];if(!l){Re(a,s,structuredClone(t[s]));continue}let c=B(r,l.id);if(Pn(i,c)){if(l.type==="object"){Re(a,s,ut(l.children,t[s],c,n,i));continue}if(l.type==="table"){let p=t[s];Re(a,s,p.map(g=>{let E=B(c,Y(n,g));return ut(l.children,g,E,n,i)}));continue}Re(a,s,structuredClone(t[s]))}}return a}function Re(e,t,r){Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0})}function Pn(e,t){let r=N(t),n=e.get(r);if(n===void 0)throw new Error(`missing relevance evaluation for field path ${r}`);return n}function ar(e,t,r){let n=structuredClone(t),i=new WeakMap;return Ne(e,t,n,[],{rowIdentities:i,allocateRowId:r}),{answers:n,rowIdentities:i}}function sr(e,t,r,n,i){if(!ft(t))throw new TypeError(`row data for table ${JSON.stringify(r)} must be an object`);let o=structuredClone(t),a=n(),s=B(r,a),l={rowIdentities:i,allocateRowId:n};return i.set(o,a),Ne(e.children,t,o,s,l),{row:o,rowId:a}}function Ne(e,t,r,n,i){for(let o of e){if(o.type==="calculated"){delete r[o.id];continue}if(o.type!=="object"&&o.type!=="table")continue;let a=B(n,o.id),s=Object.hasOwn(t,o.id)?t[o.id]:void 0,l=Object.hasOwn(r,o.id)?r[o.id]:void 0;if(o.type==="object"){let p=In(s,a),g=l??{};r[o.id]=g,Ne(o.children,p,g,a,i);continue}let c=Rn(s,a),f=l??[];r[o.id]=f;for(let[p,g]of c.entries()){let E=f[p];i.rowIdentities.has(E)&&(E=structuredClone(g),f[p]=E);let v=i.allocateRowId();i.rowIdentities.set(E,v),Ne(o.children,g,E,B(a,v),i)}}}function In(e,t){if(e===void 0)return{};if(!ft(e))throw new TypeError(`data at ${JSON.stringify(t)} must be an object`);return e}function Rn(e,t){if(e===void 0)return[];if(!Array.isArray(e))throw new TypeError(`data at ${JSON.stringify(t)} must be an array`);for(let r=0;r<e.length;r+=1)if(!ft(e[r]))throw new TypeError(`data at ${JSON.stringify([...t,r])} must be a row object`);return e}function ft(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}var lr=new WeakSet;function de(e){if(e!==null&&typeof e=="object"&&lr.has(e))return e;let t=new Set;function r(i,o){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"&&Number.isFinite(i))return i;if(typeof i!="object")throw new TypeError(`${o} must contain only JSON-compatible values`);if(t.has(i))throw new TypeError(`${o} must not contain cycles`);if(!Array.isArray(i)&&![Object.prototype,null].includes(Object.getPrototypeOf(i)))throw new TypeError(`${o} must contain only plain records and arrays`);t.add(i);let a=Array.isArray(i)?[]:Object.create(null);if(Array.isArray(i)&&Array.from({length:i.length},(s,l)=>l).some(s=>!Object.hasOwn(i,s)))throw new TypeError(`${o} must not contain sparse arrays`);for(let s of Reflect.ownKeys(i)){if(Array.isArray(i)&&s==="length")continue;let l=Object.getOwnPropertyDescriptor(i,s);if(typeof s!="string"||!l?.enumerable||!Object.hasOwn(l,"value"))throw new TypeError(`${o} must contain only enumerable data properties`);a[s]=r(i[s],`${o}.${s}`)}return t.delete(i),Object.freeze(a)}if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError("vars must be a JSON-compatible object");let n=r(e,"vars");return lr.add(n),n}function ur({schema:e,data:t={},vars:r={}}){if(!Array.isArray(e))throw new TypeError("schema must be an array");if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("data must be an object");Pe(e);let n=de(r),i=Ie(e),o=1,a=()=>`row-${o++}`,{answers:s,rowIdentities:l}=ar(i,t,a),c=new Set,f=new Set,p=!1,g=er(i,s,l,n),E,v=!1;function $(){if(v)throw new Error("reentrant public mutation during input is unsupported")}function y(){E=void 0,g.sync(),x(m=>{m.clearCalculatedValues()})}function A(m,d){let _=h(m);_.parentValues[_.node.id]=structuredClone(d)}function O(){E=void 0,g.sync(),x(m=>{m.clearCalculatedValues(),m.resolveAllCalculations();let d=ir(i,s,l,g.scopesByPath,g.objectValidators);m.commitCalculatedResults(),E=d})}function x(m){let d=g.beginEvaluation();try{return m(d)}finally{g.endEvaluation()}}function S(){if(!E)throw new Error("form evaluation is unavailable; mutate form state to retry evaluation");return E}function b(m){let d=ie(i,s,l,m);if(d.kind==="leaf")throw new Error(`section path ${JSON.stringify(m)} identifies a leaf`);let _=S(),j=d.kind==="row"?d.path.slice(0,-1):d.path,R=_.relevanceByPath.get(N(j));if(R===void 0)throw new Error(`missing relevance evaluation for section ${N(d.path)}`);let k=_.errors.filter(C=>fr(C.path,d.path));return{section:d,relevant:R,errors:k}}function u(m){if(p||c.has(N(m)))return!0;for(let d=m.length;d>0;d--)if(f.has(N(m.slice(0,d))))return!0;return!1}function h(m){let d=je(i,s,l,m);if(d.node.type==="calculated")throw new Error(`calculated field path ${JSON.stringify(d.path)} is read-only`);return d}function w(m){let d=h(m);if(!d.node.readOnly)return d;let _=N(d.path),j;if(E){let R=E.fieldsByPath.get(_);if(!R)throw new Error(`missing evaluation for field path ${_}`);j=R.readOnly}else j=x(()=>Yt(i,d.path,g.scopesByPath));if(j)throw new Error(`field path ${_} is read-only`);return d}return O(),{getFields(){return Ie(i)},getActiveFields(){return dt(S().activeFields,c,u)},getValue(m){let d=je(i,s,l,m);return structuredClone(d.parentValues[d.node.id])},input(m,d){$();let _=w(m),j=Kt(d),R=!Jt(_.parentValues[_.node.id],j.answer);y(),v=!0;try{if(A(_.path,j.answer),R){let k=g.scopesByPath.get(N(_.path));if(!k)throw new Error("missing input source scope");Ht(_,j.value,k,i,s,l,A)}O()}finally{v=!1}},setValue(m,d){$();let _=w(m),j=structuredClone(d);_.parentValues[_.node.id]=j,O()},appendRow(m,d={}){$();let _=Vt(i,s,l,m),j=sr(_.node,d,_.path,a,l);return _.rows.push(j.row),O(),j.rowId},removeRow(m){$();let d=zt(i,s,l,m);d.rows.splice(d.index,1),cr(c,d.path),cr(f,d.path),g.removeBelow(d.path),O()},touch(m){$();let d=h(m);c.add(N(d.path))},getFieldState(m){let d=je(i,s,l,m),_=N(d.path),j=S().fieldsByPath.get(_);if(!j)throw new Error(`missing evaluation for field path ${_}`);let{relevant:R,required:k,readOnly:C,errors:P,options:q}=j,L=c.has(_);return{field:ct(d.node),...q===void 0?{}:{options:structuredClone(q)},path:oe(d.path),value:structuredClone(d.parentValues[d.node.id]),touched:L,relevant:R,required:k,readOnly:C,valid:P.length===0,errors:u(d.path)?structuredClone(P):[]}},getSectionState(m){let{section:d,relevant:_,errors:j}=b(m),R=j.filter(C=>C.path.length===d.path.length),k={path:oe(d.path),relevant:_,ownValid:R.length===0,valid:j.length===0,errors:u(d.path)?structuredClone(R):[],subtreeErrors:structuredClone(j.filter(C=>u(C.path)))};return d.kind!=="table"?{...k,kind:d.kind}:{...k,kind:"table",rows:d.rows.map(C=>{let P=Y(l,C);return{id:P,path:B(d.path,P)}})}},isValid(){return S().valid},validate(){$();let{valid:m,errors:d}=S();return p=!0,{valid:m,errors:structuredClone(d)}},validateSection(m){$();let{section:d,relevant:_,errors:j}=b(m);return _&&f.add(N(d.path)),{valid:j.length===0,errors:structuredClone(j)}},getData(){return structuredClone(s)},getVars(){return structuredClone(n)},getSubmissionData(){return or(i,s,l,S().relevanceByPath)}}}function dt(e,t,r){return e.map(i=>{let o=r(i.path)?structuredClone(i.errors):[];if(i.kind==="object"){let c=dt(i.children,t,r);return c.length===0&&o.length===0?null:{type:"object",id:i.id,...i.label===void 0?{}:{label:i.label},path:oe(i.path),errors:o,children:c}}if(i.kind==="table")return{type:"table",id:i.id,...i.label===void 0?{}:{label:i.label},path:oe(i.path),valid:i.errors.length===0,errors:o,rows:i.rows.map(c=>({type:"row",id:c.id,path:oe(c.path),children:dt(c.children,t,r)}))};let a=structuredClone(i.value);if(i.field.type==="calculated")return{type:"calculated",id:i.field.id,label:i.field.label,path:oe(i.path),value:a,valid:i.errors.length===0,errors:o};let s=t.has(N(i.path)),l={id:i.field.id,label:i.field.label,path:oe(i.path),value:a,touched:s,required:i.required,readOnly:i.readOnly,valid:i.errors.length===0,errors:o};return i.field.type==="select"||i.field.type==="multi-select"?{...l,type:i.field.type,options:structuredClone(i.options??[])}:{...l,type:"text"}}).filter(i=>i!==null)}function cr(e,t){for(let r of e.keys())fr(JSON.parse(r),t)&&e.delete(r)}function fr(e,t){return e.length>=t.length&&t.every((r,n)=>e[n]===r)}var pt=class{add(t,r,n){if(typeof arguments[0]!="string")for(let i in arguments[0])this.add(i,arguments[0][i],arguments[1]);else(Array.isArray(t)?t:[t]).forEach(function(i){this[i]=this[i]||[],r&&this[i][n?"unshift":"push"](r)},this)}run(t,r){this[t]=this[t]||[],this[t].forEach(function(n){n.call(r&&r.context?r.context:r,r)})}},ht=class{constructor(t){this.jsep=t,this.registered={}}register(...t){t.forEach(r=>{if(typeof r!="object"||!r.name||!r.init)throw new Error("Invalid JSEP plugin format");this.registered[r.name]||(r.init(this.jsep),this.registered[r.name]=r)})}},W=class e{static get version(){return"1.4.0"}static toString(){return"JavaScript Expression Parser (JSEP) v"+e.version}static addUnaryOp(t){return e.max_unop_len=Math.max(t.length,e.max_unop_len),e.unary_ops[t]=1,e}static addBinaryOp(t,r,n){return e.max_binop_len=Math.max(t.length,e.max_binop_len),e.binary_ops[t]=r,n?e.right_associative.add(t):e.right_associative.delete(t),e}static addIdentifierChar(t){return e.additional_identifier_chars.add(t),e}static addLiteral(t,r){return e.literals[t]=r,e}static removeUnaryOp(t){return delete e.unary_ops[t],t.length===e.max_unop_len&&(e.max_unop_len=e.getMaxKeyLen(e.unary_ops)),e}static removeAllUnaryOps(){return e.unary_ops={},e.max_unop_len=0,e}static removeIdentifierChar(t){return e.additional_identifier_chars.delete(t),e}static removeBinaryOp(t){return delete e.binary_ops[t],t.length===e.max_binop_len&&(e.max_binop_len=e.getMaxKeyLen(e.binary_ops)),e.right_associative.delete(t),e}static removeAllBinaryOps(){return e.binary_ops={},e.max_binop_len=0,e}static removeLiteral(t){return delete e.literals[t],e}static removeAllLiterals(){return e.literals={},e}get char(){return this.expr.charAt(this.index)}get code(){return this.expr.charCodeAt(this.index)}constructor(t){this.expr=t,this.index=0}static parse(t){return new e(t).parse()}static getMaxKeyLen(t){return Math.max(0,...Object.keys(t).map(r=>r.length))}static isDecimalDigit(t){return t>=48&&t<=57}static binaryPrecedence(t){return e.binary_ops[t]||0}static isIdentifierStart(t){return t>=65&&t<=90||t>=97&&t<=122||t>=128&&!e.binary_ops[String.fromCharCode(t)]||e.additional_identifier_chars.has(String.fromCharCode(t))}static isIdentifierPart(t){return e.isIdentifierStart(t)||e.isDecimalDigit(t)}throwError(t){let r=new Error(t+" at character "+this.index);throw r.index=this.index,r.description=t,r}runHook(t,r){if(e.hooks[t]){let n={context:this,node:r};return e.hooks.run(t,n),n.node}return r}searchHook(t){if(e.hooks[t]){let r={context:this};return e.hooks[t].find(function(n){return n.call(r.context,r),r.node}),r.node}}gobbleSpaces(){let t=this.code;for(;t===e.SPACE_CODE||t===e.TAB_CODE||t===e.LF_CODE||t===e.CR_CODE;)t=this.expr.charCodeAt(++this.index);this.runHook("gobble-spaces")}parse(){this.runHook("before-all");let t=this.gobbleExpressions(),r=t.length===1?t[0]:{type:e.COMPOUND,body:t};return this.runHook("after-all",r)}gobbleExpressions(t){let r=[],n,i;for(;this.index<this.expr.length;)if(n=this.code,n===e.SEMCOL_CODE||n===e.COMMA_CODE)this.index++;else if(i=this.gobbleExpression())r.push(i);else if(this.index<this.expr.length){if(n===t)break;this.throwError('Unexpected "'+this.char+'"')}return r}gobbleExpression(){let t=this.searchHook("gobble-expression")||this.gobbleBinaryExpression();return this.gobbleSpaces(),this.runHook("after-expression",t)}gobbleBinaryOp(){this.gobbleSpaces();let t=this.expr.substr(this.index,e.max_binop_len),r=t.length;for(;r>0;){if(e.binary_ops.hasOwnProperty(t)&&(!e.isIdentifierStart(this.code)||this.index+t.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+t.length))))return this.index+=r,t;t=t.substr(0,--r)}return!1}gobbleBinaryExpression(){let t,r,n,i,o,a,s,l,c;if(a=this.gobbleToken(),!a||(r=this.gobbleBinaryOp(),!r))return a;for(o={value:r,prec:e.binaryPrecedence(r),right_a:e.right_associative.has(r)},s=this.gobbleToken(),s||this.throwError("Expected expression after "+r),i=[a,o,s];r=this.gobbleBinaryOp();){if(n=e.binaryPrecedence(r),n===0){this.index-=r.length;break}o={value:r,prec:n,right_a:e.right_associative.has(r)},c=r;let f=p=>o.right_a&&p.right_a?n>p.prec:n<=p.prec;for(;i.length>2&&f(i[i.length-2]);)s=i.pop(),r=i.pop().value,a=i.pop(),t={type:e.BINARY_EXP,operator:r,left:a,right:s},i.push(t);t=this.gobbleToken(),t||this.throwError("Expected expression after "+c),i.push(o,t)}for(l=i.length-1,t=i[l];l>1;)t={type:e.BINARY_EXP,operator:i[l-1].value,left:i[l-2],right:t},l-=2;return t}gobbleToken(){let t,r,n,i;if(this.gobbleSpaces(),i=this.searchHook("gobble-token"),i)return this.runHook("after-token",i);if(t=this.code,e.isDecimalDigit(t)||t===e.PERIOD_CODE)return this.gobbleNumericLiteral();if(t===e.SQUOTE_CODE||t===e.DQUOTE_CODE)i=this.gobbleStringLiteral();else if(t===e.OBRACK_CODE)i=this.gobbleArray();else{for(r=this.expr.substr(this.index,e.max_unop_len),n=r.length;n>0;){if(e.unary_ops.hasOwnProperty(r)&&(!e.isIdentifierStart(this.code)||this.index+r.length<this.expr.length&&!e.isIdentifierPart(this.expr.charCodeAt(this.index+r.length)))){this.index+=n;let o=this.gobbleToken();return o||this.throwError("missing unaryOp argument"),this.runHook("after-token",{type:e.UNARY_EXP,operator:r,argument:o,prefix:!0})}r=r.substr(0,--n)}e.isIdentifierStart(t)?(i=this.gobbleIdentifier(),e.literals.hasOwnProperty(i.name)?i={type:e.LITERAL,value:e.literals[i.name],raw:i.name}:i.name===e.this_str&&(i={type:e.THIS_EXP})):t===e.OPAREN_CODE&&(i=this.gobbleGroup())}return i?(i=this.gobbleTokenProperty(i),this.runHook("after-token",i)):this.runHook("after-token",!1)}gobbleTokenProperty(t){this.gobbleSpaces();let r=this.code;for(;r===e.PERIOD_CODE||r===e.OBRACK_CODE||r===e.OPAREN_CODE||r===e.QUMARK_CODE;){let n;if(r===e.QUMARK_CODE){if(this.expr.charCodeAt(this.index+1)!==e.PERIOD_CODE)break;n=!0,this.index+=2,this.gobbleSpaces(),r=this.code}this.index++,r===e.OBRACK_CODE?(t={type:e.MEMBER_EXP,computed:!0,object:t,property:this.gobbleExpression()},t.property||this.throwError('Unexpected "'+this.char+'"'),this.gobbleSpaces(),r=this.code,r!==e.CBRACK_CODE&&this.throwError("Unclosed ["),this.index++):r===e.OPAREN_CODE?t={type:e.CALL_EXP,arguments:this.gobbleArguments(e.CPAREN_CODE),callee:t}:(r===e.PERIOD_CODE||n)&&(n&&this.index--,this.gobbleSpaces(),t={type:e.MEMBER_EXP,computed:!1,object:t,property:this.gobbleIdentifier()}),n&&(t.optional=!0),this.gobbleSpaces(),r=this.code}return t}gobbleNumericLiteral(){let t="",r,n;for(;e.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(this.code===e.PERIOD_CODE)for(t+=this.expr.charAt(this.index++);e.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);if(r=this.char,r==="e"||r==="E"){for(t+=this.expr.charAt(this.index++),r=this.char,(r==="+"||r==="-")&&(t+=this.expr.charAt(this.index++));e.isDecimalDigit(this.code);)t+=this.expr.charAt(this.index++);e.isDecimalDigit(this.expr.charCodeAt(this.index-1))||this.throwError("Expected exponent ("+t+this.char+")")}return n=this.code,e.isIdentifierStart(n)?this.throwError("Variable names cannot start with a number ("+t+this.char+")"):(n===e.PERIOD_CODE||t.length===1&&t.charCodeAt(0)===e.PERIOD_CODE)&&this.throwError("Unexpected period"),{type:e.LITERAL,value:parseFloat(t),raw:t}}gobbleStringLiteral(){let t="",r=this.index,n=this.expr.charAt(this.index++),i=!1;for(;this.index<this.expr.length;){let o=this.expr.charAt(this.index++);if(o===n){i=!0;break}else if(o==="\\")switch(o=this.expr.charAt(this.index++),o){case"n":t+=`
46
+ `;break;case"r":t+="\r";break;case"t":t+=" ";break;case"b":t+="\b";break;case"f":t+="\f";break;case"v":t+="\v";break;default:t+=o}else t+=o}return i||this.throwError('Unclosed quote after "'+t+'"'),{type:e.LITERAL,value:t,raw:this.expr.substring(r,this.index)}}gobbleIdentifier(){let t=this.code,r=this.index;for(e.isIdentifierStart(t)?this.index++:this.throwError("Unexpected "+this.char);this.index<this.expr.length&&(t=this.code,e.isIdentifierPart(t));)this.index++;return{type:e.IDENTIFIER,name:this.expr.slice(r,this.index)}}gobbleArguments(t){let r=[],n=!1,i=0;for(;this.index<this.expr.length;){this.gobbleSpaces();let o=this.code;if(o===t){n=!0,this.index++,t===e.CPAREN_CODE&&i&&i>=r.length&&this.throwError("Unexpected token "+String.fromCharCode(t));break}else if(o===e.COMMA_CODE){if(this.index++,i++,i!==r.length){if(t===e.CPAREN_CODE)this.throwError("Unexpected token ,");else if(t===e.CBRACK_CODE)for(let a=r.length;a<i;a++)r.push(null)}}else if(r.length!==i&&i!==0)this.throwError("Expected comma");else{let a=this.gobbleExpression();(!a||a.type===e.COMPOUND)&&this.throwError("Expected comma"),r.push(a)}}return n||this.throwError("Expected "+String.fromCharCode(t)),r}gobbleGroup(){this.index++;let t=this.gobbleExpressions(e.CPAREN_CODE);if(this.code===e.CPAREN_CODE)return this.index++,t.length===1?t[0]:t.length?{type:e.SEQUENCE_EXP,expressions:t}:!1;this.throwError("Unclosed (")}gobbleArray(){return this.index++,{type:e.ARRAY_EXP,elements:this.gobbleArguments(e.CBRACK_CODE)}}},Nn=new pt;Object.assign(W,{hooks:Nn,plugins:new ht(W),COMPOUND:"Compound",SEQUENCE_EXP:"SequenceExpression",IDENTIFIER:"Identifier",MEMBER_EXP:"MemberExpression",LITERAL:"Literal",THIS_EXP:"ThisExpression",CALL_EXP:"CallExpression",UNARY_EXP:"UnaryExpression",BINARY_EXP:"BinaryExpression",ARRAY_EXP:"ArrayExpression",TAB_CODE:9,LF_CODE:10,CR_CODE:13,SPACE_CODE:32,PERIOD_CODE:46,COMMA_CODE:44,SQUOTE_CODE:39,DQUOTE_CODE:34,OPAREN_CODE:40,CPAREN_CODE:41,OBRACK_CODE:91,CBRACK_CODE:93,QUMARK_CODE:63,SEMCOL_CODE:59,COLON_CODE:58,unary_ops:{"-":1,"!":1,"~":1,"+":1},binary_ops:{"||":1,"??":1,"&&":2,"|":3,"^":4,"&":5,"==":6,"!=":6,"===":6,"!==":6,"<":7,">":7,"<=":7,">=":7,"<<":8,">>":8,">>>":8,"+":9,"-":9,"*":10,"/":10,"%":10,"**":11},right_associative:new Set(["**"]),additional_identifier_chars:new Set(["$","_"]),literals:{true:!0,false:!1,null:null},this_str:"this"});W.max_unop_len=W.getMaxKeyLen(W.unary_ops);W.max_binop_len=W.getMaxKeyLen(W.binary_ops);var Q=e=>new W(e).parse(),qn=Object.getOwnPropertyNames(class{});Object.getOwnPropertyNames(W).filter(e=>!qn.includes(e)&&Q[e]===void 0).forEach(e=>{Q[e]=W[e]});Q.Jsep=W;var Ln="ConditionalExpression",Mn={name:"ternary",init(e){e.hooks.add("after-expression",function(r){if(r.node&&this.code===e.QUMARK_CODE){this.index++;let n=r.node,i=this.gobbleExpression();if(i||this.throwError("Expected expression"),this.gobbleSpaces(),this.code===e.COLON_CODE){this.index++;let o=this.gobbleExpression();if(o||this.throwError("Expected expression"),r.node={type:Ln,test:n,consequent:i,alternate:o},n.operator&&e.binary_ops[n.operator]<=.9){let a=n;for(;a.right.operator&&e.binary_ops[a.right.operator]<=.9;)a=a.right;r.node.test=a.right,a.right=r.node,r.node=n}}else this.throwError("Expected :")}})}};Q.plugins.register(Mn);var Fn={or:1,and:2,"=":3,"!=":3,"<":4,"<=":4,">":4,">=":4,"+":5,"-":5,"*":6,"/":6,"%":6};Q.removeAllBinaryOps();for(let[e,t]of Object.entries(Fn))Q.addBinaryOp(e,t);Q.removeAllUnaryOps();for(let e of["+","-","!"])Q.addUnaryOp(e);Q.removeAllLiterals();for(let[e,t]of Object.entries({true:!0,false:!1,null:null,undefined:void 0}))Q.addLiteral(e,t);function mt(e){if(!e.slice(1).trim())throw new SyntaxError("Empty formula");return Q(e.slice(1))}var M={kind:"open"},J={kind:"scalar"};function ue(e){let t=e.flatMap(r=>r.choices??[r]);return t.length===1?t[0]??M:{kind:"choices",choices:t}}function ge(e){return e.choices?ue(e.choices.map(ge)):e.element??M}function bt(e){if(e.choices)return ue(e.choices.map(bt));if(e.kind==="declared-vars")throw new TypeError("Declared vars require a literal first-level member");return e.kind==="array"?ge(e):M}function qe(e,t){let r=new Map,n=new Set(t.flatMap(o=>o!=null&&typeof o=="object"?Object.keys(o):[])),i={kind:"record",members:r,ownKeys:n};for(let o of e){let a=t.filter(c=>c!=null&&Object.hasOwn(c,o.id)).map(c=>c[o.id]),s=o.id,l=J;o.type==="object"?l=qe(o.children,a):o.type==="table"?l={kind:"array",element:qe(o.children,a.flatMap(c=>Array.isArray(c)?c:[]))}:o.type==="multi-select"&&(l={kind:"array",element:J}),r.set(s,l)}return i}function pe(e){if(Array.isArray(e)){let t=e.map(pe);return{kind:"array",element:ue(t),elements:t}}return e!==null&&typeof e=="object"?{kind:"vars-record",members:new Map(Object.entries(e).map(([t,r])=>[t,pe(r)]))}:J}function dr(e){return{kind:"declared-vars",members:new Map(e.map(t=>[t,M]))}}function Bn(e){if(["__proto__","prototype","constructor"].includes(String(e)))throw new TypeError(`Forbidden property ${e}`)}function ee(e,t,r,n=!1){Bn(t);let i=String(t);if(e.choices)return ue(e.choices.map(o=>ee(o,t,r,n)));if(e.kind==="context"){if(i==="data")return e.data??M;if(i==="parent")return e.parent??M;if(i==="previous")return e;if(["kind","id","index"].includes(i))return J;if(i==="path")return{kind:"array",element:J};throw new TypeError(`Unknown context member ${i}`)}if(e.kind==="ancestor")return i==="current"?e.data??M:i==="parent"?e.parent??M:i==="form"?e.members?.get("form")??M:ee(e.data??M,t,r,n);if(e.kind==="array"){if(i==="length")return J;if(/^-?(0|[1-9]\d*)$/.test(i))return e.elements?.[Number(i)]??e.element??M;throw new TypeError(`Unknown array member ${i}`)}if(e.kind==="record"){let o=e.members?.get(i);if(o)return o;if(n?r!=null&&Object.hasOwn(r,i):e.ownKeys?.has(i))return M;throw new TypeError(`Unknown schema member ${i}`)}if(["vars-record","declared-vars"].includes(e.kind)){let o=e.members?.get(i);if(o)return o;if(n)return M;throw new TypeError(`Unknown vars member ${i}`)}return M}function Le(e,t,r){if(typeof r!="string"&&typeof r!="number")throw new TypeError("Member key must be a string or number");let n=ee(t,r,e,!0);if(e==null)return{value:void 0,descriptor:n};if(typeof e=="string"||Array.isArray(e)){if(r==="length"||/^-?(0|[1-9]\d*)$/.test(String(r)))return{value:e[r],descriptor:n};throw new TypeError(`Unsupported array/string member ${r}`)}if(typeof e!="object")throw new TypeError(`Cannot traverse scalar at ${r}`);return["context","ancestor"].includes(t.kind)||["record","vars-record"].includes(t.kind)&&t.members?.has(String(r))||Object.hasOwn(e,r)?{value:e[r],descriptor:n}:{value:void 0,descriptor:n}}function pr(e,t,r,n,i,o,a){let s=new Map([["form",e],["parent",t],["context",r],["vars",a]]);if(i){s.set("current",t),s.set("value",M);let l=[];for(let f=r.parent;f;f=f.parent)f.data?.kind!=="array"&&l.push(f.data??M);let c;for(let f of l.reverse())c={kind:"ancestor",data:f,...c?{parent:c}:{},members:new Map([["form",e]])};s.set("parent",c??M)}else if(o==="validate"){let l=t.members?.get(n.id)??M;s.set(n.type==="table"?"rows":"value",l),n.type==="object"&&l.members&&s.set("isRelevant",{kind:"helper",members:l.members})}return s}var Un=e=>e.type==="Literal"&&["string","number"].includes(typeof e.value)?e.value:void 0;function hr(e){let t=e,r=[];if(t.type==="Literal"&&typeof t.value=="string"?r=[t.value]:t.type==="ArrayExpression"&&(r=t.elements.map(n=>n?.type==="Literal"?n.value:void 0)),!r.length||r.some(n=>typeof n!="string"||!n.length))throw new TypeError("Selector must be a literal field ID or non-empty string path array");return r}function H(e,t){if(!e||e.optional)throw new TypeError("Unsupported expression syntax");let r=e;switch(r.type){case"Literal":if(typeof r.value=="number"&&!Number.isFinite(r.value))throw new TypeError("Non-finite number literal");return J;case"Identifier":{if(r.name.startsWith("$")){if(r.name.length===1||r.name.slice(1).includes("$"))throw new TypeError("Invalid $field shorthand");return ee(t.get("parent")??M,r.name.slice(1))}let n=t.get(r.name);if(!n||n.kind==="helper")throw new TypeError(`Unknown scope root ${r.name}`);return n}case"ArrayExpression":{let n=r.elements.map(i=>H(i,t));return{kind:"array",elements:n,element:ue(n)}}case"MemberExpression":{let n=H(r.object,t);r.computed&&H(r.property,t);let i=r.computed?Un(r.property):r.property.name;return i===void 0?bt(n):ee(n,i)}case"UnaryExpression":if(!["+","-","!"].includes(r.operator))throw new TypeError(`Unsupported operator ${r.operator}`);return H(r.argument,t),J;case"BinaryExpression":if(!["+","-","*","/","%","<","<=",">",">=","=","!=","and","or"].includes(r.operator))throw new TypeError(`Unsupported operator ${r.operator}`);return H(r.left,t),H(r.right,t),J;case"ConditionalExpression":return H(r.test,t),ue([H(r.consequent,t),H(r.alternate,t)]);case"CallExpression":{let n=r.callee.type==="Identifier"?r.callee.name:"";if(n==="isRelevant"){let o=t.get(n);if(!o)throw new TypeError("isRelevant is only available in object validation");let[a]=r.arguments;if(r.arguments.length!==1||a?.type!=="Literal"||typeof a.value!="string")throw new TypeError("isRelevant requires one literal string child ID");if(!o.members?.has(a.value))throw new TypeError(`Unknown direct child ${JSON.stringify(a.value)}`);return J}if(!["sum","count","unique"].includes(n))throw new TypeError(`Unsupported helper call ${n||"method"}`);if(r.arguments.length<1||r.arguments.length>(n==="count"?1:2))throw new TypeError(`${n} has incorrect argument count`);let i=H(r.arguments[0],t);if(r.arguments.length===2){let o=ge(i);for(let a of hr(r.arguments[1]))o=ee(o,a)}return J}default:throw new TypeError(`Unsupported AST node ${r.type}`)}}var mr=e=>e==null||typeof e=="string"&&!e.trim();function Me(e){if(!mr(e)){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e.trim())&&Number.isFinite(Number(e)))return Number(e);throw new TypeError(`Invalid numeric operand ${String(e)}`)}}var yt=e=>e===null||["undefined","string","number","boolean"].includes(typeof e);function wt(e,t,r){let n=e,i=a=>wt(a,t,r),o=(a,s=J)=>({value:a,descriptor:s});switch(n.type){case"Literal":return o(n.value);case"Identifier":return n.name.startsWith("$")?Le(t.parent,r.get("parent")??M,n.name.slice(1)):o(t[n.name],r.get(n.name));case"ArrayExpression":{let a=n.elements.map(s=>i(s));return o(a.map(s=>s.value),{kind:"array",elements:a.map(s=>s.descriptor)})}case"MemberExpression":{let a=i(n.object);return Le(a.value,a.descriptor,n.computed?i(n.property).value:n.property.name)}case"UnaryExpression":{let a=i(n.argument).value;if(n.operator==="!")return o(!a);let s=Me(a);return o(s===void 0?void 0:n.operator==="-"?-s:s)}case"ConditionalExpression":return i(i(n.test).value?n.consequent:n.alternate);case"BinaryExpression":{let a=i(n.left).value;if(n.operator==="and")return o(!!a&&!!i(n.right).value);if(n.operator==="or")return o(!!a||!!i(n.right).value);let s=i(n.right).value;if(["=","!="].includes(n.operator)){if(!yt(a)||!yt(s))throw new TypeError("Equality requires primitive operands");return o(n.operator==="="?a===s:a!==s)}let l=Me(a),c=Me(s);if(l===void 0||c===void 0){let p=["<","<=",">",">="].includes(n.operator);return o(p?!1:void 0)}if(["/","%"].includes(n.operator)&&c===0)throw new TypeError("Division/remainder by zero");let f;switch(n.operator){case"<":return o(l<c);case"<=":return o(l<=c);case">":return o(l>c);case">=":return o(l>=c);case"+":f=l+c;break;case"-":f=l-c;break;case"*":f=l*c;break;case"/":f=l/c;break;default:f=l%c}if(!Number.isFinite(f))throw new TypeError("Non-finite arithmetic result");return o(f)}case"CallExpression":{let a=n.callee.name;if(a==="isRelevant"){let v=n.arguments[0];return o(t.isRelevant(v.value))}let s=i(n.arguments[0]),l=s.value??[];if(!Array.isArray(l))throw new TypeError(`${a} requires an array collection`);if(a==="count")return o(l.length);let c=n.arguments.length===2?hr(n.arguments[1]):[],f=ge(s.descriptor);for(let v of c)f=ee(f,v);let p=0,g=new Set,E=!0;for(let[v,$]of l.entries()){let y=o($,ee(s.descriptor,v,l,!0));for(let A of c)y=Le(y.value,y.descriptor,A);if(!mr(y.value))if(a==="unique"){if(!yt(y.value))throw new TypeError("unique requires primitive selected values");g.has(y.value)&&(E=!1),g.add(y.value)}else{let A;try{A=Me(y.value)}catch{continue}if(p+=A??0,!Number.isFinite(p))throw new TypeError("sum overflow produced a non-finite result")}}return o(a==="unique"?E:p)}default:throw new TypeError(`Unsupported AST node ${n.type}`)}}var br=["relevant","required","readOnly"],yr=[...br,"calculate","validate"];function ve({schema:e,data:t={},varsShape:r,executable:n=!0,locateFormulaError:i}){Pe(gr(e));let o=qe(e,[t]),a={formShape:o,varsShape:r,executable:n,locateFormulaError:i},s={kind:"context",data:o};return e.map(l=>wr(l,s,[],a))}function wr(e,t,r,n){let i=e,o=i.id,a=[...r,i.id];if(i.type!=="calculated"&&typeof i.calculate=="string"&&i.calculate.startsWith("="))throw gt(new TypeError("calculate is only supported on calculated fields"),a,"calculate",i.calculate);function s(c,f,p=!1){if(typeof c!="string"||!c.startsWith("="))return c;let g=pr(n.formShape,t.data,t,i,p,f,n.varsShape);return Vn({formula:c,roots:g,property:f,definitionPath:a,nodeId:o,executable:n.executable,locateFormulaError:n.locateFormulaError})}let l={...i};for(let c of yr)Object.hasOwn(i,c)&&(l[c]=s(i[c],c));if(i.onChange&&(l.onChange={...i.onChange,copy:i.onChange.copy.map((c,f)=>{let p={...c};return Object.hasOwn(c,"when")&&(p.when=s(c.when,`onChange.copy[${f}].when`,!0)),p.value=s(c.value,`onChange.copy[${f}].value`,!0),p})}),(i.type==="select"||i.type==="multi-select")&&(typeof i.options=="string"&&i.options.startsWith("=")?l.options=s(i.options,"options"):typeof i.options=="function"?l.options=i.options:l.options=structuredClone(i.options)),i.type==="object"||i.type==="table"){let c=t.data.members?.get(i.id);if(!c)throw new Error("Missing declared descriptor");let f={kind:"context",data:c,parent:t},p=i.type==="table"?{kind:"context",data:c.element??c,parent:f}:f;l.children=i.children.map(g=>wr(g,p,a,n))}return l}function Vn({formula:e,roots:t,property:r,definitionPath:n,nodeId:i,executable:o,locateFormulaError:a}){let s;try{s=mt(e),H(s,t)}catch(l){let c=a?.({cause:l,schemaPath:n,property:r,formula:e,check(p){H(mt(p),t)}}),f=gt(c?.cause??l,n,r,e);throw c?.location!==void 0&&Object.assign(f,{preparationLocation:c.location}),f}return o?l=>{let c=[...l.context.path,i];try{let f=wt(s,l,t).value;return zn(r,f),f}catch(f){throw gt(f,n,r,e,c)}}:e}function zn(e,t){if(br.includes(e)||e.endsWith(".when")){if(typeof t!="boolean")throw new TypeError("Condition must return a boolean");return}if(e==="calculate"){if(t!==null&&!["undefined","string","number","boolean"].includes(typeof t))throw new TypeError("Calculation must return a primitive value");if(typeof t=="number"&&!Number.isFinite(t))throw new TypeError("Calculation must return a finite number");return}if(e==="validate"&&t!==void 0&&(typeof t!="string"||!t.length))throw new TypeError("Validator must return undefined or a non-empty message string")}function Fe(e){return typeof e=="string"&&e.startsWith("=")?()=>{}:e}function gr(e){return e.map(t=>{let r=t;if(r===null||typeof r!="object")return r;let n={...r};for(let i of yr)Object.hasOwn(r,i)&&(n[i]=Fe(r[i]));return["select","multi-select"].includes(r.type)&&typeof r.options=="string"&&r.options.startsWith("=")&&(n.options=Fe(r.options)),Array.isArray(r.children)&&(n.children=gr(r.children)),r.onChange&&Array.isArray(r.onChange.copy)&&(n.onChange={...r.onChange,copy:r.onChange.copy.map(i=>{if(!i||typeof i!="object")return i;let o={...i};return Object.hasOwn(i,"when")&&(o.when=Fe(i.when)),o.value=Fe(i.value),o})}),n})}function gt(e,t,r,n,i){let o=e&&typeof e=="object"&&"index"in e?e.index:void 0,a=new Error(`Expression ${JSON.stringify(t)} ${r} ${JSON.stringify(n)}${i?` at ${JSON.stringify(i)}`:""}${o===void 0?"":` offset ${o}`}: ${e instanceof Error?e.message:String(e)}`,{cause:e});return Object.assign(a,{schemaPath:[...t],property:r,formula:n,...i?{instancePath:[...i]}:{},...o===void 0?{}:{offset:o}})}function vr({schema:e,data:t={},vars:r={}}){if(!Array.isArray(e))throw new TypeError("schema must be an array");if(typeof t!="object"||t===null||Array.isArray(t))throw new TypeError("data must be an object");let n=de(r);return ur({schema:ve({schema:e,data:t,varsShape:pe(n)}),data:t,vars:n})}function Er(e,t){let r=Math.max(0,Math.min(t,e.length)),n=1,i=1;for(let o=0;o<r;o+=1)e[o]===`
47
+ `?(n+=1,i=1):i+=1;return Object.freeze({offset:r,line:n,column:i})}function Wn(e,t,r){return Object.freeze({start:Er(e,t),end:Er(e,Math.max(t,r))})}function I(e,t,r,n){return Object.freeze({category:t,message:r,range:Wn(e,n.start,n.end)})}var K=class extends Error{diagnostics=Object.freeze([]);constructor(t,r={}){super(t.length===1?t[0]?.message:`Form language compilation failed with ${t.length} diagnostics`,r),this.name="FormLanguageError",Object.defineProperty(this,"diagnostics",{value:Object.freeze([...t]),enumerable:!0,writable:!1,configurable:!1})}};var Ee=new Set(["text","select","multi-select"]);function xr(e,t){let r=[],n=t.declarations.filter(O=>O.kind==="vars"),i=t.declarations.filter(O=>O.kind==="content");for(let O of n.slice(1))r.push(I(e,"declaration","Only one vars block is allowed",O));for(let O of i.slice(1))r.push(I(e,"declaration","Only one content block is allowed",O));let o=[],a=new Set;for(let O of n.slice(0,1))for(let x of O.names)a.has(x.value)?r.push(I(e,"declaration",`Duplicate var ${x.value}`,x)):(a.add(x.value),o.push(x.value));let s=new Map;for(let O of i.slice(0,1))for(let x of O.entries)s.has(x.name.value)?r.push(I(e,"declaration",`Duplicate content ${x.name.value}`,x.name)):s.set(x.name.value,x.value.value);function l(O,x){if(!O)return;let S=O.kind==="content"?s.get(O.name):O.value;return O.kind==="content"&&S===void 0&&r.push(I(e,"declaration",`Unknown content ${O.name}`,O)),typeof S=="string"&&!S.trim()&&r.push(I(e,"declaration",`${x} must be non-empty`,O)),S??""}let c=t.declarations.filter(O=>O.kind==="node"),f=new Map,p=new Map,g=new Map,E=(O,x)=>`${JSON.stringify(O)}:${x}`;function v(O,x,S){let b=new Set;return O.map(u=>{let h=[...x,u.id.value];p.set(JSON.stringify(h),u),b.has(u.id.value)&&r.push(I(e,"schema",`Duplicate sibling ID ${u.id.value}`,u.id)),b.add(u.id.value),u.id.value==="__proto__"&&r.push(I(e,"schema",'Reserved ID "__proto__"',u.id));let w={type:u.type,id:u.id.value};u.label&&(w.label=l(u.label,"Label")),(Ee.has(u.type)||u.type==="calculated")&&!u.label&&r.push(I(e,"declaration",`${u.type} requires a label`,u)),u.marker&&(Ee.has(u.type)?w.required=!0:r.push(I(e,"declaration",`Required marker is not supported on ${u.type}`,u)));let m=new Map;for(let d of u.properties??[])m.has(d.name)?r.push(I(e,"declaration",`Duplicate ${d.name} property`,d)):m.set(d.name,d),["required","readOnly"].includes(d.name)&&!Ee.has(u.type)?r.push(I(e,"declaration",`${d.name} is not supported on ${u.type}`,d)):(w[d.name]=`=${d.expression.value}`,f.set(E(h,d.name),d.expression));if(u.marker&&m.has("required")&&r.push(I(e,"declaration","Required marker conflicts with required property",m.get("required"))),u.calculate&&(w.calculate=`=${u.calculate.value}`,f.set(E(h,"calculate"),u.calculate)),u.options)if(["select","multi-select"].includes(u.type)||r.push(I(e,"declaration",`options is not supported on ${u.type}`,u.options)),u.options.kind==="formula")w.options=`=${u.options.expression.value}`,f.set(E(h,"options"),u.options.expression);else{let d=new Set;w.options=u.options.entries.map(_=>(_.value.value.trim()||r.push(I(e,"declaration","Option value must be non-empty",_.value)),d.has(_.value.value)&&r.push(I(e,"declaration",`Duplicate option value ${_.value.value}`,_.value)),d.add(_.value.value),{value:_.value.value,label:l(_.label,"Option label")}))}else["select","multi-select"].includes(u.type)&&r.push(I(e,"declaration",`${u.type} requires exactly one options source`,u));if(u.children?.length&&!["object","table"].includes(u.type)&&r.push(I(e,"declaration",`Nested declarations are not supported on ${u.type}`,u.children[0])),["object","table"].includes(u.type)){let d=[u.children,...S];w.children=v(u.children??[],h,d)}if(u.validations?.length){let d="undefined",_=[];for(let j=u.validations.length-1;j>=0;j-=1){let R=u.validations[j],k=l(R.message,"Validation message");_.unshift({formula:`=${R.predicate.value}`,range:R.predicate}),d=`(${R.predicate.value}) ? (${d}) : ${JSON.stringify(k)}`}w.validate=`=${d}`,g.set(E(h,"validate"),_),f.set(E(h,"validate"),{start:u.validations[0].start,end:u.validations.at(-1).end})}return u.copies?.length&&(Ee.has(u.type)||r.push(I(e,"declaration",`copy is not supported on ${u.type}`,u.copies[0])),w.onChange={copy:u.copies.map((d,_)=>($(d.destination,S,O),f.set(E(h,`onChange.copy[${_}].value`),d.value),d.when&&f.set(E(h,`onChange.copy[${_}].when`),d.when),{value:`=${d.value.value}`,to:d.destination.value,...d.when?{when:`=${d.when.value}`}:{}}))}),w})}function $(O,x,S){let b=O.value.split("."),u=0;if(b[0]==="form")u=x.length-1,b.shift();else if(b[0]==="current")b.shift();else for(;b[0]==="parent";)u+=1,b.shift();let h=x[u]??(u===0?S:void 0);if(!h||!b.length){r.push(I(e,"declaration",`Unsupported copy destination ${O.value}`,O));return}let w=h,m;for(let[d,_]of b.entries()){if(m=w.find(j=>j.id.value===_),!m||m.type==="table")break;if(d<b.length-1){if(m.type!=="object"){m=void 0;break}w=m.children??[]}}(!m||!Ee.has(m.type))&&r.push(I(e,"declaration",`Copy destination must identify an existing editable field: ${O.value}`,O))}let y=v(c,[],[c]);if(r.length)throw new K(r);return{compiled:{id:t.id,version:1,vars:Object.freeze(o),schema:y},ruleRanges:f,nodeRanges:p,formulaFragments:g}}var Be=class{constructor(t){this.source=t,this.offset=0}get eof(){return this.offset>=this.source.length}peek(t=1){return this.source.slice(this.offset,this.offset+t)}skip(t=!0){for(;!this.eof;)if(this.peek()==="#")for(;!this.eof&&this.peek()!==`
48
+ `;)this.offset+=1;else if(/[ \t\r]/.test(this.peek())||t&&this.peek()===`
49
+ `)this.offset+=1;else break}take(t){return this.source.startsWith(t,this.offset)?(this.offset+=t.length,!0):!1}word(){let t=this.offset,r=/^[A-Za-z_][A-Za-z0-9_]*/.exec(this.source.slice(t));if(r)return this.offset+=r[0].length,{value:r[0],start:t,end:this.offset}}number(){let t=this.offset,r=/^\d+/.exec(this.source.slice(t));if(r)return this.offset+=r[0].length,{value:Number(r[0]),start:t,end:this.offset}}string(){let t=this.offset;if(this.peek(3)==='"""')return this.tripleString();if(!this.take('"'))return;let r=!1;for(;!this.eof;){let n=this.peek();if(this.offset+=1,!r&&n==='"'){let i=this.source.slice(t,this.offset);try{return{value:JSON.parse(i),start:t,end:this.offset}}catch{throw Object.assign(new SyntaxError("Invalid quoted string"),{start:t,end:this.offset})}}if(!r&&n===`
50
+ `){this.offset-=1;break}r=!r&&n==="\\",n!=="\\"&&(r=!1)}throw Object.assign(new SyntaxError("Unterminated quoted string"),{start:t,end:this.offset})}tripleString(){let t=this.offset;for(this.offset+=3;this.peek()===" "||this.peek()===" ";)this.offset+=1;if(this.take("\r"),!this.take(`
51
+ `))throw Object.assign(new SyntaxError("Triple-quoted opening delimiter must end its line"),{start:t,end:this.offset});let r=this.offset,n=-1;for(;!this.eof;){let c=this.offset,f=this.source.indexOf(`
52
+ `,c),p=f<0?this.source.length:f;if(this.source.slice(c,p).trim()==='"""'){n=c,this.offset=p;break}this.offset=f<0?this.source.length:f+1}if(n<0)throw Object.assign(new SyntaxError("Unterminated triple-quoted string"),{start:t,end:this.offset});let i=this.source.slice(r,n);i.endsWith(`
53
+ `)&&(i=i.slice(0,-1));let o=i.split(`
54
+ `),a=o.filter(c=>c.trim()).map(c=>/^\s*/.exec(c)?.[0].length??0),s=a.length?Math.min(...a):0;if(i=o.map(c=>c.trim()?c.slice(s):"").join(`
55
+ `),this.source.slice(n,this.offset).trim()!=='"""')throw Object.assign(new SyntaxError("Triple-quoted closing delimiter must be on its own line"),{start:n,end:this.offset});return{value:i,start:t,end:this.offset}}expression(t="line"){this.skip(!1);let r=this.offset,n=0,i=0,o=!1,a;for(;!this.eof;){let l=this.peek();if(a){this.offset+=1,!o&&l===a&&(a=void 0),o=!o&&l==="\\",l!=="\\"&&(o=!1);continue}if(l==='"'||l==="'"){a=l,this.offset+=1;continue}if(l==="("?n+=1:l===")"?n-=1:l==="["?i+=1:l==="]"&&(i-=1),n<0||i<0)throw Object.assign(new SyntaxError("Unbalanced expression delimiter"),{start:r,end:this.offset+1});if(n===0&&i===0&&(t==="arrow"&&this.peek(2)==="->"||t==="otherwise"&&!/[A-Za-z0-9_]/.test(this.source[this.offset-1]??"")&&/^otherwise\b/.test(this.source.slice(this.offset))||l===`
56
+ `||l==="}"||l==="#"))break;this.offset+=1}if(n||i||a)throw Object.assign(new SyntaxError("Unbalanced expression delimiter"),{start:r,end:this.offset});let s=this.offset;for(;s>r&&/\s/.test(this.source[s-1]??"");)s-=1;return{value:this.source.slice(r,s),start:r,end:s}}recover(){for(;!this.eof&&![`
57
+ `,"}"].includes(this.peek());)this.offset+=1;this.peek()===`
58
+ `&&(this.offset+=1)}};var kr=new Set(["select","multi-select","calculated","object","table"]),Kn=new Set(["number","group","section"]),Ue=new Set(["form","vars","content","options","required","relevant","validate","otherwise","copy","when",...kr]),ae=class extends Error{};function Or(e){if(typeof e!="string")throw new TypeError("source must be a string");let t=new Be(e),r=[];function n(b,u,h){throw r.push(I(e,b,u,h)),new ae}function i(b,u){t.skip();let h=t.offset;t.take(b)||n("syntax",u,{start:h,end:h+1})}function o(b){t.skip();let u=t.word();return u||n("syntax",b,{start:t.offset,end:t.offset+1}),u}function a(){let b=t.offset;if(t.word()?.value!=="content"||!t.take(".")){t.offset=b;return}let h=t.word();return h||n("syntax","Expected content name",{start:b,end:t.offset}),{kind:"content",name:h.value,start:b,end:h.end}}function s(b,u=!1){t.skip();let h=a();if(h)return h;try{let w=t.string();return w||n("syntax",b,{start:t.offset,end:t.offset+1}),!u&&t.source.slice(w.start,w.start+3)==='"""'&&n("declaration","Triple-quoted content is only supported in the content block",w),{kind:"string",...w}}catch(w){if(w instanceof ae)throw w;let m=w;n("syntax",w instanceof Error?w.message:String(w),{start:m.start??t.offset,end:m.end??t.offset})}}function l(b="line"){try{let u=t.expression(b);return u.value.trim()||n("syntax","Expected expression",u),u}catch(u){if(u instanceof ae)throw u;let h=u;n("syntax",u instanceof Error?u.message:String(u),{start:h.start??t.offset,end:h.end??t.offset})}}function c(){let b=t.offset;i("{","Expected '{' after vars");let u=[];for(;!t.eof;){if(t.skip(),t.take("}"))return{kind:"vars",names:u,start:b,end:t.offset};let h=o("Expected variable name");Ue.has(h.value)&&r.push(I(e,"declaration",`Reserved variable name ${h.value}`,h)),u.push(h)}n("syntax","Unterminated vars block",{start:b,end:t.offset})}function f(){let b=t.offset;i("{","Expected '{' after content");let u=[];for(;!t.eof;){if(t.skip(),t.take("}"))return{kind:"content",entries:u,start:b,end:t.offset};let h=o("Expected content name");Ue.has(h.value)&&r.push(I(e,"declaration",`Reserved content name ${h.value}`,h));let w=s("Expected quoted content",!0);u.push({name:h,value:w,start:h.start,end:w.end})}n("syntax","Unterminated content block",{start:b,end:t.offset})}function p(){let b=t.offset;if(t.skip(),t.take("="))return{kind:"formula",expression:l(),start:b,end:t.offset};i("{","Expected '=' or '{' after options");let u=[];for(;!t.eof;){if(t.skip(),t.take("}"))return{kind:"literal",entries:u,start:b,end:t.offset};let h=t.offset,w;try{w=t.string()}catch(d){let _=d;n("syntax",d instanceof Error?d.message:String(d),{start:_.start??h,end:_.end??t.offset})}w&&t.source.slice(w.start,w.start+3)==='"""'&&n("declaration","Triple-quoted option values are not supported",w),w||(w=o("Expected option value"));let m=s("Expected option label");u.push({value:w,label:m,start:h,end:m.end})}n("syntax","Unterminated options block",{start:b,end:t.offset})}function g(b){t.skip(),t.take("=")||n("syntax","Expected '=' after validate",{start:t.offset,end:t.offset+1});let u=l("otherwise");t.skip(!1),t.word()?.value!=="otherwise"&&n("syntax","Expected 'otherwise' after validation predicate",{start:t.offset,end:t.offset+1});let w=s("Expected validation message");return{predicate:u,message:w,start:b,end:w.end}}function E(b){let u=l("arrow");t.take("->")||n("syntax","Expected '->' in copy declaration",{start:t.offset,end:t.offset+2}),t.skip(!1);let h=t.offset,m=/^(?:[A-Za-z_][A-Za-z0-9_]*)(?:\.[A-Za-z_][A-Za-z0-9_]*)*/.exec(e.slice(t.offset))?.[0];m||n("declaration","Copy destination must be a dotted path",{start:h,end:h+1}),t.offset+=m.length;let d={value:m,start:h,end:t.offset};for(;t.peek()===" "||t.peek()===" "||t.peek()==="\r";)t.offset+=1;if(t.peek()==="#")for(;!t.eof&&t.peek()!==`
59
+ `;)t.offset+=1;t.peek()===`
60
+ `&&(t.offset+=1);let _=t.offset;t.skip(!1);let j=t.word(),R;return j?.value==="when"?(t.skip(),t.take("=")||n("syntax","Expected '=' after when",j),R=l()):t.offset=_,{value:u,destination:d,...R?{when:R}:{},start:b,end:R?.end??d.end}}function v(b){for(i("{",`Expected '{' after ${b.type} declaration`),b.properties=[],b.validations=[],b.copies=[],b.children=[];!t.eof;){if(t.skip(),t.take("}")){b.end=t.offset;return}let u=t.offset;try{if(t.peek()==="*"){b.children.push($());continue}let h=t.word();if(h||n("syntax","Expected declaration",{start:u,end:u+1}),["required","relevant","readOnly"].includes(h.value)){if(t.skip(),!t.take("=")){if(h.value==="readOnly"){t.offset=u,b.children.push($());continue}n("syntax",`Expected '=' after ${h.value}`,h)}b.properties.push({name:h.value,expression:l(),start:u,end:t.offset})}else h.value==="options"?(b.options&&n("declaration","Duplicate options declaration",h),b.options=p()):h.value==="validate"?b.validations.push(g(u)):h.value==="copy"?b.copies.push(E(u)):(t.skip(!1),t.peek()==="="&&n("declaration",`Unsupported property ${h.value}`,h),t.offset=u,b.children.push($()))}catch(h){if(!(h instanceof ae))throw h;t.recover()}}n("syntax",`Unterminated ${b.type} block`,{start:b.start,end:t.offset})}function $(){t.skip();let b=t.offset,u=!1,h=!1;t.take("*")&&(u=!0,h=!0,t.skip(!1));let w;/^multi-select\b/.test(e.slice(t.offset))?(w={value:"multi-select",start:t.offset,end:t.offset+12},t.offset=w.end):w=o("Expected field declaration"),Kn.has(w.value)&&n("declaration",`Unsupported declaration type ${w.value}`,w);let m="text";kr.has(w.value)&&(m=w.value,h&&n("declaration","Required marker must immediately precede the field ID",{start:b,end:w.end}),t.skip(),t.take("*")&&(u&&n("declaration","Duplicate required marker",{start:t.offset-1,end:t.offset}),u=!0,t.skip(!1)),w=o("Expected field ID")),Ue.has(w.value)&&n("declaration",`Reserved declaration identifier ${w.value}`,w);let d=w,_;m==="object"||m==="table"?(t.skip(),_=t.peek()==="{"?void 0:s("Expected quoted label or '{'")):_=s("Expected field label");let j={kind:"node",type:m,id:d,label:_,marker:u,start:b,end:_?.end??d.end};return t.skip(),m==="calculated"?(t.take("=")||n("declaration","Calculated field requires '= <expression>'",{start:t.offset,end:t.offset+1}),j.calculate=l(),j.end=j.calculate.end,t.skip(),t.peek()==="{"&&v(j)):m==="object"||m==="table"?v(j):(t.skip(),t.peek()==="{"?v(j):(j.properties=[],j.validations=[],j.copies=[],j.children=[])),j}t.skip();let y=t.offset,A=t.word();A?.value!=="form"&&r.push(I(e,"syntax","Document must begin with 'form 1 <id>'",{start:y,end:A?.end??y+1})),t.skip();let O=t.number();O?O.value!==1&&r.push(I(e,"declaration",`Unsupported language version ${O.value}`,O)):r.push(I(e,"syntax","Expected language version",{start:t.offset,end:t.offset+1})),t.skip();let x=t.word();x?Ue.has(x.value)&&r.push(I(e,"declaration",`Reserved document ID ${x.value}`,x)):r.push(I(e,"syntax","Expected document ID",{start:t.offset,end:t.offset+1})),t.recover();let S=[];for(;!t.eof&&(t.skip(),!t.eof);){let b=t.offset;if(t.peek()==="*"){try{S.push($())}catch(h){if(!(h instanceof ae))throw h;t.recover()}continue}let u=t.word();if(!u){r.push(I(e,"syntax","Unexpected token",{start:b,end:b+1})),t.peek()==="}"?t.offset+=1:t.recover();continue}try{u.value==="vars"?S.push(c()):u.value==="content"?S.push(f()):(t.offset=b,S.push($()))}catch(h){if(!(h instanceof ae))throw h;t.recover()}}if(r.length)throw new K(r);return{id:x?.value??"",version:1,declarations:S,start:y,end:e.length}}function Jn(e){let t=Or(e),r=xr(e,t);try{let n=ve({schema:r.compiled.schema,varsShape:dr(r.compiled.vars),executable:!1,locateFormulaError:Cr(r)});return{...r,compiled:{...r.compiled,schema:n},document:t}}catch(n){throw Sr(e,r,n)}}function $r({source:e,data:t={},vars:r={}}){let n=Jn(e);if(r===null||typeof r!="object"||Array.isArray(r))throw new K([I(e,"vars","vars must be a JSON-compatible object",n.document)]);let i=n.document.declarations.find(s=>s.kind==="vars"),o=[];for(let s of n.compiled.vars)if(!Object.hasOwn(r,s)){let l=i?.names.find(c=>c.value===s)??n.document;o.push(I(e,"vars",`Missing declared var ${s}`,l))}if(o.length)throw new K(o);let a;try{a=de(r)}catch(s){throw _r(e,n,s)}try{ve({schema:n.compiled.schema,data:t,varsShape:pe(a),executable:!1,locateFormulaError:Cr(n)})}catch(s){throw _r(e,n,s)}try{return vr({schema:n.compiled.schema,data:t,vars:a})}catch(s){throw s instanceof K?s:Sr(e,n,s)}}function Cr(e){return t=>{let r=`${JSON.stringify(t.schemaPath)}:${t.property}`;for(let n of e.formulaFragments.get(r)??[])try{t.check(n.formula)}catch(i){return{cause:i,location:n.range}}}}function _r(e,t,r){let n=t.document.declarations.find(i=>i.kind==="vars");return new K([I(e,"vars",r instanceof Error?r.message:String(r),n??t.document)],{cause:r})}function Sr(e,t,r){let n=r,i=n.schemaPath&&n.property?`${JSON.stringify(n.schemaPath)}:${n.property}`:void 0,o=n.preparationLocation??(i?t.ruleRanges.get(i):void 0);!o&&n.schemaPath&&(o=t.nodeRanges.get(JSON.stringify(n.schemaPath)));let a=o??t.document??{start:0,end:e.length},s=typeof n.offset=="number"?Math.min(a.end,a.start+n.offset):a.start,l=n.schemaPath&&n.property?"expression":"schema";return new K([I(e,l,n.message??String(r),{start:s,end:typeof n.offset=="number"?Math.min(a.end,s+1):a.end})],{cause:r})}var ke=new WeakMap,Oe=new WeakMap;function Hn(e){let t=ke.get(e);if(t){for(let n of t)n.elem.removeEventListener(n.type,n.listener,n.capture);ke.delete(e)}let r=Oe.get(e);if(r){for(let n of r)n();Oe.delete(e)}}function kt(e){let t=Array.from(e.childNodes);Hn(e),t.forEach(r=>{kt(r)})}var F={clear(e){for(Array.from(e.childNodes).forEach(t=>kt(t));e.firstChild;)e.removeChild(e.firstChild)},remove(e){kt(e),e.parentNode?.removeChild(e)},append(e,t){typeof t=="string"?e.appendChild(document.createTextNode(t)):Array.isArray(t)?t.forEach(r=>e.appendChild(r)):e.appendChild(t)},set(e,t){return this.clear(e),this.append(e,t)},addCleanup(e,t){Oe.has(e)?Oe.get(e).push(t):Oe.set(e,[t])},subscribe(e,t,r){this.addCleanup(e,t.subscribe(r))},addEventListener(e,t,r,n){let i=typeof n=="boolean"?n:!!n?.capture;e.addEventListener(t,r,n);let o=e;return ke.has(o)?ke.get(o).push({elem:e,type:t,listener:r,capture:i}):ke.set(o,[{elem:e,type:t,listener:r,capture:i}]),o}},te=class{constructor(){this._listeners=[]}get(){throw new Error("Watchable#get() is abstract; override in subclass")}_notify(e){this._listeners.forEach(t=>t(e))}notify(){this._notify(this.get())}subscribe(e){return this._listeners.push(e),()=>{this._listeners=this._listeners.filter(t=>t!==e)}}},Tr=class extends te{constructor({r:e,w:t}){super(),this._reader=e,this._writer=t}get(){return this._reader()}set(e){this._writer(e),this._notify(this.get())}orElse(e){return this.get()||e}orElseGet(e){return this.get()||e()}toString(){return this.get()}},Xn=class extends te{constructor(e){super(),this._unsubs=e.map(t=>t.subscribe(r=>{this._notify(t)}))}subscribe(e){let t=super.subscribe(e);return()=>{t(),this._listeners.length===0&&(this._unsubs.forEach(r=>r()),this._unsubs=[])}}};function G(e,t=void 0){return t===void 0?Qn(e):new Tr({r:()=>e[t],w:r=>e[t]=r})}function Qn(e){return new Tr({r:()=>e,w:t=>e=t})}function Dr(...e){return new Xn(e)}var Zn=class extends te{constructor(e,t){super(),this._fn=e,this._sources=t,this._unsubs=[]}get(){return this._fn()}orElse(e){return this.get()||e}orElseGet(e){return this.get()||e()}toString(){return this.get()}subscribe(e){this._listeners.length===0&&(this._unsubs=this._sources.map(r=>r.subscribe(()=>this._notify(this.get()))));let t=super.subscribe(e);return()=>{t(),this._listeners.length===0&&(this._unsubs.forEach(r=>r()),this._unsubs=[])}}};function z(e,...t){return new Zn(e,t)}var Ve={capture:!0};function Yn(e,t,r){let n=t(r);return F.subscribe(e,r,()=>{let i=t(r);F.set(e,i)}),F.set(e,n),e}function Gn(e,t,r="change"){return e.checked=t.get(),F.addEventListener(e,r,n=>t.set(n.target.checked),Ve),F.subscribe(e,t,n=>e.checked=n),e}function ei(e,t,r="change"){return e.checked=t.get()===e.value,F.addEventListener(e,r,n=>t.set(n.target.value),Ve),F.subscribe(e,t,n=>{e.checked=n===e.value}),e}function ti(e){if(!(e instanceof te)||!("set"in e)||typeof e.set!="function")throw new TypeError("bind.ref must be a writable Watchable")}function ri(e){if(!(e instanceof te))throw new TypeError("bind.source must be a Watchable")}function ni({ref:e,source:t,read:r}){if(r!==void 0&&t===void 0)throw new TypeError("bind.read requires bind.source");if(r!==void 0&&typeof r!="function")throw new TypeError("bind.read must be a function");if(t!==void 0&&ri(t),r!==void 0&&t===e)throw new TypeError("bind.read requires bind.source and bind.ref to be different Watchables")}function Pr(e,t="text"){let r=oi(e),{ref:n,source:i,read:o}=r;if(ti(n),t==="checkbox"||t==="radio"){if(i!==void 0||o!==void 0)throw new TypeError("bind.source and bind.read are only supported for scalar value controls")}else ni(r);return r}function ii(e,{ref:t,source:r,read:n,event:i="input"}){let o=r??t,a=n??(E=>E),s,l=!1,c=0,f=E=>{let v=a(E);e.value=v??"",s=e.value,l=!1,c++},p=()=>{l=e.value!==s},g=()=>{if(p(),!l)return;let E=e.value,v=c;t.set(E),c===v&&(s=E,l=!1)};return f(o.get()),F.subscribe(e,o,f),i==="input"?F.addEventListener(e,"input",g,Ve):(F.addEventListener(e,"input",p),F.addEventListener(e,i,g,Ve)),e}function oi(e){return e&&"ref"in e?e:{ref:e}}function ai(e,t){if(e.type==="file")throw new TypeError("File input binding is unsupported");if(e.type==="select-multiple")throw new TypeError("Multiple-select binding is unsupported");let r=e.type==="checkbox"||e.type==="radio"?e.type:"text",n=Pr(t,r),{ref:i,event:o}=n;switch(e.type){case"checkbox":return Gn(e,i,o);case"radio":return ei(e,i,o);default:return ii(e,n)}}function si(...e){let t=[];for(let r=0;r<e.length;r=r+2){let n=e[r],i=e[r+1];if(!_t(jt,Ot)(n))throw new Error("matcher at ["+r+"] must be a list of functions or a single function");if(!Ot(i))throw new Error("func at ["+(r+1)+"] must be a function");let o=n.filter(l=>!l.__isVarg).length,a=o<n.length,s=l=>(a?l.length>=o:l.length===o)&&n.every((c,f)=>c.__isVarg?c(l.slice(f)):c(l[f]));t.push({isMatch:s,func:i})}return(...r)=>{for(let n=0;n<t.length;n++){let i=t[n];if(i.isMatch(r))return i.func(...r)}throw new Error("no function found that can handle the arguments: "+r)}}var he=e=>t=>typeof t===e,li=e=>e instanceof Map,jt=e=>Array.isArray(e),Ot=he("function"),ci=he("number"),ui=he("string"),fi=he("boolean"),di=he("symbol"),pi=he("bigint"),Ir=e=>e===void 0,Rr=e=>e===null,xe=e=>Ir(e)||Rr(e),jr=e=>!xe(e),hi=e=>typeof e=="object"&&!Rr(e)&&!jt(e),Ar=(...e)=>t=>e.every(r=>r(t)),_t=(...e)=>t=>e.some(r=>r(t)),mi=e=>t=>!e(t),bi=e=>Object.assign(t=>e?t.every(e):!0,{__isVarg:!0}),yi=e=>t=>t instanceof e,wi=()=>!0,T={arr:()=>jt,map:()=>li,any:()=>wi,func:()=>Ot,num:()=>ci,str:()=>ui,bool:()=>fi,bigint:()=>pi,sym:()=>di,undef:()=>Ir,obj:()=>hi,nil:e=>xe(e)?xe:_t(xe,e),notNil:e=>xe(e)?jr:Ar(jr,e),matcher:si,rest:bi,eq:e=>t=>t===e,or:_t,and:Ar,not:mi,instOf:yi};function gi(){return Math.random().toString(36).substring(7)}var Nr=T.instOf(te),qr=T.func(),vi=class extends te{constructor(e){super(),this.value=e}get(){return this.value}subscribe(e){return this.disposed?()=>{}:super.subscribe(e)}_publish(e){this.disposed||(this.value=e,this._notify(e))}_dispose(){this.disposed||(this.disposed=!0,this.value=void 0,this._listeners=[])}};function Ei(e,t,r,n){t.id||(t.id=gi);let[i,o]=r,a=Nr(i)?i:G(i),s=qr(t.id)?t.id:g=>g[t.id],l=new Map,c=g=>(l.get(g)||l.set(g,s(g)),g),f=g=>l.get(g),p=(g,E)=>{let v=e(o(g,E),n);return v.dataset.__vid=f(g),v};return F.subscribe(n,a,()=>{let g=a.get(),E=new Set(g),v=new Map(g.map(y=>(c(y),[f(y),y])));for(let y of l.keys())E.has(y)||l.delete(y);let $=n.childNodes;for(let y=$.length-1;y>=0;y--){let A=$[y];v.has(A.dataset.__vid)||F.remove(A)}for(let y=0;y<g.length;y++){let A=g[y],O=$[y];O?O.dataset.__vid!==f(A)&&n.insertBefore(p(A,y),O):n.appendChild(p(A,y))}}),a.get().map((g,E)=>p(c(g),E))}function xi(e,t,r,n){if(!Object.prototype.hasOwnProperty.call(t,"id"))throw new Error("foreach resource mode requires an explicit id selector");let[i,o]=r,a=Nr(i)?i:G(i),s=qr(t.id)?t.id:y=>y[t.id],l=new Map,c=document.createComment("foreach:start"),f=document.createComment("foreach:end"),p=y=>{let A=y.map((x,S)=>({item:x,index:S,key:s(x)})),O=new Set;for(let{key:x}of A){if(x==null)throw new Error("foreach resource mode id selector returned a null or undefined key");if(O.has(x))throw new Error("foreach requires unique keys");O.add(x)}return A},g=y=>y.resource._dispose(),E=(y,A,O)=>{let x=new vi(y),S=e(o(y,A,x),n);S.dataset.__vid=String(O);let b={node:S,resource:x};return l.set(O,b),b},v=()=>{let y=f.parentNode;if(!y||c.parentNode!==y)return;let A=p(a.get()),O=new Set(A.map(({key:S})=>S));for(let[S,b]of l)O.has(S)||(l.delete(S),F.remove(b.node),g(b));let x=c.nextSibling;A.forEach(({item:S,index:b,key:u})=>{let h=l.get(u);h?h.resource._publish(S):h=E(S,b,u),h.node!==x&&y.insertBefore(h.node,x),x=h.node.nextSibling})},$=p(a.get()).map(({item:y,index:A,key:O})=>E(y,A,O).node);return F.subscribe(f,a,v),F.addCleanup(f,()=>{for(let y of l.values())g(y);l.clear()}),[c,...$,f]}function ki(e,t,r,n){return t.resource===!0?xi(e,t,r,n):Ei(e,t,r,n)}var Oi=e=>({__condaReactiveText:e}),_i=e=>({__condaReactiveProperty:e}),$i=e=>({__condaReactiveAttribute:e}),vt=(e,t)=>t===void 0?e:z(()=>t(e.get()),e),D=Object.freeze({text:(e,t)=>Oi(vt(e,t)),prop:(e,t)=>_i(vt(e,t)),attr:(e,t)=>$i(vt(e,t))}),$t=e=>e?.__condaReactiveText,Lr=e=>e?.__condaReactiveProperty,Mr=e=>e?.__condaReactiveAttribute,Ci=T.or(T.str(),T.num(),T.bool(),T.bigint(),T.sym()),Et={text:{event:"input"},checkbox:{event:"change"},radio:{event:"change"}},Si=new Set(["button","checkbox","color","date","datetime-local","email","file","hidden","image","month","number","password","radio","range","reset","search","submit","tel","text","time","url","week"]),ji=new Set(["hidden","button","submit","reset","image"]),xt=T.and(T.obj(),T.not(T.or(T.instOf(te),T.instOf(St),T.instOf(HTMLElement),T.instOf(DocumentFragment),e=>!!$t(e)))),Ai=T.matcher([T.str()],e=>({attrs:{},children:[]}),[T.str(),xt],(e,t)=>({attrs:t,children:[]}),[T.str(),xt,T.instOf(St)],(e,t,r)=>({attrs:t,children:r._elems}),[T.str(),xt,T.rest()],(e,t,...r)=>({attrs:t,children:[...r]}),[T.str(),T.instOf(St)],(e,t)=>({attrs:{},children:t._elems}),[T.str(),T.rest()],(e,...t)=>({attrs:{},children:[...t]}));function Ti(e={}){let t=e.bindings??{};return{bindings:{text:{...Et.text,...t.text},checkbox:{...Et.checkbox,...t.checkbox},radio:{...Et.radio,...t.radio}}}}function Ct(e){let t=Lr(e),r=Mr(e),n=t??r;return n?n.get():e}function Di(e){if(!("type"in e))return"text";let t=String(Ct(e.type)).toLowerCase();return Si.has(t)?t:"text"}function Pi(e,t){let r=e.tagName?.toLowerCase();if(r==="input"){let n=Di(t);return n==="file"?{kind:"unsupported",type:n}:n==="checkbox"||n==="radio"?{kind:n,type:n}:{kind:ji.has(n)?"native":"scalar",type:n}}return r==="textarea"?{kind:"scalar"}:r==="select"?{kind:Ct(t.multiple)?"unsupported":"scalar",type:Ct(t.multiple)?"multiple":"single"}:{kind:"other"}}function Ii(e,t,r){let n=Pi(t,e),i=Object.prototype.hasOwnProperty.call(e,"value"),o=Object.prototype.hasOwnProperty.call(e,"bind");if(n.kind==="scalar"&&i)throw new TypeError("Editable scalar controls cannot declare value; use bind instead");if(n.kind==="unsupported"&&o)throw new TypeError(n.type==="file"?"File input binding is unsupported":"Multiple-select binding is unsupported");if(!o)return null;let a=n.kind==="checkbox"||n.kind==="radio"?n.kind:"text";return Pr(Ri(e.bind,r.bindings[a]),a)}function Ri(e,t){return e&&"ref"in e?{...t,...e}:{...t,ref:e}}function ze(e){let t=Ti(e);function r(a,s){return a.map(l=>o(l,s)).flat()}function n(a,s){let l=Ii(a,s,t);for(let c of Object.keys(a)){if(c==="bind")continue;let f=Lr(a[c]),p=Mr(a[c]);if(f)s[c]=f.get(),F.subscribe(s,f,g=>s[c]=g);else if(p){let g=E=>E==null||E===!1?s.removeAttribute(c):s.setAttribute(c,String(E));g(p.get()),F.subscribe(s,p,g)}else c==="onmount"?queueMicrotask(()=>a[c](s)):c.startsWith("on")?F.addEventListener(s,c.substring(2).toLowerCase(),a[c]):c in s?s[c]=a[c]:s.setAttribute(c,a[c])}return l&&(()=>ai(s,l))}function i(a,s){let{attrs:l,children:c}=Ai.apply(null,a),f=l.watch;Array.isArray(f)&&(f=Dr(...f)),delete l.watch;let p=a[0],g;switch(p){case"foreach":return ki(o,l,c,s);case"frag":g=document.createDocumentFragment();break;default:g=document.createElement(p)}let E=n(l,g);if(f)Yn(g,()=>r(c,g),f);else for(let v of r(c,g))g.appendChild(v);return E?.(),g}let o=T.matcher([T.and(T.obj(),a=>!!$t(a)),T.any()],a=>{let s=$t(a),l=document.createTextNode(s.get());return F.subscribe(l,s,c=>l.data=c),l},[Ci,T.any()],(a,s)=>document.createTextNode(a),[T.func(),T.any()],(a,s)=>o(a(),s),[T.or(T.instOf(HTMLElement),T.instOf(DocumentFragment)),T.any()],(a,s)=>a,[T.instOf(te),T.any()],(a,s)=>o(a.get(),s),[T.any(),T.any()],(a,s)=>i(a,s),[T.any()],a=>i(a,null));return{render:o}}var Ni=ze(),qi=Ni.render,At=new Proxy({},{get(e,t){return(...r)=>[t,...r]}});function St(e){this._elems=e}function Tt(e){F.remove(e)}function re(e,t,r){let n=We(e),i=r.map(We).join(".");return`umbika-${n}-${t}-${i}`}function V(e,t,r){let n=We(e),i=r.map(We).join(".");return`umbika-${n}-${t}-${i}`}function _e(e){return e.path.map(t=>`${t.length}:${t}`).join("|")}function We(e){return encodeURIComponent(e).replaceAll(".","%2E")}function Fr(e,t){if(e===void 0)return Object.freeze({tables:Object.freeze([])});if(!Dt(e))throw new TypeError("layout must be an object");if(e.tables!==void 0&&!Array.isArray(e.tables))throw new TypeError("layout.tables must be an array");let r=new Set,n=(e.tables??[]).map((i,o)=>{let a=`layout table ${o+1}`;if(!Dt(i))throw new TypeError(`${a} must be an object`);let s=Vr(i.path,`${a} path`),l=Ke(s);if(r.has(l))throw new TypeError(`${a} duplicates ${Je(s)}`);r.add(l);let c=Ur(t,s,`${a} path`);if(c.type!=="table")throw new TypeError(`${a} path ${Je(s)} must identify a table`);if(i.mode!=="cards"&&i.mode!=="table")throw new TypeError(`${a} mode must be "cards" or "table"`);let f=Li(i.columns,c.children,a);return Object.freeze({path:s,mode:i.mode,columns:f})});return Object.freeze({tables:Object.freeze(n)})}function Br(e){if(e===void 0)return"default";if(typeof e!="string"||!/^[A-Za-z][A-Za-z0-9_-]*$/.test(e))throw new TypeError("theme must start with a letter and contain only letters, numbers, hyphens, or underscores");return e}function me(e,t){let r=Ke(t);return e.tables.find(n=>Ke(n.path)===r)}function Li(e,t,r){if(e===void 0)return;if(!Array.isArray(e))throw new TypeError(`${r} columns must be an array`);if(e.length===0||e.length>4)throw new TypeError(`${r} columns must contain one to four entries`);let n=new Set;return Object.freeze(e.map((i,o)=>{let a=`${r} column ${o+1}`;if(!Dt(i))throw new TypeError(`${a} must be an object`);let s=Vr(i.path,`${a} path`),l=Ke(s);if(n.has(l))throw new TypeError(`${a} duplicates ${Je(s)}`);n.add(l);let c=Ur(t,s,`${a} path`);if(c.type==="object"||c.type==="table")throw new TypeError(`${a} must identify a summary field`);if(i.label!==void 0&&(typeof i.label!="string"||i.label.trim()===""))throw new TypeError(`${a} label must be a non-empty string`);if(i.align!==void 0&&i.align!=="start"&&i.align!=="center"&&i.align!=="end")throw new TypeError(`${a} align must be "start", "center", or "end"`);return Object.freeze({key:l,path:s,label:i.label??c.label,align:i.align??"start"})}))}function Ur(e,t,r){let n=e,i;for(let o of t){if(i=n.find(a=>a.id===o),!i)throw new TypeError(`${r} ${Je(t)} does not exist`);n=i.type==="object"||i.type==="table"?i.children:[]}return i}function Vr(e,t){if(!Array.isArray(e)||e.length===0||e.some(r=>typeof r!="string"||r.trim()===""))throw new TypeError(`${t} must be a non-empty path of non-empty strings`);return Object.freeze([...e])}function Ke(e){return e.map(t=>`${t.length}:${t}`).join("|")}function Je(e){return JSON.stringify(e)}function Dt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var Mi=At,{article:zr,button:Z,caption:Wr,dialog:Kr,div:U,fieldset:He,foreach:X,form:Jr,frag:Hr,h2:Xr,h3:Qr,input:Xe,label:Qe,legend:Ze,li:Zr,option:Pt,output:Yr,p:fe,section:Gr,select:en,ul:tn,table:rn,tbody:nn,td:It,th:Rt,thead:on,tr:Nt}=Mi;function se(e,t,r){let n=re(e,"control",t.path),i=re(e,"description",t.path),o=re(e,"errors",t.path);return{control:n,describedBy:`${i} ${o}`,label:Qe({class:"umbika-field__label",for:n},D.text(r,a=>a&&"label"in a?a.label:"")),legend:Ze({class:"umbika-field__label"},D.text(r,a=>a&&"label"in a?a.label:"")),descriptionId:i,errors:$e(o,r)}}function $e(e,t){return tn({id:e,class:"umbika-field__errors","aria-live":"polite",watch:t},()=>Hr(...(t.get()?.errors??[]).map(r=>Zr(r.message))))}function le(e,t){return fe({id:e,class:"umbika-field__description"},t)}function Ce(e){return e==null||e===""?"\u2014":String(e)}function an(e,t){let r=e.get();if(!r||r.type!=="object")return"";let n=V(t.instanceId,"errors",r.path),i=z(()=>{let o=e.get();return o?.type==="object"?o.children:[]},e);return He({id:V(t.instanceId,"object",r.path),class:"umbika-object","data-umbika-kind":"object","aria-describedby":n,tabindex:"-1","data-umbika-invalid":D.attr(e,o=>o?.type==="object"&&o.errors.length>0?"true":"false")},Ze({class:"umbika-object__heading"},D.text(e,o=>o?.type==="object"?o.label??o.id:"")),$e(n,e),t.renderNodes(i,t.definitionPath))}function sn(e,t){let r=e.get();if(!r||r.type!=="multi-select")return"";let n=se(t.instanceId,r,e),i=z(()=>Ui(e.get()),e);return He({id:n.control,class:"umbika-field umbika-multi-select","data-umbika-kind":"multi-select","data-umbika-required":D.attr(e,o=>String(o?.type==="multi-select"&&o.required)),"data-umbika-invalid":D.attr(e,o=>String(o?.type==="multi-select"&&o.errors.length>0)),"aria-invalid":D.attr(e,o=>String(o?.type==="multi-select"&&o.errors.length>0)),"aria-describedby":n.describedBy},n.legend,le(n.descriptionId,"Choose any options that apply"),U({class:"umbika-multi-select__choices"},X({id:"value",resource:!0},i,(o,a,s)=>Fi(r.path,o,s,e,t))),Z({type:"button",class:"umbika-action umbika-multi-select__clear",hidden:D.prop(e,o=>o?.type!=="multi-select"||o.required),disabled:D.prop(e,o=>o?.type!=="multi-select"||!Array.isArray(o.value)||o.value.length===0),onclick:()=>{let o=e.get();!o||o.type!=="multi-select"||o.required||t.commitMultiSelect?.(o.path,[])}},"Clear selection"),n.errors)}function Fi(e,t,r,n,i){let o=re(i.instanceId,"choice",[...e,t.value]);return Qe({class:D.attr(r,a=>a?.unavailable?"umbika-multi-select__choice umbika-multi-select__choice--unavailable":"umbika-multi-select__choice"),"data-umbika-choice":t.value,"data-umbika-unavailable":D.attr(r,a=>String(a?.unavailable===!0)),for:o},Xe({id:o,class:"umbika-field__control umbika-multi-select__control",type:"checkbox",value:t.value,checked:D.prop(n,a=>a?.type==="multi-select"&&Array.isArray(a.value)?a.value.includes(t.value):!1),onchange:a=>{let s=n.get(),l=a.currentTarget;if(!s||s.type!=="multi-select"||!(l instanceof HTMLInputElement))return;let c=t.value,f=Bi(s.value,c,l.checked);i.commitMultiSelect?.(s.path,f)}}),D.text(r,a=>a?`${a.label}${a.unavailable?" \u2014 unavailable":""}`:""))}function Bi(e,t,r){let n=Array.isArray(e)?e.filter((i,o,a)=>typeof i=="string"&&a.indexOf(i)===o):[];return r?n.includes(t)?n:[...n,t]:n.filter(i=>i!==t)}function Ui(e){if(!e||e.type!=="multi-select")return[];let t=new Set(e.options.map(i=>i.value)),r=e.options.map(i=>Object.freeze({...i,unavailable:!1}));if(!Array.isArray(e.value))return r;let n=new Set(t);for(let i of e.value)typeof i!="string"||n.has(i)||(n.add(i),r.push(Object.freeze({value:i,label:i,unavailable:!0})));return r}function cn(e,t){let r=e.get();if(!r||!("value"in r))return"";let n=r.type==="calculated",i=se(t.instanceId,r,e);return U({class:n?"umbika-field umbika-field--calculated":"umbika-field","data-umbika-kind":r.type,"data-umbika-readonly":"true"},i.label,le(i.descriptionId,n?"Calculated automatically":"Read only"),Yr({id:i.control,class:n?"umbika-calculated":"umbika-field__output",tabindex:"-1","aria-live":"polite","aria-invalid":D.attr(e,o=>String(o&&"value"in o&&o.errors.length>0)),"aria-describedby":i.describedBy},D.text(e,o=>o&&"value"in o?Vi(o):"")),i.errors)}function Vi(e){return e.type==="select"&&typeof e.value=="string"&&e.value!==""?ln(e.options,e.value):e.type==="multi-select"&&Array.isArray(e.value)?Ce(e.value.map(t=>ln(e.options,t)).join(", ")):Ce(e.value)}function ln(e,t){return e.find(r=>r.value===t)?.label??`${String(t)} (unavailable)`}function fn(e,t){let r=e.get();if(!r||r.type!=="select")return"";let n=se(t.instanceId,r,e),i=G(un(r.value)),o=z(()=>{let a=e.get();return a?.type==="select"?a.options:[]},e);return i.subscribe(a=>{let s=e.get();!s||s.type!=="select"||t.commitSelect?.(s.path,String(a)===""?void 0:s.options.find(l=>l.value===String(a)))}),U({class:"umbika-field","data-umbika-kind":"select"},n.label,le(n.descriptionId,"Choose one option"),en({id:n.control,class:"umbika-field__control",bind:{ref:i,source:e,read:a=>a?.type==="select"?un(a.value):"",event:"change"},required:D.prop(e,a=>a?.type==="select"?a.required:!1),"aria-required":D.attr(e,a=>String(a?.type==="select"&&a.required)),"aria-invalid":D.attr(e,a=>String(a?.type==="select"&&a.errors.length>0)),"aria-describedby":n.describedBy},Pt({value:""},"Select\u2026"),X({id:"value",resource:!0},o,(a,s,l)=>Pt({value:a.value},D.text(l,c=>c?.label??"")))),n.errors)}function un(e){return e==null?"":String(e)}function Ye(e){let t=0;for(let r of e)if(t+=r.errors.length,r.type==="object")t+=Ye(r.children);else if(r.type==="table")for(let n of r.rows)t+=Ye(n.children);return t}function Ge(e,t){if(t)return t;let r=[],n=new Set;for(let i of e)if(dn(i.children,[],r,n),r.length===4)break;return r}function et(e,t){let r=pn(e.children,t);if(!r)return{available:!1,display:"\u2014"};let n=zi(r);return{available:!0,display:Ce(n)}}function tt(e,t){for(let r of t){let n=et(e,r.path);if(n.available)return n}return{available:!1,display:"row"}}function dn(e,t,r,n){for(let i of e){if(r.length===4)return;let o=[...t,i.id];if(i.type==="object"){dn(i.children,o,r,n);continue}if(i.type==="table")continue;let a=Wi(o);n.has(a)||(n.add(a),r.push(Object.freeze({key:a,path:Object.freeze(o),label:i.label,align:"start"})))}}function pn(e,t){let[r,...n]=t;if(r===void 0)return;let i=e.find(o=>o.id===r);if(i)return n.length>0?i.type==="object"?pn(i.children,n):void 0:i.type==="text"||i.type==="select"||i.type==="multi-select"||i.type==="calculated"?i:void 0}function zi(e){return e.type==="select"?e.options.find(t=>t.value===e.value)?.label??e.value:e.type!=="multi-select"||!Array.isArray(e.value)?e.value:e.value.map(t=>typeof t=="string"?e.options.find(r=>r.value===t)?.label??`${t} (unavailable)`:String(t)).join(", ")}function Wi(e){return e.map(t=>`${t.length}:${t}`).join("|")}function hn(e,t){let r=e.get();if(!r||r.type!=="table")return"";let n=r.label??r.id,i=V(t.instanceId,"table-title",r.path),o=V(t.instanceId,"add-row",r.path),a=V(t.instanceId,"table-errors",r.path),s=me(t.layout,t.definitionPath),l=s?.mode??"cards",c=z(()=>{let p=e.get();return p?.type==="table"?p.rows:[]},e),f=z(()=>{let p=e.get();return Ge(p?.type==="table"?p.rows:[],s?.columns)},e);return Gr({id:V(t.instanceId,"table",r.path),class:l==="table"?"umbika-table umbika-table--summary":"umbika-table","data-umbika-kind":"table","aria-labelledby":i,"aria-describedby":a,tabindex:"-1","data-umbika-invalid":D.attr(e,p=>p?.type==="table"&&p.errors.length>0?"true":"false")},Xr({id:i,class:"umbika-table__heading"},D.text(e,p=>p?.type==="table"?p.label??p.id:"")),l==="table"?Ji(e,c,f,n,t):Ki(c,n,t),fe({class:"umbika-table__empty"},D.text(e,p=>p?.type==="table"&&p.rows.length===0?`No ${n} rows.`:"")),$e(a,e),Z({id:o,class:"umbika-table__add-row",type:"button","aria-label":`Add row to ${n}`,onclick:()=>{let p=e.get();p?.type==="table"&&t.appendRow?.(p.path,l==="table",o,t.definitionPath)}},"Add row"))}function Ki(e,t,r){return U({class:"umbika-table__rows"},X({id:_e,resource:!0},e,(n,i,o)=>{let a=z(()=>o.get()?.children??[],o);return zr({id:V(r.instanceId,"row",n.path),class:"umbika-table__row","data-umbika-row-id":n.id,"aria-label":`${t} row`},U({class:"umbika-table__fields"},r.renderNodes(a,r.definitionPath)),Z({class:"umbika-table__remove-row",type:"button","aria-label":`Remove row from ${t}`,onclick:()=>{let s=o.get();s&&r.removeRow?.(s.path)}},"Remove row"))}))}function Ji(e,t,r,n,i){return U({class:"umbika-data-table__overflow"},rn({class:"umbika-data-table"},Wr({class:"umbika-visually-hidden"},n),on(Nt(X({id:"key",resource:!0},r,(o,a,s)=>Rt({scope:"col","data-umbika-align":D.attr(s,l=>l?.align??"start")},D.text(s,l=>l?.label??""))),Rt({scope:"col",class:"umbika-data-table__actions"},"Actions"))),nn(X({id:_e,resource:!0},t,(o,a,s)=>Hi(o,s,e,r,n,i)))))}function Hi(e,t,r,n,i,o){let a=V(o.instanceId,"row",e.path),s=V(o.instanceId,"edit-row",e.path),l=V(o.instanceId,"row-errors",e.path),c=z(()=>Ye(t.get()?.children??[]),t),f=p=>{let g=t.get();g&&o.openRow?.(g.path,p,o.definitionPath)};return Nt({id:a,class:"umbika-data-table__row","data-umbika-row-id":e.id,"aria-describedby":l,"data-umbika-invalid":D.attr(c,p=>p>0?"true":"false")},X({id:"key",resource:!0},n,(p,g,E)=>It({"data-umbika-align":D.attr(E,v=>v?.align??"start"),"aria-label":D.attr(t,v=>v&&et(v,p.path).available?null:"Unavailable")},D.text(t,v=>v?et(v,p.path).display:"\u2014"))),It({class:"umbika-data-table__actions"},fe({id:l,class:"umbika-data-table__row-errors","aria-live":"polite"},D.text(c,p=>p>0?`${p} ${p===1?"error":"errors"}`:"")),Z({id:s,type:"button",class:"umbika-data-table__edit","aria-label":D.attr(t,p=>p?Xi(p,n.get(),i):`Edit row in ${i}`),"aria-describedby":l,onclick:()=>f(s)},"Edit")))}function Xi(e,t,r){let n=tt(e,t);return n.available?`Edit ${n.display} in ${r}`:`Edit row in ${r}`}function bn(e,t){let r=e.get();if(!r||r.type!=="text")return"";let n=se(t.instanceId,r,e),i=G(mn(r.value));return i.subscribe(o=>{let a=e.get();!a||a.type!=="text"||t.setText?.(a.path,String(o))}),U({class:"umbika-field","data-umbika-kind":"text"},n.label,le(n.descriptionId,"Text response"),Xe({id:n.control,class:"umbika-field__control",type:"text",bind:{ref:i,source:e,read:o=>o?.type==="text"?mn(o.value):"",event:"blur"},required:D.prop(e,o=>o?.type==="text"?o.required:!1),"aria-required":D.attr(e,o=>String(o?.type==="text"&&o.required)),"aria-invalid":D.attr(e,o=>String(o?.type==="text"&&o.errors.length>0)),"aria-describedby":n.describedBy,onblur:()=>{let o=e.get();!o||o.type!=="text"||t.touchText?.(o.path)}}),n.errors)}function mn(e){return e==null?"":String(e)}function qt(e,t,r=[]){return X({id:n=>`${"readOnly"in n&&n.readOnly?"output:":""}${_e(n)}`,resource:!0},e,(n,i,o)=>{let a=Object.freeze({...t,definitionPath:Object.freeze([...r,n.id])});return Qi(o,a)})}function Qi(e,t){let r=e.get();if(!r)return"";if(r.type==="calculated"||"readOnly"in r&&r.readOnly)return cn(e,t);switch(r.type){case"object":return an(e,t);case"table":return hn(e,t);case"text":return bn(e,t);case"select":return fn(e,t);case"multi-select":return sn(e,t);default:return Zi(r)}}function Zi(e){let t=typeof e=="object"&&e!==null&&"type"in e?String(e.type):"unknown";throw new TypeError(`Unsupported active node type: ${t}`)}function yn(e,t){return Lt(e,t,[],[])}function wn(e,t){if(!t)return null;let r=[];for(let n of t.frames){if(!yn(e,n.rowPath))break;r.push(n)}return r.length>0?Object.freeze({frames:Object.freeze(r)}):null}function Yi(e,t,r){if(!t?.frames.length)return null;let n=[];for(let l of t.frames){let c=yn(e,l.rowPath);if(!c)break;let f=Ge([c.row],me(r,c.definitionPath)?.columns),p=tt(c.row,f);n.push({detail:c,frame:l,primary:p})}let i=n.at(-1);if(!i)return null;let o=`${i.detail.tableName} row`,a=i.primary.available?i.primary.display:o,s=i.frame.origin==="new";return Object.freeze({current:Object.freeze({...i,name:a}),depth:n.length,title:s?`Add row to ${i.detail.tableName}`:`Edit ${a}`,trail:Object.freeze(n.flatMap(l=>[l.detail.tableName,l.primary.available?l.primary.display:`${l.detail.tableName} row`])),secondary:s?"cancel":n.length>1?"back":"close"})}function gn(e,t,r,n){let i=V(r.instanceId,"workspace-title",["active-row"]),o=V(r.instanceId,"workspace-location",["active-row"]),a=z(()=>{let s=e.get(),l=Yi(t.get(),s,r.layout);return l?[l]:[]},e,t);return Kr({class:"umbika-workspace","aria-labelledby":i,"aria-describedby":o,oncancel:s=>{s.preventDefault(),n.escape()}},U({class:"umbika-workspace__contents"},X({id:s=>Gi(s.current.frame.rowPath),resource:!0},a,(s,l,c)=>{let f=z(()=>c.get()?.current.detail.row.children??[],c),p=s.current;return U({class:p.frame.origin==="new"?"umbika-workspace__panel umbika-workspace__panel--new":"umbika-workspace__panel","data-umbika-workspace-depth":String(s.depth)},U({class:"umbika-workspace__header"},Qr({id:i,class:"umbika-workspace__title",tabindex:"-1"},s.title),fe({id:o,class:"umbika-workspace__hierarchy","aria-label":"Workspace hierarchy"},s.trail.join(" / ")),p.frame.origin==="existing"?U({class:"umbika-workspace__actions umbika-workspace__navigation"},s.depth>1?Z({type:"button",class:"umbika-workspace__back",onclick:n.back},"Back"):"",Z({type:"button",class:"umbika-workspace__done",onclick:n.close},"Close")):""),U({class:"umbika-workspace__fields"},r.renderNodes(f,p.detail.definitionPath)),p.frame.origin==="new"?U({class:"umbika-workspace__confirmation-footer"},Z({type:"button",class:"umbika-workspace__discard",onpointerdown:g=>g.preventDefault(),onclick:n.cancel},"Cancel"),Z({type:"button",class:"umbika-workspace__keep",onclick:n.add},`Add row to ${p.detail.tableName}`)):U({class:"umbika-workspace__danger-area"},Z({type:"button",class:"umbika-workspace__remove","aria-label":`Remove ${p.name} from ${p.detail.tableName}`,onpointerdown:g=>g.preventDefault(),onclick:n.remove},"Remove row")))})))}function Gi(e){return e.map(t=>`${t.length}:${t}`).join("|")}function Lt(e,t,r,n){for(let i of e){let o=[...r,i.id];if(i.type==="object"){let a=Lt(i.children,t,o,n);if(a)return a;continue}if(i.type==="table")for(let a of i.rows){let s=[...n,a.path];if(eo(a.path,t))return Object.freeze({row:a,definitionPath:Object.freeze(o),parentRowPath:n.at(-1),table:i,tableName:i.label??i.id});let l=Lt(a.children,t,o,s);if(l)return l}}}function eo(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}var to=1;function Mt(e,t){if(!(e instanceof Element))throw new TypeError("target must be a DOM Element");if(!t||typeof t.form?.getActiveFields!="function")throw new TypeError("options.form must be a form-engine form");let r=t.instanceId??`web-form-${to++}`;if(r.trim().length===0)throw new TypeError("instanceId must not be empty");let n=Fr(t.layout,t.form.getFields()),i=Br(t.theme),o=!1,a=!1,s=G(t.form.getActiveFields()),l=G(null),c,f,p=()=>{if(o)return;let k=f?.contains(document.activeElement)?document.activeElement:null,C=c?.contains(k),P=t.form.getActiveFields(),q=l.get(),L=wn(P,q);L!==q&&l.set(L),s.set(P),E(),k instanceof HTMLElement&&!k.isConnected&&(C&&c?.open?A():v(q?.frames.at(-1)?.openedBy))};function g(k){let C=document.activeElement;if(C instanceof HTMLInputElement&&C.type==="text"&&!C.disabled&&!C.readOnly&&f?.contains(C)){a=!k;try{C.blur()}finally{a=!1}}}function E(){l.get()?.frames.length?c?.open||(typeof c?.showModal=="function"?c.showModal():c?.setAttribute("open","")):c?.open&&(typeof c.close=="function"?c.close():c.removeAttribute("open"))}function v(k){if(o||!f)return;let P=(k?$(k):null)??f.querySelector('input:not([disabled]), select:not([disabled]), button:not([disabled]), [tabindex="0"]')??f.querySelector("output.umbika-field__output");P instanceof HTMLElement&&P.focus()}function $(k){return f?f.querySelector(`#${oo(k)}`):null}function y(k,C=!1){o||(l.set(k.length?Object.freeze({frames:Object.freeze(k.map(ro))}):null),E(),C&&A())}function A(){let C=c?.querySelector(".umbika-workspace__fields input:not([disabled]), .umbika-workspace__fields select:not([disabled])")??c?.querySelector(".umbika-workspace__title");C instanceof HTMLElement&&C.focus()}function O(k,C,P,q){if(o)return;let L=Ft(k,P,C,q),ne=l.get()?.frames??[],Ut=ne.at(-1),kn=Ut&&vn(k,Ut.rowPath)?[...ne,L]:[L];y(kn,!0)}function x(k){let C=l.get();if(!C)return;let P=C.frames[0]?.openedBy;k&&g(!0),y([]),v(P)}function S(){let k=l.get();if(!k||k.frames.length<2)return;let C=k.frames.at(-1);g(!0),y(k.frames.slice(0,-1)),v(C?.openedBy)}function b(k){let C=l.get(),P=C?.frames.at(-1);if(!C||!P)return;k||g(!0);let q=C.frames.slice(0,-1);y(q),k&&(t.form.removeRow(rt(P.rowPath)),p()),v(P.openedBy)}function u(){b(!0)}function h(){let k=l.get(),C=k?.frames.at(-1);!k||!C||(C.origin==="new"?b(!0):k.frames.length>1?S():x(!0))}let w=Object.freeze({instanceId:r,definitionPath:Object.freeze([]),layout:n,setText(k,C){o||t.form.input(k,C)},touchText(k){o||(t.form.touch(k),a||p())},commitSelect(k,C){o||(t.form.input(k,C),t.form.touch(k),p())},commitMultiSelect(k,C){o||(t.form.input(k,[...C]),t.form.touch(k),p())},appendRow(k,C,P,q){if(o)return;let L=rt(k),be=t.form.appendRow(L);p(),C&&O(rt([...L,be]),P,q,"new")},removeRow(k){if(o)return;let C=rt(k),P=l.get(),q=P?.frames.find(L=>vn(L.rowPath,C));if(P&&q){let L=P.frames.slice(0,P.frames.indexOf(q));y(L)}t.form.removeRow(C),p(),v(q?.openedBy)},openRow(k,C,P){O(k,C,P,"existing")},renderNodes(k,C=[]){return qt(k,w,C)}}),m=ze({bindings:{text:{event:"blur"}}});c=m.render(gn(l,s,w,{close:()=>x(!0),back:S,add:()=>b(!1),cancel:()=>b(!0),remove:u,escape:h})),c.addEventListener("keydown",R),f=m.render(Jr({class:"umbika-form","data-umbika-instance":r,"data-umbika-theme":i,novalidate:!0,onsubmit:k=>{if(k.preventDefault(),o)return;g(!1);let C=t.form.validate();p(),j(s.get()),t.onSubmit?.({validation:C})}},qt(s,w),c)),e.appendChild(f);let d=f;function _(k){if(o||!no(k))return!1;let C=Se(s.get(),n,r,L=>io(L.path,k));if(!C||!("readOnly"in C.node)||C.node.readOnly)return!1;y(C.frames);let P=$(re(r,"control",C.node.path)),q=C.node.type==="multi-select"?P?.querySelector('input[type="checkbox"]:not([disabled])'):P;return q instanceof HTMLElement?(q.focus(),!0):!1}function j(k){let C=Se(k,n,r,ne=>ne.errors.length>0);if(!C)return;C.node.type==="object"&&(C=Se(k,n,r,ne=>"readOnly"in ne&&!ne.readOnly&&ne.errors.length>0)??C),y(C.frames);let{type:P,path:q}=C.node,L=$(P==="object"||P==="table"?V(r,P,q):re(r,"control",q)),be=C.node.type==="multi-select"&&!C.node.readOnly?L?.querySelector('input[type="checkbox"]:not([disabled])'):L;be instanceof HTMLElement&&be.focus()}function R(k){if(o||k.key!=="Tab"||!c?.open)return;let C=Array.from(c.querySelectorAll('button:not([disabled]), input:not([disabled]), select:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')).filter(L=>L instanceof HTMLElement&&L.getAttribute("aria-hidden")!=="true");if(C.length===0){k.preventDefault(),c.focus();return}let P=C[0],q=C.at(-1);if(!k.shiftKey&&document.activeElement===q||k.shiftKey&&document.activeElement===P){k.preventDefault();let L=k.shiftKey?q:P;L instanceof HTMLElement&&L.focus()}}return{root:d,refresh:p,focus:_,dispose(){o||(o=!0,l.set(null),c?.removeEventListener("keydown",R),Tt(d),c=void 0,f=void 0)}}}function ro(e){return Ft(e.rowPath,e.definitionPath,e.openedBy,e.origin)}function Ft(e,t,r,n){return Object.freeze({rowPath:Object.freeze([...e]),definitionPath:Object.freeze([...t]),openedBy:r,origin:n})}function rt(e){return[...e]}function Se(e,t,r,n,i=[],o=[]){for(let a of e){let s=[...i,a.id];if(n(a))return{node:a,frames:o};if(a.type==="object"){let l=Se(a.children,t,r,n,s,o);if(l)return l}else if(a.type==="table"){let l=me(t,s)?.mode==="table";for(let c of a.rows){let f=l?[...o,Ft(c.path,s,V(r,"edit-row",c.path),"existing")]:o,p=Se(c.children,t,r,n,s,f);if(p)return p}}}}function no(e){return Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string"&&t.length>0)}function vn(e,t){return e.length>=t.length&&t.every((r,n)=>e[n]===r)}function io(e,t){return e.length===t.length&&e.every((r,n)=>r===t[n])}function oo(e){return globalThis.CSS?.escape?globalThis.CSS.escape(e):e.replace(/[^A-Za-z0-9_-]/g,t=>`\\${t.codePointAt(0)?.toString(16)} `)}function ao(e,t){let r=so(e),n=lo(t),i=$r({source:n.source,...n.vars===void 0?{}:{vars:n.vars},...n.data===void 0?{}:{data:n.data}}),o=n.onSubmit,a=co(o,n.submitLabel),s=Mt(r,{form:i,...n.instanceId===void 0?{}:{instanceId:n.instanceId},...n.layout===void 0?{}:{layout:n.layout},...n.theme===void 0?{}:{theme:n.theme},...o===void 0?{}:{onSubmit:({validation:l})=>{l.valid&&o(i.getSubmissionData())}}});try{a&&s.root.append(a)}catch(l){throw En(a),s.dispose(),l}return{form:i,root:s.root,refresh:()=>s.refresh(),focus:l=>s.focus(l),dispose(){En(a),s.dispose()}}}function so(e){let t=typeof e=="string"?document.querySelector(e):e;if(!(t instanceof HTMLElement))throw new TypeError("target must resolve to an HTMLElement");return t}function lo(e){if(!Bt(e))throw new TypeError("options must be an object");if(typeof e.source!="string")throw new TypeError("options.source must be a string");if(e.vars!==void 0&&!Bt(e.vars))throw new TypeError("options.vars must be an object");if(e.data!==void 0&&!Bt(e.data))throw new TypeError("options.data must be an object");if(e.onSubmit!==void 0&&typeof e.onSubmit!="function")throw new TypeError("options.onSubmit must be a function");if(e.submitLabel!==void 0&&(typeof e.submitLabel!="string"||e.submitLabel.trim()===""))throw new TypeError("options.submitLabel must be a non-empty string");return e}function co(e,t){if(!e)return;let r=document.createElement("button");return r.type="submit",r.className="umbika-action umbika-standalone-submit",r.textContent=t??"Submit",r.addEventListener("mousedown",xn),r}function xn(e){e.preventDefault()}function En(e){e&&(e.removeEventListener("mousedown",xn),e.remove())}function Bt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}export{K as FormLanguageError,ao as mount};
@@ -0,0 +1,2 @@
1
+ export { computed, createCasconda, destroy, ref, render, rx, tags, watch, } from "../vendor/casconda.min.mjs";
2
+ //# sourceMappingURL=casconda.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"casconda.d.ts","sourceRoot":"","sources":["../src/casconda.js"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,cAAc,EACd,OAAO,EACP,GAAG,EACH,MAAM,EACN,EAAE,EACF,IAAI,EACJ,KAAK,GACN,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,165 @@
1
+ /**
2
+ * @typedef {object} MountWebFormOptions
3
+ * @property {import("@kayr/umbika-core").Form} form Replacement-engine form instance.
4
+ * @property {string} [instanceId] Host-supplied DOM identity prefix.
5
+ * @property {WebFormLayout} [layout] Renderer-owned repeat presentation.
6
+ * @property {string} [theme] Root-scoped theme name. Changing it requires remounting.
7
+ * @property {WebFormSubmitCallback} [onSubmit] Receives validation; persistence remains host-owned.
8
+ */
9
+ export type MountWebFormOptions = {
10
+ /**
11
+ * Replacement-engine form instance.
12
+ */
13
+ form: import("@kayr/umbika-core").Form;
14
+ /**
15
+ * Host-supplied DOM identity prefix.
16
+ */
17
+ instanceId?: string;
18
+ /**
19
+ * Renderer-owned repeat presentation.
20
+ */
21
+ layout?: WebFormLayout;
22
+ /**
23
+ * Root-scoped theme name. Changing it requires remounting.
24
+ */
25
+ theme?: string;
26
+ /**
27
+ * Receives validation; persistence remains host-owned.
28
+ */
29
+ onSubmit?: WebFormSubmitCallback;
30
+ };
31
+ export type WebFormSubmitEvent = {
32
+ validation: import("@kayr/umbika-core").ValidationResult;
33
+ };
34
+ export type WebFormSubmitCallback = (event: WebFormSubmitEvent) => void;
35
+ export type WebTableMode = "cards" | "table";
36
+ export type WebTableColumnAlignment = "start" | "center" | "end";
37
+ export type WebTableColumnLayout = {
38
+ path: import("@kayr/umbika-core").FieldPath;
39
+ label?: string;
40
+ align?: WebTableColumnAlignment;
41
+ };
42
+ export type WebTableLayout = {
43
+ path: import("@kayr/umbika-core").FieldPath;
44
+ mode: WebTableMode;
45
+ columns?: readonly WebTableColumnLayout[];
46
+ };
47
+ export type WebFormLayout = {
48
+ tables?: readonly WebTableLayout[];
49
+ };
50
+ export type OwnedWebTableColumnLayout = Readonly<{
51
+ key: string;
52
+ path: readonly string[];
53
+ label: string;
54
+ align: WebTableColumnAlignment;
55
+ }>;
56
+ export type OwnedWebTableLayout = Readonly<{
57
+ path: readonly string[];
58
+ mode: WebTableMode;
59
+ columns: readonly OwnedWebTableColumnLayout[] | undefined;
60
+ }>;
61
+ export type OwnedWebFormLayout = Readonly<{
62
+ tables: readonly OwnedWebTableLayout[];
63
+ }>;
64
+ export type WorkspaceFrame = Readonly<{
65
+ rowPath: import("@kayr/umbika-core").FieldPath;
66
+ definitionPath: readonly string[];
67
+ openedBy: string;
68
+ origin: "new" | "existing";
69
+ }>;
70
+ export type WorkspaceState = Readonly<{
71
+ frames: readonly WorkspaceFrame[];
72
+ }>;
73
+ export type MountedWebForm = {
74
+ root: HTMLFormElement;
75
+ refresh: () => void;
76
+ focus: (path: import("@kayr/umbika-core").FieldPath) => boolean;
77
+ dispose: () => void;
78
+ };
79
+ export type ReactiveSource<TValue> = Readonly<{
80
+ _listeners: unknown[];
81
+ _notify: (value: unknown) => void;
82
+ get: () => TValue;
83
+ notify: () => void;
84
+ subscribe: (listener: (value: any) => void) => () => void;
85
+ }>;
86
+ export type KeyedItemResource<TValue> = ReactiveSource<TValue | undefined>;
87
+ export type ResourceListSource<TValue> = ReactiveSource<readonly TValue[]>;
88
+ export type NodeRendererContext = Readonly<{
89
+ instanceId: string;
90
+ definitionPath: readonly string[];
91
+ layout: OwnedWebFormLayout;
92
+ renderNodes: (nodes: ResourceListSource<import("@kayr/umbika-core").ActiveFieldNode>, definitionPath?: readonly string[]) => unknown;
93
+ setText?: (path: import("@kayr/umbika-core").FieldPath, value: string) => void;
94
+ touchText?: (path: import("@kayr/umbika-core").FieldPath) => void;
95
+ commitSelect?: (path: import("@kayr/umbika-core").FieldPath, value: import("@kayr/umbika-core").SelectOption | undefined) => void;
96
+ commitMultiSelect?: (path: import("@kayr/umbika-core").FieldPath, value: readonly string[]) => void;
97
+ appendRow?: (tablePath: import("@kayr/umbika-core").FieldPath, openDetail: boolean, openerId: string, definitionPath: readonly string[]) => void;
98
+ removeRow?: (rowPath: import("@kayr/umbika-core").FieldPath) => void;
99
+ openRow?: (rowPath: import("@kayr/umbika-core").FieldPath, openerId: string, definitionPath: readonly string[]) => void;
100
+ }>;
101
+ /** @typedef {{validation: import("@kayr/umbika-core").ValidationResult}} WebFormSubmitEvent */
102
+ /** @typedef {(event: WebFormSubmitEvent) => void} WebFormSubmitCallback */
103
+ /** @typedef {"cards" | "table"} WebTableMode */
104
+ /** @typedef {"start" | "center" | "end"} WebTableColumnAlignment */
105
+ /**
106
+ * @typedef {object} WebTableColumnLayout
107
+ * @property {import("@kayr/umbika-core").FieldPath} path
108
+ * @property {string} [label]
109
+ * @property {WebTableColumnAlignment} [align]
110
+ */
111
+ /**
112
+ * @typedef {object} WebTableLayout
113
+ * @property {import("@kayr/umbika-core").FieldPath} path
114
+ * @property {WebTableMode} mode
115
+ * @property {readonly WebTableColumnLayout[]} [columns]
116
+ */
117
+ /** @typedef {{tables?: readonly WebTableLayout[]}} WebFormLayout */
118
+ /** @typedef {Readonly<{key: string, path: readonly string[], label: string, align: WebTableColumnAlignment}>} OwnedWebTableColumnLayout */
119
+ /** @typedef {Readonly<{path: readonly string[], mode: WebTableMode, columns: readonly OwnedWebTableColumnLayout[] | undefined}>} OwnedWebTableLayout */
120
+ /** @typedef {Readonly<{tables: readonly OwnedWebTableLayout[]}>} OwnedWebFormLayout */
121
+ /**
122
+ * @typedef {Readonly<{
123
+ * rowPath: import("@kayr/umbika-core").FieldPath;
124
+ * definitionPath: readonly string[];
125
+ * openedBy: string;
126
+ * origin: "new" | "existing";
127
+ * }>} WorkspaceFrame
128
+ */
129
+ /** @typedef {Readonly<{frames: readonly WorkspaceFrame[]}>} WorkspaceState */
130
+ /**
131
+ * @typedef {object} MountedWebForm
132
+ * @property {HTMLFormElement} root
133
+ * @property {() => void} refresh
134
+ * @property {(path: import("@kayr/umbika-core").FieldPath) => boolean} focus
135
+ * @property {() => void} dispose
136
+ */
137
+ /**
138
+ * @template TValue
139
+ * @typedef {Readonly<{
140
+ * _listeners: unknown[];
141
+ * _notify: (value: unknown) => void;
142
+ * get: () => TValue;
143
+ * notify: () => void;
144
+ * subscribe: (listener: (value: any) => void) => () => void;
145
+ * }>} ReactiveSource
146
+ */
147
+ /** @template TValue @typedef {ReactiveSource<TValue | undefined>} KeyedItemResource */
148
+ /** @template TValue @typedef {ReactiveSource<readonly TValue[]>} ResourceListSource */
149
+ /**
150
+ * @typedef {Readonly<{
151
+ * instanceId: string;
152
+ * definitionPath: readonly string[];
153
+ * layout: OwnedWebFormLayout;
154
+ * renderNodes: (nodes: ResourceListSource<import("@kayr/umbika-core").ActiveFieldNode>, definitionPath?: readonly string[]) => unknown;
155
+ * setText?: (path: import("@kayr/umbika-core").FieldPath, value: string) => void;
156
+ * touchText?: (path: import("@kayr/umbika-core").FieldPath) => void;
157
+ * commitSelect?: (path: import("@kayr/umbika-core").FieldPath, value: import("@kayr/umbika-core").SelectOption | undefined) => void;
158
+ * commitMultiSelect?: (path: import("@kayr/umbika-core").FieldPath, value: readonly string[]) => void;
159
+ * appendRow?: (tablePath: import("@kayr/umbika-core").FieldPath, openDetail: boolean, openerId: string, definitionPath: readonly string[]) => void;
160
+ * removeRow?: (rowPath: import("@kayr/umbika-core").FieldPath) => void;
161
+ * openRow?: (rowPath: import("@kayr/umbika-core").FieldPath, openerId: string, definitionPath: readonly string[]) => void;
162
+ * }>} NodeRendererContext
163
+ */
164
+ export {};
165
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../src/contracts.js"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AANA,YAAkB,mBAAmB,GACrC;;;;IAA6C,IAAI,EAAtC,OAAO,mBAAmB,EAAE,IAAI,CAC3C;;;;IAAoB,UAAU,AAA9B,CACA,EADW,MAAM,CACjB;;;;IAA2B,MAAM,AAAjC,CACA,EADW,aAAa,CACxB;;;;IAAoB,KAAK,AAAzB,CACA,EADW,MAAM,CACjB;;;;IAAmC,QAAQ,AAA3C,CACF,EADa,qBAAqB,CAClC;CAAA,CAAA;AAEG,YAAsE,kBAAkB,GAA9E;IAAC,UAAU,EAAE,OAAO,mBAAmB,EAAE,gBAAgB,CAAA;CAAC,CAAoB;AACxF,YAA+C,qBAAqB,GAA1D,CAAC,KAAK,EAAE,kBAAkB,KAAK,IAAI,CAAuB;AACpE,YAA6B,YAAY,GAA/B,OAAO,GAAG,OAAO,CAAc;AACzC,YAAsC,uBAAuB,GAAnD,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAyB;AAG9D,YAAkB,oBAAoB,GACtC;IAAkD,IAAI,EAA3C,OAAO,mBAAmB,EAAE,SAAS,CAChD;IAAoB,KAAK,AAAzB,CACA,EADW,MAAM,CACjB;IAAqC,KAAK,AAA1C,CAA2C,EAAhC,uBAAuB,CAAS;CAAA,CAAA;AAG3C,YAAkB,cAAc,GAChC;IAAkD,IAAI,EAA3C,OAAO,mBAAmB,EAAE,SAAS,CAChD;IAAyB,IAAI,EAAlB,YAAY,CACvB;IAA6C,OAAO,AAApD,CAAqD,EAA1C,SAAS,oBAAoB,EAAE,CAAW;CAAA,CAAA;AAEpD,YAAgD,aAAa,GAAnD;IAAC,MAAM,CAAC,EAAE,SAAS,cAAc,EAAE,CAAA;CAAC,CAAe;AAC7D,YAA2G,yBAAyB,GAA1H,QAAQ,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,uBAAuB,CAAA;CAAC,CAAC,CAA2B;AACpI,YAA8H,mBAAmB,GAAvI,QAAQ,CAAC;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,YAAY,CAAC;IAAC,OAAO,EAAE,SAAS,yBAAyB,EAAE,GAAG,SAAS,CAAA;CAAC,CAAC,CAAqB;AACjJ,YAA8D,kBAAkB,GAAtE,QAAQ,CAAC;IAAC,MAAM,EAAE,SAAS,mBAAmB,EAAE,CAAA;CAAC,CAAC,CAAoB;AAGjF,YAKI,cAAc,GALR,QAAQ,CAAC;IACjB,OAAO,EAAE,OAAO,mBAAmB,EAAE,SAAS,CAAC;IAC/C,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,GAAG,UAAU,CAAC;CAC5B,CAAC,CAAgB;AAEjB,YAAyD,cAAc,GAA7D,QAAQ,CAAC;IAAC,MAAM,EAAE,SAAS,cAAc,EAAE,CAAA;CAAC,CAAC,CAAgB;AAGxE,YAAkB,cAAc,GAChC;IAA4B,IAAI,EAArB,eAAe,CAC1B;IAAuB,OAAO,EAAnB,MAAM,IAAI,CACrB;IAAqE,KAAK,EAA/D,CAAC,IAAI,EAAE,OAAO,mBAAmB,EAAE,SAAS,KAAK,OAAO,CACnE;IAAuB,OAAO,EAAnB,MAAM,IAAI,CACvB;CAAA,CAAA;AAIE,YAMI,cAAc,CAPR,MAAM,IACN,QAAQ,CAAC;IACjB,UAAU,EAAE,OAAO,EAAE,CAAC;IACtB,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAClC,GAAG,EAAE,MAAM,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;CAC3D,CAAC,CAAgB;AAEA,YAA8C,iBAAiB,CAAtE,MAAM,IAAW,cAAc,CAAC,MAAM,GAAG,SAAS,CAAC,CAAmB;AAC/D,YAA6C,kBAAkB,CAAtE,MAAM,IAAW,cAAc,CAAC,SAAS,MAAM,EAAE,CAAC,CAAoB;AAGjF,YAYI,mBAAmB,GAZb,QAAQ,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,WAAW,EAAE,CAAC,KAAK,EAAE,kBAAkB,CAAC,OAAO,mBAAmB,EAAE,eAAe,CAAC,EAAE,cAAc,CAAC,EAAE,SAAS,MAAM,EAAE,KAAK,OAAO,CAAC;IACrI,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,mBAAmB,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/E,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,mBAAmB,EAAE,SAAS,KAAK,IAAI,CAAC;IAClE,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,mBAAmB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,mBAAmB,EAAE,YAAY,GAAG,SAAS,KAAK,IAAI,CAAC;IAClI,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,mBAAmB,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;IACpG,SAAS,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,mBAAmB,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;IACjJ,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,mBAAmB,EAAE,SAAS,KAAK,IAAI,CAAC;IACrE,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,mBAAmB,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,MAAM,EAAE,KAAK,IAAI,CAAC;CACzH,CAAC,CAAqB;AAlE1B,+FAA+F;AAC/F,2EAA2E;AAC3E,gDAAgD;AAChD,oEAAoE;AAEpE;;;;;GAKG;AACH;;;;;GAKG;AACH,oEAAoE;AACpE,2IAA2I;AAC3I,wJAAwJ;AACxJ,uFAAuF;AAEvF;;;;;;;GAOG;AACH,8EAA8E;AAE9E;;;;;;GAMG;AAEH;;;;;;;;;GASG;AACH,uFAAuF;AACvF,uFAAuF;AAEvF;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @param {string} instanceId
3
+ * @param {string} role
4
+ * @param {import("@kayr/umbika-core").FieldPath} path
5
+ */
6
+ export declare function _fieldDomId(instanceId: string, role: string, path: import("@kayr/umbika-core").FieldPath): string;
7
+ /**
8
+ * @param {string} instanceId
9
+ * @param {string} role
10
+ * @param {readonly string[]} path
11
+ */
12
+ export declare function _structuralDomId(instanceId: string, role: string, path: readonly string[]): string;
13
+ /** @param {{path: readonly string[]}} value */
14
+ export declare function _resourcePathKey(value: {
15
+ path: readonly string[];
16
+ }): string;
17
+ //# sourceMappingURL=dom-identity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dom-identity.d.ts","sourceRoot":"","sources":["../src/dom-identity.js"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAJ3B,MAI2B,EAAE,IAAI,EAHjC,MAGiC,EAAE,IAAI,EAFvC,OAAO,mBAAmB,EAAE,SAEW,UAIjD;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,UAAU,EAJhC,MAIgC,EAAE,IAAI,EAHtC,MAGsC,EAAE,IAAI,EAF5C,SAAS,MAAM,EAE6B,UAItD;AAED,+CAA+C;AAC/C,wBAAgB,gBAAgB,CAAC,KAAK,EAD1B;IAAC,IAAI,EAAE,SAAS,MAAM,EAAE,CAAA;CACE,UAErC"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @param {string} instanceId
3
+ * @param {import("@kayr/umbika-core").ActiveField} node
4
+ * @param {import("./contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>} resource
5
+ */
6
+ export declare function _fieldPresentation(instanceId: string, node: import("@kayr/umbika-core").ActiveField, resource: import("./contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>): {
7
+ control: string;
8
+ describedBy: string;
9
+ label: any[];
10
+ legend: any[];
11
+ descriptionId: string;
12
+ errors: any[];
13
+ };
14
+ /**
15
+ * @param {string} id
16
+ * @param {import("./contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>} resource
17
+ */
18
+ export declare function _renderErrors(id: string, resource: import("./contracts.js").KeyedItemResource<import("@kayr/umbika-core").ActiveFieldNode>): any[];
19
+ /**
20
+ * @param {string} id
21
+ * @param {string} guidance
22
+ */
23
+ export declare function _fieldDescription(id: string, guidance: string): any[];
24
+ /** @param {unknown} value */
25
+ export declare function _displayValue(value: unknown): string;
26
+ //# sourceMappingURL=field-presentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-presentation.d.ts","sourceRoot":"","sources":["../src/field-presentation.js"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAJlC,MAIkC,EAAE,IAAI,EAHxC,OAAO,mBAAmB,EAAE,WAGY,EAAE,QAAQ,EAFlD,OAAO,gBAAgB,EAAE,iBAAiB,CAAC,OAAO,mBAAmB,EAAE,eAAe,CAEpC;;;;;;;EA6B5D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAHrB,MAGqB,EAAE,QAAQ,EAF/B,OAAO,gBAAgB,EAAE,iBAAiB,CAAC,OAAO,mBAAmB,EAAE,eAAe,CAEvD,SAWzC;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAHzB,MAGyB,EAAE,QAAQ,EAFnC,MAEmC,SAE7C;AAED,6BAA6B;AAC7B,wBAAgB,aAAa,CAAC,KAAK,EADvB,OACuB,UAIlC"}
@@ -0,0 +1,16 @@
1
+ export { mountWebForm } from "./mount.js";
2
+ export type MountedWebForm = import("./contracts.js").MountedWebForm;
3
+ export type MountWebFormOptions = import("./contracts.js").MountWebFormOptions;
4
+ export type WebFormLayout = import("./contracts.js").WebFormLayout;
5
+ export type WebTableLayout = import("./contracts.js").WebTableLayout;
6
+ export type WebTableColumnLayout = import("./contracts.js").WebTableColumnLayout;
7
+ export type WebTableMode = import("./contracts.js").WebTableMode;
8
+ export type WebTableColumnAlignment = import("./contracts.js").WebTableColumnAlignment;
9
+ /** @typedef {import("./contracts.js").MountedWebForm} MountedWebForm */
10
+ /** @typedef {import("./contracts.js").MountWebFormOptions} MountWebFormOptions */
11
+ /** @typedef {import("./contracts.js").WebFormLayout} WebFormLayout */
12
+ /** @typedef {import("./contracts.js").WebTableLayout} WebTableLayout */
13
+ /** @typedef {import("./contracts.js").WebTableColumnLayout} WebTableColumnLayout */
14
+ /** @typedef {import("./contracts.js").WebTableMode} WebTableMode */
15
+ /** @typedef {import("./contracts.js").WebTableColumnAlignment} WebTableColumnAlignment */
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEtC,YAAmD,cAAc,GAAvD,OAAO,gBAAgB,EAAE,cAAc,CAAgB;AACjE,YAAwD,mBAAmB,GAAjE,OAAO,gBAAgB,EAAE,mBAAmB,CAAqB;AAC3E,YAAkD,aAAa,GAArD,OAAO,gBAAgB,EAAE,aAAa,CAAe;AAC/D,YAAmD,cAAc,GAAvD,OAAO,gBAAgB,EAAE,cAAc,CAAgB;AACjE,YAAyD,oBAAoB,GAAnE,OAAO,gBAAgB,EAAE,oBAAoB,CAAsB;AAC7E,YAAiD,YAAY,GAAnD,OAAO,gBAAgB,EAAE,YAAY,CAAc;AAC7D,YAA4D,uBAAuB,GAAzE,OAAO,gBAAgB,EAAE,uBAAuB,CAAyB;AANvF,wEAAwE;AACxE,kFAAkF;AAClF,sEAAsE;AACtE,wEAAwE;AACxE,oFAAoF;AACpF,oEAAoE;AACpE,0FAA0F"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copy and validate renderer-owned repeat presentation at the mount boundary.
3
+ *
4
+ * @param {unknown} layout
5
+ * @param {readonly import("@kayr/umbika-core").FormNode[]} schema
6
+ * @returns {import("./contracts.js").OwnedWebFormLayout}
7
+ */
8
+ export declare function _copyWebFormLayout(layout: unknown, schema: readonly import("@kayr/umbika-core").FormNode[]): import("./contracts.js").OwnedWebFormLayout;
9
+ /**
10
+ * Validate the mount-scoped theme token. Strings cross the ownership boundary
11
+ * by value, so the returned token cannot be changed through a caller alias.
12
+ *
13
+ * @param {unknown} theme
14
+ */
15
+ export declare function _copyWebFormTheme(theme: unknown): string;
16
+ /**
17
+ * @param {import("./contracts.js").OwnedWebFormLayout} layout
18
+ * @param {readonly string[]} definitionPath
19
+ */
20
+ export declare function _tableLayoutAt(layout: import("./contracts.js").OwnedWebFormLayout, definitionPath: readonly string[]): Readonly<{
21
+ path: readonly string[];
22
+ mode: import("./contracts.js").WebTableMode;
23
+ columns: readonly import("./contracts.js").OwnedWebTableColumnLayout[] | undefined;
24
+ }> | undefined;
25
+ //# sourceMappingURL=layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../src/layout.js"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAJ9B,OAI8B,EAAE,MAAM,EAHtC,SAAS,OAAO,mBAAmB,EAAE,QAAQ,EAGP,GAFpC,OAAO,gBAAgB,EAAE,kBAAkB,CAoCvD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAF5B,OAE4B,UAQtC;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAH1B,OAAO,gBAAgB,EAAE,kBAGC,EAAE,cAAc,EAF1C,SAAS,MAAM,EAE2B;;;;eAGpD"}