fig-tree-evaluator 3.0.0-preview.13 → 3.0.0-preview.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/authoring/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e,i as t,c as n,a as r,n as a,b as o,d as s,e as i,v as c,f as u,r as l,g as p,s as m,F as d,h as y,j as f}from"../chunks/engine.js";import{i as h,r as v,W as g,E as b,a as w,F as x,b as k}from"../chunks/shared.js";const j=e=>"demand"in e,O=(t,n)=>({...t,path:n.path,...void 0===t.fragment?{fragment:n.name,fragmentPath:e(t.path)}:{},order:[n.order,...t.order]}),$=(t,n)=>void 0===t.fragmentPath?{...t,path:n.path,fragmentPath:e(t.path)}:{...t,path:n.path},A=t=>{const{code:n,message:r,certainty:a,operator:o,parameter:s,fragment:i,fragmentPath:c}=t;return{path:e(t.path),code:n,message:r,certainty:a,...void 0!==o?{operator:o}:{},...void 0!==s?{parameter:s}:{},...void 0!==i?{fragment:i,fragmentPath:c}:{}}},N=({path:e,code:t,message:n,operator:r,parameter:a})=>({path:[...e],code:t,message:n,certainty:"always",...void 0!==r?{operator:r}:{},...void 0!==a?{parameter:a}:{}}),S=e=>{const t=new Map;for(const{finding:n}of[...e].sort((e,t)=>((e,t)=>{for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length})(e.order,t.order))){const e=JSON.stringify({...n,message:void 0,certainty:void 0}),r=t.get(e);void 0===r?t.set(e,n):"always"===n.certainty&&(r.certainty="always")}return[...t.values()]},M=e=>({order:e.order,finding:A(e)}),P=(t,n)=>({order:t.order,finding:{...A(t),coveredBy:e(n.path),...void 0!==n.fragmentPath?{coveredByFragmentPath:n.fragmentPath}:{},...n.givesNull?{givesNull:n.givesNull}:{}}}),F=[],E=[{type:"string"},{type:"number"},{type:"boolean"},{type:"null"},{type:"array"},{type:"object"},{type:"opaque"},{type:"nonFinite"}],z=e=>[{exact:void 0===e?null:e}],L=e=>e.length>0&&e.every(e=>"exact"in e)?e.map(e=>e.exact):void 0,q=e=>"exact"in e?null===e.exact:"null"===e.type,D=e=>{if(h(e))return e.literal.map(e=>({exact:e}));const t="string"==typeof e?[e]:e;return t.includes("any")?E:W(t.map(e=>[{type:e}]))},J=new WeakMap;let B=0;const I=e=>"object"==typeof e&&null!==e||"function"==typeof e?`=#${(e=>{let t=J.get(e);return void 0===t&&J.set(e,t=++B),t})(e)}`:`=${typeof e}:${String(e)}`,C=e=>{if("exact"in e)return I(e.exact);if("array"===e.type)return void 0!==e.items?`a[${e.items.map(T).join(";")}]`:`a${e.length??""}+${e.minLength??""}(${void 0===e.element?"*":T(e.element)})`;if("object"===e.type)return void 0===e.keys?"o":`o{${Object.keys(e.keys).sort().map(t=>`${JSON.stringify(t)}:${T(e.keys[t])}`).join(",")}}`;const{type:t,...n}=e;return`${t}${JSON.stringify(n)}`},T=e=>e.map(C).sort().join("|"),R=e=>{if(null===e)return{type:"null"};if(Array.isArray(e))return{type:"array"};switch(typeof e){case"string":return{type:"string"};case"number":return{type:Number.isInteger(e)?"integer":Number.isFinite(e)?"number":"nonFinite"};case"boolean":return{type:"boolean"};case"object":{const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t?{type:"object"}:{type:"opaque"}}default:return{type:"opaque"}}},W=e=>{const t=new Set,n=[];for(const r of e)for(const e of r){const r=C(e);t.has(r)||(t.add(r),n.push(e))}const r=n.filter(e=>"exact"in e).map(e=>e.exact);return r.length<=16?n:H(n.filter(e=>!("exact"in e)),Q(r))},H=(...e)=>W(e),G=e=>"number"==typeof e&&Number.isFinite(e),K=e=>Array.from(e).length,Q=e=>{const t=(e,t)=>{if(0===t.length)return F;const n=t.reduce((e,t)=>Math.min(e,t));return[U({type:e},n)]};return W([...[!0,!1].map(t=>ye(me(e.map(e=>G(e)&&Number.isInteger(e)===t?le(e):void 0)))),t("string",e.filter(e=>"string"==typeof e).map(K)),t("array",e.filter(Array.isArray).map(e=>e.length)),...e.filter(e=>!G(e)&&"string"!=typeof e&&!Array.isArray(e)).map(e=>[R(e)])])},U=(e,t)=>t?{...e,minLength:t}:e,V=e=>e.some(q),X=e=>e.length>0&&e.every(q),Y=e=>e.filter(e=>!q(e)),Z=e=>Oe(e.map(e=>{if("exact"in e){const{exact:n}=e;return(Array.isArray(n)?n:t(n)?Object.values(n):[]).includes(null)?"yes":"no"}return"array"===e.type?0!==e.length&&V(e.element??E)?"maybe":"no":"object"===e.type?"maybe":"no"})),_=(e,t)=>W(e.map(e=>{if("no"===Z([e]))return[e];const n="exact"in e?e.exact:void 0;if(1===t.length&&"exact"in t[0]&&"exact"in e){const e=t[0].exact,r=t=>null===t?e:t;if(Array.isArray(n))return z(n.map(r));const a={};for(const[e,t]of Object.entries(n))a[e]=r(t);return z(a)}if(!(Array.isArray(n)||"type"in e&&"array"===e.type))return[{type:"object"}];const{length:r,minLength:a}=e;return ne([Y(te([e])),t],Array.isArray(n)?{length:n.length}:{length:r,minLength:a})})),ee=e=>e.flatMap(e=>{const t=Z([e]);if("no"===t)return[e];if("yes"===t)return F;if(!("type"in e))return[e];if("array"!==e.type)return[e];const{items:n,...r}=e;if(void 0===n)return[{...r,element:Y(e.element??E)}];const a=n.map(Y);return a.some(e=>0===e.length)?F:re(a)}),te=e=>W(e.map(e=>"exact"in e?Array.isArray(e.exact)?W(Array.from(e.exact,e=>z(e))):F:"array"===e.type?0===e.length?F:e.element??E:F)),ne=(e,t={})=>[{type:"array",element:W(e),...t}],re=e=>[{type:"array",element:W(e),length:e.length,items:e}],ae=e=>H(e.map(e=>"exact"in e?R(e.exact):e)),oe=e=>je(e.map(e=>"exact"in e?"number"!=typeof e.exact||Number.isFinite(e.exact)?"no":"yes":"nonFinite"===e.type?"maybe":"no")),se=e=>[{type:"object",keys:e}],ie=(e,t)=>{if(0===t.length)return{value:e,found:"yes"};const[n,...r]=t;let a;const o=[],s=Oe(e.map(e=>{if("exact"in e){const n=v(e.exact,t);return n.found&&o.push(z(n.value)),n.found?"yes":"no"}const s=(e,t)=>{if("no"===t)return"no";const n=(e=>e===E?a??=ie(E,r):ie(e,r))(e);return o.push(n.value),"yes"===t?n.found:"no"===n.found?"no":"maybe"};if(n===g)return"array"!==e.type?"no":(o.push(0===r.length?[e]:[{type:"array"}]),"yes");switch(e.type){case"array":{const t="number"==typeof n?n:Number(n);if(!Number.isInteger(t)||t<0)return"number"==typeof n?"no":"maybe";const r=void 0!==e.length?t<e.length?"yes":"no":t<(e.minLength??0)?"yes":"maybe";return void 0!==e.items&&"yes"===r?s(e.items[t],"yes"):s(e.element??E,r)}case"object":return void 0===e.keys?s(E,"maybe"):Object.hasOwn(e.keys,String(n))?s(e.keys[String(n)],"yes"):"no";case"opaque":return s(E,"maybe");default:return"no"}}));return{value:W(o),found:0===e.length?"yes":s}},ce={min:0,max:0,integer:!0},ue={min:1,max:1,integer:!0},le=e=>({min:e,max:e,integer:Number.isInteger(e)}),pe=e=>"exact"in e?G(e.exact)?le(e.exact):void 0:"number"===e.type||"integer"===e.type?{min:e.min??-1/0,max:e.max??1/0,integer:"integer"===e.type}:void 0,me=e=>e.reduce((e,t)=>void 0===e||void 0===t?e??t:{min:Math.min(e.min,t.min),max:Math.max(e.max,t.max),integer:e.integer&&t.integer},void 0),de=e=>me(e.map(pe)),ye=e=>{if(void 0===e)return F;const t=e.integer?Math.ceil(e.min):e.min,n=e.integer?Math.floor(e.max):e.max;return t>n?F:[{type:e.integer?"integer":"number",...t>-1/0?{min:t}:{},...n<1/0?{max:n}:{}}]},fe=e=>e.filter(e=>"exact"in e?"number"!=typeof e.exact:!["number","integer","nonFinite"].includes(e.type)),he=e=>te(e).filter(e=>"no"!==oe([e])),ve=(e,t,n)=>W(e.map(e=>"exact"in e?Array.isArray(e.exact)?t(Array.from(e.exact,e=>z(e))):F:"array"!==e.type?F:void 0!==e.items?t(e.items):0===e.length?n(F,0):n(e.element??E,e.length??e.minLength??0))),ge=(e,t,n)=>e.reduce((e,t)=>{const r=de(t);return e&&r&&n(e,r)},t),be=(e,t)=>({min:e.min+t.min,max:e.max+t.max,integer:e.integer&&t.integer}),we=(e,t)=>0===e||0===t?0:e*t,xe=(e,t)=>{const n=[we(e.min,t.min),we(e.min,t.max),we(e.max,t.min),we(e.max,t.max)];return{min:Math.min(...n),max:Math.max(...n),integer:e.integer&&t.integer}},ke=(e,t)=>H(fe(te(e)),he(e),ve(e,e=>{const n=e.map(de);if(e.some(e=>"no"!==oe(e)))return ye(me(n));if(0===n.length||n.includes(void 0))return F;const r="min"===t?Math.min:Math.max;return ye({min:n.map(e=>e.min).reduce((e,t)=>r(e,t)),max:n.map(e=>e.max).reduce((e,t)=>r(e,t)),integer:n.every(e=>e.integer)})},e=>ye(de(e)))),je=e=>e.includes("yes")?"yes":e.includes("maybe")?"maybe":"no",Oe=e=>e.every(e=>"yes"===e)?"yes":e.every(e=>"no"===e)?"no":"maybe",$e=(e,t)=>"no"===e||"no"===t?"no":"yes"===e&&"yes"===t?"yes":"maybe",Ae=(e,t)=>{if("exact"in e)return Ne([e.exact],t);if("object"!==e.type)return"no";if(void 0===e.keys)return"maybe";const n=e.keys;return Oe(Object.entries(t).map(([e,t])=>{if(!Object.hasOwn(n,e))return!1===t.required?"yes":"no";const r=void 0===t.type?"yes":Se(n[e],t.type);return void 0===t.constraints?r:$e(r,Se(n[e],"any",t.constraints))}))},Ne=(e,t)=>r(e,{elementShape:t},!1).ok?"yes":"no",Se=(e,t,a,o=!1)=>Oe(e.map(e=>{if("exact"in e){const s=e.exact;return n(s,t).ok&&(null===s||void 0===a||r(s,a,o).ok)?"yes":"no"}const s=((e,t)=>{if(h(t)){const n=t=>{const n=pe(e);return void 0!==n?"number"==typeof t&&(!n.integer||Number.isInteger(t))&&t>=n.min&&t<=n.max:"string"===e.type?"string"==typeof t&&K(t)>=(e.minLength??0):typeof t===e.type};return t.literal.some(n)?"maybe":"no"}const n="string"==typeof t?[t]:t;if(n.includes("any"))return"yes";switch(e.type){case"number":return n.includes("number")?"yes":n.includes("integer")?"maybe":"no";case"integer":return n.includes("integer")||n.includes("number")?"yes":"no";case"opaque":return n.includes("object")?"maybe":"no";case"nonFinite":return n.includes("number")?"yes":"no";default:return n.includes(e.type)?"yes":"no"}})(e,t);return"no"===s||void 0===a||"null"===e.type?s:$e(s,((e,t,n)=>{if(0===Object.keys(t).filter(e=>void 0!==t[e]).length)return"yes";if("array"!==e.type)return"no";let r="yes";void 0!==t.length&&(r=$e(r,void 0===e.length?"maybe":e.length===t.length?"yes":"no"));const a=0===e.length?F:e.element??E,o=n?Y(a):a;return void 0!==t.homogeneous&&(r=$e(r,0===o.length||t.homogeneous.some(e=>"yes"===Se(o,e))?"yes":"maybe")),void 0!==t.elementShape&&(r=$e(r,o.every(e=>"yes"===Ae(e,t.elementShape))?"yes":"maybe")),r})(e,a,o))})),Me=(e,t)=>"yes"===Se(e,t)?e:W(e.map(e=>"no"===Se([e],t)?F:"exact"in e?[e]:h(t)?t.literal.filter(t=>"no"!==Se([e],{literal:[t]})).map(e=>({exact:e})):"number"===e.type?ye({...pe(e),integer:!0}):[e])),Pe=e=>"string"==typeof e?e:Array.isArray(e)?e.join(" | "):`one of ${e.literal.map(e=>JSON.stringify(e)).join(", ")}`,Fe=(e,t,n)=>{const r=e.entry.hostDefaults;return void 0!==r&&Object.hasOwn(r,t)?z(r[t]):"default"in n?"symbol"==typeof n.default?E:z(n.default):void 0},Ee=(e,t)=>"lazyEntries"===e.evaluation?"entries"===t.kind:"elements"===t.kind,ze=(e,t)=>{const n=e.nullPolicy;if("string"==typeof n)return new Set([n]);const r=t[n.selector]?.known??F,a=r.every(e=>"exact"in e)?n.table.filter(e=>r.some(t=>"exact"in t&&t.exact===e.value)):n.table;return new Set(a.map(e=>e.policy))},Le=(e,t)=>{const{definition:n}=e.entry,{entries:r,whole:s}=n.resolution,i={},c=new Set,u=[],l={},p=new Set,m={},d=new Set;let y,f="no";const h=(t,n,r,a)=>{const o=Se(r,n.type,n.constraints,void 0!==n.elementNullPolicy);if("yes"===o)return;const s={path:e.path,code:"type-check",message:`${e.name} – parameter '${t}': may receive something other than ${Pe(n.type)}${void 0!==n.constraints?", as constrained":""}`,certainty:"no"===o&&a?"always":"may",operator:e.name,parameter:t,order:[e.order]};u.push(s),"no"===o&&a&&(y??=s)};for(const[n,a]of r){const r=e.params[n];switch(a.evaluation){case"eager":void 0!==r&&(l[n]={known:t[n],absent:!1});break;case"structural":"constant"===r?.kind&&(l[n]={known:z(r.value),absent:!1});break;case"lazy":if(void 0!==a.replacesNullAt){const o=void 0!==r?t[n]:Fe(e,n,a);if(void 0!==o)for(const e of a.replacesNullAt)m[e]={name:n,known:o}}else void 0!==r&&(p.add(n),h(n,a,t[n],!1),i[n]=Me(t[n],a.type));break;case"lazyElements":case"lazyEntries":case"race":if(void 0===r)break;Ee(a,r)?(p.add(n),i[n]=t[n]):l[n]={known:t[n],absent:!1}}}for(const[t,n]of s){if(p.has(t))continue;const r=l[t]??{known:F,absent:!0},o=a(n)&&V(r.known);if(!r.absent&&!o)continue;const s=Fe(e,t,n),i=o?Y(r.known):r.known;l[t]={known:void 0===s?i:H(i,s),absent:void 0===s}}for(const[e,t]of s){if(p.has(e))continue;let n=l[e]?.known??F;if(0===n.length)continue;l[e].absent&&c.add(e);const r=m[e];if(void 0!==r){(void 0!==t.elementNullPolicy?"no"!==Z(n):V(n))&&(d.add(r.name),n=void 0!==t.elementNullPolicy?_(n,r.known):H(Y(n),r.known))}const a="eager"!==t.evaluation&&"structural"!==t.evaluation;if(V(n)&&o(t.type)&&!a){const e=ze(t,l);if(e.has("propagate")){const t=1===e.size&&X(n);if(f=t?"yes":"maybe",t){y??="null";break}1===e.size&&(n=Y(n))}}if("propagate"===t.elementNullPolicy){const e=Z(n);if("no"!==e){if(f="yes"===e?"yes":"maybe","yes"===e){y??="null";break}n=ee(n)}}h(e,t,n,!0),i[e]=Je(t,n)}if("no"!==f)for(const e of u)"always"===e.certainty&&(e.certainty="may");return{received:i,absent:c,failures:u,propagates:f,consulted:d,...y?{ends:y}:{}}},qe=e=>{const t="string"==typeof e?[e]:Array.isArray(e)?e:[];return t.length>0&&t.every(e=>"array"===e||"object"===e)},De=(e,n)=>{if(qe(n)){if(Array.isArray(e))return e.map(s);if(t(e)){const t={};for(const[n,r]of Object.entries(e))t[n]=s(r);return t}}return s(e)},Je=(e,t)=>{const n=Me(t,e.type);return e.truthiness?n.length>0&&n.every(e=>"exact"in e)?W(n.map(t=>z(De(t.exact,e.type)))):qe(e.type)?E:D("boolean"):n},Be=(e,t)=>{const n=a(e)&&V(t),r=n?Y(t):t;let o=Se(r,e.type,e.constraints);"yes"===o&&void 0!==e.constraints&&V(r)&&(o="maybe");const s=n?z(e.default??null):F;return{known:H(Me(r,e.type),s),answer:o}},Ie=(e,t,n,r)=>{if("yes"!==Se(r,n.type,n.constraints))return{path:e.path,code:"type-check",message:`${e.name} – parameter '${t}': an element's result may be other than ${Pe(n.type)}`,certainty:"may",operator:e.name,parameter:t,order:[e.order]}},Ce="non-finite-result",Te="empty-aggregate",Re="operator-failure",We={code:Ce,overflow:!0},He=e=>({code:"type-check",parameter:"values",when:{expect:e,values:{some:{not:{type:e}}}}}),Ge={plus:[{code:Te,parameter:"values",when:{values:{empty:!0},expect:{supplied:!1}}},He("number"),He("string"),He("array"),He("object"),We],subtract:[We],multiply:[We],divide:[{code:Ce,parameter:"by",when:{by:0}},We],modulo:[{code:Ce,parameter:"mod",when:{mod:0}},We],power:[{code:Ce,parameter:"base",when:{base:0,exponent:{below:0}}},{code:Ce,parameter:"base",may:!0,when:{base:{below:0},exponent:{not:{type:"integer"}}}},{code:Ce,parameter:"exponent",may:!0,when:{exponent:{not:{below:100}}}},We],round:[{code:Ce,parameter:"decimals",may:!0,when:{decimals:{not:{below:300}}}},We],min:[{code:Te,parameter:"values",when:{values:{empty:!0}}}],max:[{code:Te,parameter:"values",when:{values:{empty:!0}}}],match:[{code:Re,may:!0,when:{default:{supplied:!1}}}],regex:[{code:Re,parameter:"flags",when:{flags:{invalid:!0}}},{code:Re,parameter:"pattern",when:{pattern:{invalid:!0}}}],get:[{code:Re,parameter:"path",when:{path:{invalid:!0}}},{code:"missing-data-path",may:!0,options:{strictDataPaths:!0},when:{default:{supplied:!1}}}],convert:[{code:Re,when:{to:"number",value:{type:["array","object"]}}},{code:Re,may:!0,when:{to:"number",value:{type:"string"}}},{code:Ce,may:!0,when:{to:"number",value:{type:"string"}}},{code:Re,when:{to:"string",value:{type:["array","object"]}}}]};let Ke;const Qe=e=>{const t=e.analysis;return void 0!==t?t.external?"external":t.failures??[]:(Ke??=new Map(i.map(e=>[e,Ge[e.name]??[]])),Ke.get(e)??"external")},Ue=e=>"yes"===e?"no":"no"===e?"yes":"maybe",Ve=(e,n)=>{if(null===e||"object"!=typeof e){if("exact"in n)return n.exact===e?"yes":"no";return"no"===Se([n],null===e?"null":{literal:[e]})?"no":"maybe"}if("type"in e)return Se([n],e.type);if("not"in e)return Ue(Ve(e.not,n));if("below"in e)return"exact"in n?"number"==typeof n.exact&&n.exact<e.below?"yes":"no":"number"===n.type||"integer"===n.type?(n.max??1/0)<e.below?"yes":(n.min??-1/0)>=e.below?"no":"maybe":"nonFinite"===n.type?"maybe":"no";if("empty"in e){if("exact"in n){const{exact:e}=n;return"string"==typeof e||Array.isArray(e)?0===e.length?"yes":"no":t(e)&&0===Object.keys(e).length?"yes":"no"}switch(n.type){case"array":return void 0!==n.length?0===n.length?"yes":"no":n.minLength?"no":"maybe";case"object":return void 0===n.keys?"maybe":0===Object.keys(n.keys).length?"yes":"no";case"string":return n.minLength?"no":"maybe";default:return"no"}}if("some"in e){if("exact"in n){const{exact:r}=n,a=Array.isArray(r)?Array.from(r):t(r)?Object.values(r):[];return je(a.map(t=>Ve(e.some,{exact:t??null})))}if("array"===n.type){if(0===n.length)return"no";const t=Xe(e.some,n.element??E);return"yes"!==t||void 0===n.length&&!n.minLength?"no"===t?"no":"maybe":"yes"}return"object"===n.type?void 0===n.keys?"maybe":je(Object.values(n.keys).map(t=>"no"===Xe(e.some,t)?"no":"maybe")):"no"}return"maybe"},Xe=(e,t)=>0===t.length?"no":Oe(t.map(t=>Ve(e,t))),Ye=e=>void 0!==e&&1===e.length&&"exact"in e[0]?{value:e[0].exact}:void 0,Ze=(e,t,n,r)=>{const a=r.received[t],o=void 0===a?"no":r.absent.has(t)?"maybe":"yes";return null!==n&&"object"==typeof n&&"supplied"in n?n.supplied?o:Ue(o):"no"===o?"no":null!==n&&"object"==typeof n&&"invalid"in n?((e,t,n)=>{const{validate:r}=e.entry.definition;if(void 0===r)return"no";if(void 0===Ye(n.received[t]))return"maybe";const a={};for(const[e,t]of Object.entries(n.received)){const r=Ye(t);void 0===r||n.absent.has(e)||(a[e]=r.value)}return r(a,c).some(e=>"error"===e.severity&&e.parameter===t)?"yes":"no"})(e,t,r):Xe(n,a)},_e=e=>null===e||"object"!=typeof e?JSON.stringify(e):"type"in e?"string"==typeof e.type?`a ${e.type}`:`of type ${JSON.stringify(e.type)}`:"not"in e?`not ${_e(e.not)}`:"below"in e?`below ${e.below}`:"empty"in e?"empty":"supplied"in e?e.supplied?"supplied":"not supplied":"invalid"in e?"refused by its validation":`with some element ${_e(e.some)}`,et=(e,t)=>{const n=Object.entries(t.when??{}).map(([e,t])=>null!==t&&"object"==typeof t&&"some"in t?`some element of '${e}' is ${_e(t.some)}`:`'${e}' is ${_e(t)}`),r=n.length>0?`when ${n.join(" and ")}`:t.overflow?"on extreme numbers":"whatever its inputs";return`${e} – ${t.code} ${t.may?"possible ":""}${r}`},tt=(e,t,n,r)=>{if(t.overflow&&!r.strictNumbers)return"no";for(const[e,n]of Object.entries(t.options??{}))if((r.evaluation[e]??!1)!==n)return"no";const a=Object.entries(t.when??{}).map(([t,r])=>Ze(e,t,r,n));return a.includes("no")?"no":a.every(e=>"yes"===e)?"yes":"maybe"},nt={if:{oneOf:[{param:"then"},{param:"else"}]},match:{oneOf:[{param:"branches"},{param:"default"}]},firstOf:{firstNonNull:"values"},find:{oneOf:[{elementOf:"input"},{param:"noMatchDefault"}]},plus:{oneOf:[{sum:"values"},{typeNamedBy:"expect"}]},subtract:{difference:["value","minus"]},multiply:{product:"values"},abs:{abs:"value"},min:{min:"values"},max:{max:"values"},length:{type:"integer",min:0},filter:{arrayOf:{elementOf:"input"}},map:{arrayOf:{param:"each"}},split:{byParam:"delimiter",cases:{"":{arrayOf:"string"}},otherwise:{arrayOf:"string",minLength:1}},convert:{typeNamedBy:"to"},regex:{byParam:"mode",cases:{test:"boolean",extract:{oneOf:["string",{param:"noMatchDefault"}]},match:{arrayOf:"string"}}}};let rt;const at=/*#__PURE__*/new Set(["lazyElements","lazyEntries","race"]),ot=(e,n)=>{const{inputs:r}=n,a=e=>r.received[e]??F;if((e=>"string"==typeof e||Array.isArray(e)||"literal"in e)(e))return D(e);if("type"in e)return(e=>{const{type:t,min:n=-1/0,max:r=1/0}=e;return"number"===t||"integer"===t?ye({min:n,max:r,integer:"integer"===t}):[U({type:t},e.minLength)]})(e);if("sum"in e)return o=a(e.sum),H(ae(fe(te(o))),he(o),ve(o,e=>ye(ge(e,ce,be)),(e,t)=>{const n=de(e);if(void 0===n)return 0===t?ye(ce):F;const r=t>0;return ye({min:n.min>=0?r?n.min:0:-1/0,max:n.max<=0?r?n.max:0:1/0,integer:n.integer})}));var o;if("product"in e)return(e=>H(he(e),ve(e,e=>ye(ge(e,ue,xe)),(e,t)=>{const n=de(e);if(void 0===n)return 0===t?ye(ue):F;const r=n.min>=-1&&n.max<=1;return ye({min:n.min>=1?1:n.min>=0?0:r?-1:-1/0,max:r?1:1/0,integer:n.integer})})))(a(e.product));if("difference"in e)return((e,t)=>{const n=de(e),r=de(t);return ye(n&&r&&{min:n.min-r.max,max:n.max-r.min,integer:n.integer&&r.integer})})(...e.difference.map(a));if("abs"in e)return(e=>{const t=de(e);if(void 0===t)return F;const{min:n,max:r}=t;return ye(n>=0?t:r<=0?{...t,min:-r,max:-n}:{...t,min:0,max:Math.max(-n,r)})})(a(e.abs));if("min"in e)return ke(a(e.min),"min");if("max"in e)return ke(a(e.max),"max");if("param"in e){const r=e.param;if(Object.hasOwn(n.elements,r))return n.elements[r];const o=a(r),s=n.definition.parameters[r]?.evaluation??"eager";return at.has(s)?H(te(o),(e=>W(e.map(e=>"exact"in e?t(e.exact)?W(Object.values(e.exact).map(e=>z(e))):F:"object"!==e.type?F:void 0===e.keys?E:W(Object.values(e.keys)))))(o)):o}if("elementOf"in e)return te(a(e.elementOf));if("kindOf"in e)return ae(te(a(e.kindOf)));if("arrayOf"in e){const{arrayOf:t,minLength:r}=e,a="object"==typeof t&&"param"in t?n.items[t.param]:void 0;return void 0!==a?re(a):ne([ot(t,n)],r?{minLength:r}:{})}if("oneOf"in e)return W(e.oneOf.map(e=>ot(e,n)));if("typeNamedBy"in e){const t=e.typeNamedBy,a=r.received[t];if(void 0===a)return F;const o=L(a)??((e,t)=>{const n=e.definition.parameters[t]?.type;return"object"==typeof n&&"literal"in n?[...n.literal]:void 0})(n,t);return void 0===o?E:W(o.filter(e=>"string"==typeof e).map(e=>D(e)))}if("byParam"in e){const{cases:t,otherwise:a}=e,o=r.received[e.byParam],s=void 0===o?void 0:L(o),i=s?.map(e=>"string"==typeof e&&Object.hasOwn(t,e)?t[e]:a)??[...Object.values(t),a];return W(i.map(e=>void 0===e?F:ot(e,n)))}return(e=>W(e.map(e=>{const t="exact"in e?Array.isArray(e.exact)?Array.from(e.exact,e=>z(e)):void 0:"array"===e.type?e.items:void 0;if(void 0===t)return H(Y(te([e])),z(null));const n=[];for(const e of t)if(n.push(Y(e)),!V(e))return W(n);return W([...n,z(null)])})))(a(e.firstNonNull))},st=[{type:"nonFinite"}],it=(e,t,n,r,a={})=>{if("yes"===t.propagates)return{output:z(null)};const{definition:o}=e.entry,s=(e=>void 0!==e.analysis?e.analysis.output:(rt??=new Map(i.filter(e=>Object.hasOwn(nt,e.name)).map(e=>[e,nt[e.name]])),rt.get(e)))(o);let c=void 0!==s?ot(s,{definition:o,inputs:t,elements:n,items:a}):D(o.returns);return Object.values(t.received).some(e=>"no"!==oe(e))&&"no"!==Se(c,"number")&&(c=H(c,st)),"maybe"===t.propagates&&(c=H(c,z(null))),ct(e,c,r,"no"===t.propagates)},ct=(e,t,n,r)=>{const a=oe(t),o=n?a:oe(ut(t)),s=t.filter(e=>"exact"in e?"number"!=typeof e.exact||Number.isFinite(e.exact):"nonFinite"!==e.type);return"no"===o?{output:s}:{output:s,boundary:{path:e.path,code:"non-finite-result",message:`${e.name} – non-finite-result possible: a NaN or infinite number may reach its result`,certainty:0===s.length&&r?"always":"may",operator:e.name,order:[e.order]}}},ut=e=>e.filter(e=>!("type"in e&&"nonFinite"===e.type)),lt={unknown:!0},pt={fails:!0},mt=async(e,t,n,r,a=new Set)=>{if(a.has(e.entry.definition))return;const{parameters:o}=e.entry.definition,s=new Set(n.map(e=>e.param)),i=[];for(const[e,n]of Object.entries(t)){if(s.has(e))continue;const t=L(n);if(void 0===t)return;i.push({name:e,outcomes:t.map(e=>({value:e}))})}const c=n.map(e=>{const t=o[e.param],n=((e,t)=>{const{verdict:n,output:r}=e.result,a=void 0!==t.replacesNullAt;if("always"===n)return[a?lt:pt];const o=L(r);if(void 0===o)return[lt];const s=o.map(e=>({value:e}));return"no"===n?s:a?[lt]:[...s,pt]})(e,t);return{child:e,outcomes:"perElement"===t.evaluation&&void 0===e.at&&n.length>1?[lt]:n}}),u=()=>[...i,...c].reduce((e,{outcomes:t})=>e*t.length,1);if(u()>16)for(const e of c)e.outcomes.length>1&&(e.outcomes=[lt]);const l=u();if(l>16)return;const p=new Set,m=new Set,d=[];for(let n=0;n<l;n++){let o=n;const s=e=>{const t=e[o%e.length];return o=Math.floor(o/e.length),t},u={};for(const{name:e,outcomes:t}of i)u[e]=s(t).value;const l=new Map(c.map(({child:e,outcomes:t})=>[e,s(t)])),y=await bt(e,t,u,l,r,p,m,a);if(void 0===y)return;d.push(y)}const y=[],f=new Map,h=new Set,v=new Set;let g=0;for(const e of d)if("value"in e)y.push(z(e.value));else if("passed"in e){const{passed:t}=e;v.add(t),h.add(t),y.push(dt(t,o[t.param]))}else if(g++,"escaped"in e)h.add(e.escaped);else{const t=`${e.failure.code}|${e.failure.parameter??""}`,n=f.get(t)??{failure:e.failure,count:0};n.count++,f.set(t,n)}const b=[...f.values()].map(({failure:e,count:t})=>({...e,certainty:t===d.length?"always":"may"}));return{output:W(y),failures:b,reached:p,awaited:m,escaped:h,passed:v,fails:g===d.length}},dt=(e,t)=>void 0===e.at||"perElement"===t.evaluation?Je(t,e.result.output):t.truthiness?D("boolean"):e.result.output,yt=Symbol("stopped"),ft=new Promise(()=>{}),ht=e=>{const t=Promise.reject(e);return t.catch(()=>{}),t},vt={memo:(e,t)=>t()},gt={note:()=>{}},bt=async(e,t,n,r,a,o,i,c)=>{const l=e=>{o.add(e),i.add(e)},{definition:p}=e.entry,{parameters:m}=p,d={...t};for(const[e,t]of Object.entries(n))d[e]=z(t);for(const[e,t]of r)void 0!==m[e.param].replacesNullAt&&"value"in t&&(d[e.param]=z(t.value));const y=Le(e,d);for(const[e,t]of r){if("race"===m[e.param].evaluation&&o.add(e),y.consulted.has(e.param)){if(!("value"in t))return;l(e)}}const f=Qe(p),h=(t,n,r)=>{const o=r??("external"===f?void 0:f.find(n=>n.code===t&&void 0!==n.parameter&&"no"!==tt(e,n,y,a))?.parameter);return{failure:{path:e.path,code:t,message:n,certainty:"always",operator:e.name,...void 0!==o?{parameter:o}:{},order:[e.order]}}};if("null"===y.ends)return{value:null};if(void 0!==y.ends)return{failure:y.ends};const v=new Map,g=new Set,k=new Map,j=new Map;let O=!1,$=()=>{};const A=new Promise(e=>{$=()=>e(yt)});let N=!1;const S=()=>{N?$():O=!0},M=e=>{const t=new x({code:b.operatorFailure,message:"",path:[]});return k.set(t,e),t},P=(t,n)=>r=>{const a=void 0!==n.elementNullPolicy;if("yes"!==Se(z(r),n.type,n.constraints,a)){const n=new x({code:b.typeCheck,message:`${e.name} – parameter '${t}': fails its type check`,path:[]});throw j.set(n,t),n}return n.truthiness?De(r,n.type):r},F=e=>t=>e.truthiness?s(t):t,E=(e,t)=>{void 0!==e&&l(e);const n=void 0===e?lt:r.get(e);if("unknown"in n){const t=new Promise(()=>{});return void 0!==e&&v.set(t,e),S(),t}if("fails"in n)return ht(M(e));try{return Promise.resolve(t(n.value))}catch(e){return ht(e)}},q=e=>{let t;const n={evaluate:()=>t??=e()};return g.add(n),n},D=(e,t)=>{const n=({index:e,child:n,value:a})=>{if(void 0===n)return{index:e,ok:!0,value:t(a)};l(n);const o=r.get(n);if("fails"in o)return{index:e,ok:!1,error:M(n)};try{return{index:e,ok:!0,value:t(o.value)}}catch(t){return{index:e,ok:!1,error:t}}},a=e=>void 0!==e.child&&"unknown"in r.get(e.child),o={length:e.length,async*[Symbol.asyncIterator](){for(const t of e)a(t)||(yield n(t));e.some(a)&&(S(),await ft)}};return g.add(o),o},J=(e,t)=>{const n=F(t);switch(t.evaluation){case"lazyElements":return e.map(e=>q(()=>Promise.resolve(n(e))));case"race":return D(e.map((e,t)=>({index:t,value:e})),n);case"lazyEntries":{const t={};for(const[r,a]of Object.entries(e))t[r]=q(()=>Promise.resolve(n(a)));return t}case"lazy":return q(()=>Promise.resolve(e));default:return e}},B=new Map;for(const e of r.keys())B.set(e.param,[...B.get(e.param)??[],e]);const I={};for(const[e,t]of Object.entries(m)){if("perElement"===t.evaluation||void 0!==t.replacesNullAt)continue;const n=B.get(e);if(void 0!==n){const r=F(t);if("lazy"===t.evaluation)I[e]=q(()=>E(n[0],P(e,t)));else if("race"===t.evaluation)I[e]=D(n.map((e,t)=>({index:t,child:e})),r);else if("lazyElements"===t.evaluation)I[e]=n.map(e=>q(()=>E(e,r)));else{const t={};for(const e of n)t[String(e.at)]=q(()=>E(e,r));I[e]=t}continue}const r=y.received[e];if(void 0===r)continue;const a=L(r);if(void 0===a||1!==a.length)return;I[e]=J(a[0],t)}for(const[t,n]of p.resolution.perElement){if(void 0===e.params[t]||void 0===n.over)continue;const r=B.get(t)??[],a=I[n.over],s=Array.isArray(a)?a:[],i=1===r.length&&void 0===r[0].at;if(!i&&r.length!==s.length)return;const c=e=>r[i?e>=0&&e<s.length?0:-1:e],u=P(t,n),l=new Map,p={evaluate:e=>{let t=l.get(e);return void 0===t&&l.set(e,t=E(c(e),u)),t},settle:()=>{const e=s.map((e,t)=>({index:t,child:c(t)}));for(const{child:t}of e)o.add(t);return D(e,u)}};g.add(p),I[t]=p}const C={options:a.evaluation,get signal(){return(new AbortController).signal},cache:vt,trace:gt},T=t=>{const n=k.get(t);if(void 0!==n)return{escaped:n};if(w(t))return h(t.code,t.message,j.get(t));const r=`${e.name} – ${t instanceof Error?t.message:String(t)}`;return h((u(t)?t.code:void 0)??b.operatorFailure,r)};let R;try{R=p.evaluate(I,C)}catch(e){return T(e)}if(W=R,"function"==typeof W?.then){const e=v.get(R);if(void 0!==e)return{passed:e};if(O)return;N=!0;const t=setTimeout(()=>{c.add(p),$()},100),n=await Promise.race([Promise.resolve(R).then(e=>({value:e}),e=>({error:e})),A]);if(clearTimeout(t),n===yt)return;if("error"in n)return T(n.error);R=n.value}var W;return void 0===R?{value:null}:"number"!=typeof R||Number.isFinite(R)?g.has(R)?h(b.escapedHandle,`${e.name} – returned a lazy handle instead of evaluating it`):{value:R}:h(b.nonFiniteResult,`${e.name} – produced a non-finite number (${String(R)})`)},wt=(e,t)=>void 0===t?e.scope:{vars:t,at:e,known:new Map},xt={verdict:"no",escapes:[],output:F},kt={result:xt,covered:[]},jt=[{type:"integer",min:0}],Ot=z(null),$t=[{type:"object"}],At=se(Object.fromEntries(Object.entries(k).map(([e,t])=>[e,D(t)]))),Nt=e=>{if(0===e.length)return $t;const{value:t,found:n}=ie(At,e);return"yes"===n?t:H(t,Ot)},St=({value:e,reads:t=[]},n=0)=>{if(0===t.length)return z(e);const r=t.find(({at:e})=>e.length===n);if(void 0!==r)return Nt(r.segments);const a=e,o=e=>St({value:a[e],reads:t.filter(({at:t})=>t[n]===e)},n+1);return Array.isArray(e)?re(e.map((e,t)=>o(t))):se(Object.fromEntries(Object.keys(a).map(e=>[e,o(e)])))},Mt=(e,t)=>{for(const n of t)e.push(n)},Pt=(e,t,n)=>{const r=[...e];for(const e of t)Mt(r,e.result.escapes);const a=t.some(e=>e.result.waits);return t.some(e=>e.eager&&"always"===e.result.verdict)||e.some(e=>!j(e)&&"always"===e.certainty)?{verdict:"always",escapes:r,output:F,waits:a}:{verdict:r.length>0?"may":"no",escapes:r,output:n,waits:a}},Ft=e=>`${e.order}|${e.code}|${e.parameter}`,Et=e=>{const t=e.map(e=>new Set([...e.result.escapes,...e.covered.map(({pending:e})=>e)].filter(e=>!j(e)&&"always"===e.certainty).map(e=>Ft(e)))),n=e=>j(e)||"may"===e.certainty||t.every(t=>t.has(Ft(e)))?e:{...e,certainty:"may"};for(const t of e)t.result={...t.result,escapes:t.result.escapes.map(n)},t.covered=t.covered.map(({pending:e,by:t})=>({pending:n(e),by:t}))};class zt{options;bodies=new Map;stalled=new Set;waiting=new Set;strict;constructor(e){this.options=e,this.strict=!0===e.evaluation.strictDataPaths}root(e,t){return this.walk(e,{scope:null,bindings:null,sink:t,frame:{},walks:1})}async walk(e,t){const n=await this.visit(e,t);return n.waits&&this.waiting.add(e),n}async visit(e,t){switch(e.kind){case"constant":return{...xt,output:z(e.value)};case"invalid":throw Lt("an invalid node");case"reference":return this.reference(e,t);case"skeleton":{const n={...t,scope:wt(t,e.vars)},r=[];for(const t of e.holes)r.push({result:await this.walk(t.node,n),eager:!0});const a=((e,t)=>{if(t.every(e=>1===e.length&&"exact"in e[0]))return z(m(e.skeleton,e.holes,t.map(e=>e[0].exact)));const n=e.holes.map((e,n)=>({at:e.at,output:t[n]})),r=(e,t,n)=>{const a=n.find(e=>e.at.length===t);if(void 0!==a)return a.output;if(0===n.length)return z(e);const o=new Map;for(const e of n){const n=o.get(e.at[t]);void 0===n?o.set(e.at[t],[e]):n.push(e)}const s=e=>o.get(e)??[];if(Array.isArray(e))return re(Array.from(e,(e,n)=>r(e,t+1,s(n))));const i=e,c=new Set([...Object.keys(i),...n.map(e=>String(e.at[t]))]),u={};for(const e of c)u[e]=r(i[e],t+1,s(e));return se(u)};return r(e.skeleton,0,n)})(e,r.map(e=>e.result.output));return Pt([],r,a)}case"elements":case"entries":{const n=[],r=await this.container("",e,t,n);for(const e of n)Mt(t.sink,e.covered);const a=n.map(({result:e})=>({result:e,eager:!1}));return Pt([],a,r)}case"operator":return this.operator(e,t);case"fragmentCall":return this.call(e,t)}return e}async operator(e,t){const{definition:n}=e.entry,r={...t,scope:wt(t,e.vars)},a={},o=[],s=[];for(const[t,i]of Object.entries(e.params)){const e=n.parameters[t]?.evaluation;if("perElement"!==e)if("elements"===i.kind||"entries"===i.kind)a[t]=await this.container(t,i,r,s);else if("lazy"===e){const e=await this.apart(t,i,r);a[t]=e.result.output,s.push(e)}else{const e=await this.walk(i,r);a[t]=e.output,o.push({result:e,eager:!0})}}const i=Le(e,a),c=l(e),u={},p={};for(const[a,o]of n.resolution.perElement){const n=e.params[a];if(void 0===n||void 0===o.over)continue;const l=i.received[o.over]??F,m=L(l),d=1===m?.length&&Array.isArray(m[0])?m[0]:void 0,y=t.walks*(d?.length??1/0);if(y<=16){const e=[];for(const[o,i]of Array.from(d).entries()){const u={as:c,element:z(i),index:z(o),parent:t.bindings},l=await this.apart(a,n,{...r,bindings:u,walks:y},o);s.push(l),e.push(l.result.output)}p[a]=e,u[a]=W(e)}else{const e={as:c,element:te(l),index:jt,parent:t.bindings},o=await this.apart(a,n,{...r,bindings:e});s.push(o),u[a]=o.result.output}}const m=o.some(e=>"always"===e.result.verdict)?{output:F,failures:[],reached:new Set(s.filter(e=>"race"===n.parameters[e.param].evaluation)),awaited:new Set,escaped:new Set,passed:new Set,fails:!0}:"external"===Qe(n)?void 0:await mt(e,a,s,this.options,this.stalled);for(const e of Object.keys(p))Et(s.filter(t=>t.param===e&&(m?.reached.has(t)??!0)));const d=[];void 0===m?(Mt(d,i.failures),"yes"!==i.propagates&&Mt(d,((e,t,n)=>{const r=Qe(e.entry.definition),a={path:e.path,operator:e.name,order:[e.order]};if("external"===r)return[{...a,code:Re,message:`${e.name} – may fail whatever its inputs: nothing describes what it fails on`,certainty:"may"}];const o=[];for(const s of r){const r=tt(e,s,t,n);"no"!==r&&o.push({...a,code:s.code,message:et(e.name,s),certainty:"yes"!==r||s.may||s.overflow||"no"!==t.propagates?"may":"always",...void 0!==s.parameter?{parameter:s.parameter}:{}})}return o})(e,i,this.options))):Mt(d,m.failures);for(const t of s){if(void 0!==m&&!m.passed.has(t))continue;const r=n.parameters[t.param];if("perElement"===r.evaluation){const n=Ie(e,t.param,r,t.result.output);void 0!==n&&d.push(n)}else void 0!==m&&void 0===t.at&&Mt(d,i.failures.filter(e=>e.parameter===t.param))}const{output:y,boundary:f}=void 0===m?it(e,i,u,this.options.strictNumbers,p):ct(e,m.output,this.options.strictNumbers,!1);void 0===f||d.some(e=>!j(e)&&e.code===f.code)||d.push(f);for(const e of s){if(void 0!==m&&!m.reached.has(e))continue;Mt(t.sink,e.covered);const n=void 0===m||m.escaped.has(e)?e.result.escapes:e.result.escapes.filter(j),r=e.result.waits&&(m?.awaited.has(e)??!0);o.push({result:{...e.result,escapes:n,waits:r},eager:!1})}const h=Pt(d,o,y);return!0===m?.fails&&Object.assign(h,{verdict:"always",output:F}),(e=>void 0!==e.analysis||"external"===Qe(e))(n)&&(h.waits=!0),this.withFallback(e,h,r)}async apart(e,t,n,r){const a=[];return{param:e,...void 0!==r?{at:r}:{},result:await this.walk(t,{...n,sink:a}),covered:a}}async container(e,t,n,r){if("elements"===t.kind){const a=[];for(const[o,s]of t.nodes.entries()){const t=await this.apart(e,s,n,o);r.push(t),a.push(t.result.output)}return re(a)}const a={...n,scope:wt(n,t.vars)},o={};for(const[n,s]of Object.entries(t.entries)){const t=await this.apart(e,s,a,n);r.push(t),o[n]=t.result.output}return se(o)}async withFallback(e,t,n){if("no"===t.verdict)return t;const r="operator"===e.kind?e.entry.defaultFallback:void 0;if(void 0===e.fallback&&void 0===r)return t;const a={path:e.path};for(const e of t.escapes)n.sink.push({pending:e,by:a});const{waits:o}=t;if(void 0===e.fallback)return{...xt,output:H(t.output,St(r)),waits:o};const s=await this.walk(e.fallback,n);if(e.fallbackReadsError&&"no"!==s.verdict){const r={path:e.path,givesNull:!0};for(const e of s.escapes)n.sink.push({pending:e,by:r});return{...xt,output:H(t.output,s.output,Ot),waits:o||s.waits}}return{verdict:"always"===t.verdict||"always"!==s.verdict?s.verdict:"may",escapes:s.escapes,output:H(t.output,s.output),waits:o||s.waits}}async reference(e,t){const{segments:n,namespace:r}=e;switch(r){case"data":return this.drilled(e,E,n,[],[]);case"element":case"index":for(let a=t.bindings;null!==a;a=a.parent)if(p(a.as,r,e.binding))return"index"===r?{...xt,output:a.index}:this.drilled(e,a.element,n,[],[]);throw Lt(`an unresolved '${e.raw}'`);case"vars":{const r=await this.varDefinition(n[0],t);if(void 0===r)throw Lt(`an unresolved '${e.raw}'`);Mt(t.sink,r.covered);const a=[{result:r.result,eager:!0}];return this.drilled(e,r.result.output,n.slice(1),a,[])}case"params":{const{entry:r,params:a={}}=t.frame;if(void 0===r)throw Lt(`'${e.raw}' outside a fragment body`);const[o,...s]=n;if(void 0===o){const t=Object.keys(r.parameters).map(e=>({demand:e}));return this.drilled(e,se(a),[],[],t)}const i="string"==typeof o?a[o]??E:E;return this.drilled(e,i,s,[],[{demand:String(o)}])}case"error":return{...xt,output:Nt(n)}}return r}drilled(e,t,n,r,a){const{value:o,found:s}=ie(t,n);if("yes"===s)return Pt(a,r,o);if(!this.strict)return Pt(a,r,H(o,Ot));const i={path:e.path,code:"missing-data-path",message:`'${e.raw}' may be absent (strictDataPaths)`,certainty:"no"===s?"always":"may",order:[e.order]};return Pt([...a,i],r,o)}async varDefinition(e,t){for(let n=t.scope;null!==n;n=n.at.scope){if("string"!=typeof e||!Object.hasOwn(n.vars,e))continue;const t=n.known.get(e);if(void 0!==t)return t;n.known.set(e,{result:{...xt,output:E},covered:[]});const r=[],a={result:await this.walk(n.vars[e],{...n.at,scope:n,sink:r}),covered:r};return n.known.set(e,a),a}}async call(e,t){const{entry:n}=e;if(void 0===n)throw Lt(`a call to the unknown fragment '${e.name}'`);const r={...t,scope:wt(t,e.vars)},a=[],o=[],s={},i=new Map;if("static"===e.argumentsMode)for(const[t,a]of Object.entries(n.parameters)){const n=await this.argument(e,t,a,r);i.set(t,n),s[t]=n.result.output}else{const t=e.parameters,i=await this.walk(t,r);o.push({result:i,eager:!0}),Mt(a,Dt(e,n,t,s))}let c=!1;const u=e=>{const n=i.get(e)??kt;return Mt(t.sink,n.covered),c||=!0===n.result.waits,n},l=await this.body(n,s);for(const{pending:n,by:r}of l.covered){const a=$(r,e);if(j(n))for(const e of u(n.demand).result.escapes)t.sink.push({pending:e,by:a});else t.sink.push({pending:O(n,e),by:a})}const p=[];for(const t of l.result.escapes)j(t)?Mt(p,u(t.demand).result.escapes):p.push(O(t,e));return o.push({result:{...l.result,escapes:[]},eager:!0},{result:{...xt,escapes:p,waits:c},eager:!1}),this.withFallback(e,Pt(a,o,l.result.output),r)}async argument(e,t,n,r){const a=e.parameters?.[t];if(void 0===a)return{result:{...xt,output:z(n.default??null)},covered:[]};const o=[],s=await this.walk(a,{...r,sink:o}),{known:i,answer:c}=Be(n,s.output),u="yes"===c?[]:[qt(e,t,a.path,a.order)];return{result:Pt(u,[{result:s,eager:!0}],i),covered:o}}async body(e,t){const n=Object.keys(t).map(e=>`${e}=${T(t[e])}`).join(";");let r=this.bodies.get(e);void 0===r&&this.bodies.set(e,r=new Map);const a=r.get(n);if(void 0!==a)return a;r.set(n,{result:{...xt,output:E},covered:[]});const o=[],s={entry:e,params:t},i={result:await this.walk(e.body,{scope:null,bindings:null,sink:o,frame:s,walks:1}),covered:o};return r.set(n,i),i}}const Lt=e=>new Error(`[fig-tree internal] ${e} reached the coverage walk — the static gate should have refused it`),qt=(e,t,n,r)=>({path:n,code:"type-check",message:`fragment '${e.name}' – parameter '${t}': the argument may not fit the declared type`,certainty:"may",parameter:t,order:[r]}),Dt=(e,t,n,r)=>{const a=(t,r)=>({path:n.path,code:t,message:`fragment '${e.name}' – ${r}`,certainty:"may",order:[n.order]}),o=Object.entries(t.parameters);for(const[e,t]of o)r[e]=Be(t,E).known;const s=[a("type-check","'parameters' may not match the declared parameters")];return o.some(([,e])=>e.required)&&s.push(a("missing-required","'parameters' may omit a required parameter")),s},Jt=async(e,t,n)=>{if(!(e instanceof d))throw new TypeError("fallbackCoverage() takes a FigTree instance");const r=n?.strictNumbers??!1;if("boolean"!=typeof r)throw new x({code:b.invalidOptions,message:`'strictNumbers' must be a boolean, received ${JSON.stringify(r)}`,path:[]});const{artifact:a,options:o}=y(e.compile(t)),s=f(a,o).filter(e=>"error"===e.severity);if(s.length>0)return{uncovered:s.map(N),covered:[]};const i=new zt({strictNumbers:r,evaluation:o}),c=[],{escapes:u,waits:l}=await i.root(a.root,c),p=u.filter(e=>!j(e)).map(M);if(void 0!==o.timeout&&l)for(const{node:e,timeoutFallback:t}of a.holes){const n={path:e.path,code:"timeout",certainty:"may",order:[e.order]};a.timeoutShielded?i.waiting.has(e)&&c.push({pending:{...n,message:"may be cut off by the timeout, which puts its static fallback in its place"},by:{path:e.path}}):void 0===t&&p.push(M({...n,message:"the timeout may reject the evaluation: something in it can wait, and this value has no static fallback to shield it"}))}const m=c.flatMap(({pending:e,by:t})=>j(e)?[]:[P(e,t)]);return{uncovered:S(p),covered:S(m)}};export{Jt as fallbackCoverage};
|
|
1
|
+
import{t as e,i as t,c as n,a as r,n as a,b as o,d as s,e as i,v as c,f as u,r as l,g as p,s as m,F as d,h as y,j as f}from"../chunks/engine.js";import{i as h,r as v,W as g,E as b,a as w,F as x,b as k}from"../chunks/shared.js";const j=e=>"demand"in e,O=(t,n)=>({...t,path:n.path,...void 0===t.fragment?{fragment:n.name,fragmentPath:e(t.path)}:{},order:[n.order,...t.order]}),$=(t,n)=>void 0===t.fragmentPath?{...t,path:n.path,fragmentPath:e(t.path)}:{...t,path:n.path},A=t=>{const{code:n,message:r,certainty:a,operator:o,parameter:s,fragment:i,fragmentPath:c}=t;return{path:e(t.path),code:n,message:r,certainty:a,...void 0!==o?{operator:o}:{},...void 0!==s?{parameter:s}:{},...void 0!==i?{fragment:i,fragmentPath:c}:{}}},N=({path:e,code:t,message:n,operator:r,parameter:a})=>({path:[...e],code:t,message:n,certainty:"always",...void 0!==r?{operator:r}:{},...void 0!==a?{parameter:a}:{}}),S=e=>{const t=new Map;for(const{finding:n}of[...e].sort((e,t)=>((e,t)=>{for(let n=0;n<Math.min(e.length,t.length);n++)if(e[n]!==t[n])return e[n]-t[n];return e.length-t.length})(e.order,t.order))){const e=JSON.stringify({...n,message:void 0,certainty:void 0}),r=t.get(e);void 0===r?t.set(e,n):"always"===n.certainty&&(r.certainty="always")}return[...t.values()]},M=e=>({order:e.order,finding:A(e)}),P=(t,n)=>({order:t.order,finding:{...A(t),coveredBy:e(n.path),...void 0!==n.fragmentPath?{coveredByFragmentPath:n.fragmentPath}:{},...n.givesNull?{givesNull:n.givesNull}:{}}}),F=[],E=[{type:"string"},{type:"number"},{type:"boolean"},{type:"null"},{type:"array"},{type:"object"},{type:"opaque"},{type:"nonFinite"}],z=e=>[{exact:void 0===e?null:e}],L=e=>e.length>0&&e.every(e=>"exact"in e)?e.map(e=>e.exact):void 0,q=e=>"exact"in e?null===e.exact:"null"===e.type,D=e=>{if(h(e))return e.literal.map(e=>({exact:e}));const t="string"==typeof e?[e]:e;return t.includes("any")?E:W(t.map(e=>[{type:e}]))},J=new WeakMap;let B=0;const I=e=>"object"==typeof e&&null!==e||"function"==typeof e?`=#${(e=>{let t=J.get(e);return void 0===t&&J.set(e,t=++B),t})(e)}`:`=${typeof e}:${String(e)}`,C=e=>{if("exact"in e)return I(e.exact);if("array"===e.type)return void 0!==e.items?`a[${e.items.map(T).join(";")}]`:`a${e.length??""}+${e.minLength??""}(${void 0===e.element?"*":T(e.element)})`;if("object"===e.type)return void 0===e.keys?"o":`o{${Object.keys(e.keys).sort().map(t=>`${JSON.stringify(t)}:${T(e.keys[t])}`).join(",")}}`;const{type:t,...n}=e;return`${t}${JSON.stringify(n)}`},T=e=>e.map(C).sort().join("|"),R=e=>{if(null===e)return{type:"null"};if(Array.isArray(e))return{type:"array"};switch(typeof e){case"string":return{type:"string"};case"number":return{type:Number.isInteger(e)?"integer":Number.isFinite(e)?"number":"nonFinite"};case"boolean":return{type:"boolean"};case"object":{const t=Object.getPrototypeOf(e);return t===Object.prototype||null===t?{type:"object"}:{type:"opaque"}}default:return{type:"opaque"}}},W=e=>{const t=new Set,n=[];for(const r of e)for(const e of r){const r=C(e);t.has(r)||(t.add(r),n.push(e))}const r=n.filter(e=>"exact"in e).map(e=>e.exact);return r.length<=16?n:H(n.filter(e=>!("exact"in e)),Q(r))},H=(...e)=>W(e),G=e=>"number"==typeof e&&Number.isFinite(e),K=e=>Array.from(e).length,Q=e=>{const t=(e,t)=>{if(0===t.length)return F;const n=t.reduce((e,t)=>Math.min(e,t));return[U({type:e},n)]};return W([...[!0,!1].map(t=>ye(me(e.map(e=>G(e)&&Number.isInteger(e)===t?le(e):void 0)))),t("string",e.filter(e=>"string"==typeof e).map(K)),t("array",e.filter(Array.isArray).map(e=>e.length)),...e.filter(e=>!G(e)&&"string"!=typeof e&&!Array.isArray(e)).map(e=>[R(e)])])},U=(e,t)=>t?{...e,minLength:t}:e,V=e=>e.some(q),X=e=>e.length>0&&e.every(q),Y=e=>e.filter(e=>!q(e)),Z=e=>Oe(e.map(e=>{if("exact"in e){const{exact:n}=e;return(Array.isArray(n)?n:t(n)?Object.values(n):[]).includes(null)?"yes":"no"}return"array"===e.type?0!==e.length&&V(e.element??E)?"maybe":"no":"object"===e.type?"maybe":"no"})),_=(e,t)=>W(e.map(e=>{if("no"===Z([e]))return[e];const n="exact"in e?e.exact:void 0;if(1===t.length&&"exact"in t[0]&&"exact"in e){const e=t[0].exact,r=t=>null===t?e:t;if(Array.isArray(n))return z(n.map(r));const a={};for(const[e,t]of Object.entries(n))a[e]=r(t);return z(a)}if(!(Array.isArray(n)||"type"in e&&"array"===e.type))return[{type:"object"}];const{length:r,minLength:a}=e;return ne([Y(te([e])),t],Array.isArray(n)?{length:n.length}:{length:r,minLength:a})})),ee=e=>e.flatMap(e=>{const t=Z([e]);if("no"===t)return[e];if("yes"===t)return F;if(!("type"in e))return[e];if("array"!==e.type)return[e];const{items:n,...r}=e;if(void 0===n)return[{...r,element:Y(e.element??E)}];const a=n.map(Y);return a.some(e=>0===e.length)?F:re(a)}),te=e=>W(e.map(e=>"exact"in e?Array.isArray(e.exact)?W(Array.from(e.exact,e=>z(e))):F:"array"===e.type?0===e.length?F:e.element??E:F)),ne=(e,t={})=>[{type:"array",element:W(e),...t}],re=e=>[{type:"array",element:W(e),length:e.length,items:e}],ae=e=>H(e.map(e=>"exact"in e?R(e.exact):e)),oe=e=>je(e.map(e=>"exact"in e?"number"!=typeof e.exact||Number.isFinite(e.exact)?"no":"yes":"nonFinite"===e.type?"maybe":"no")),se=e=>[{type:"object",keys:e}],ie=(e,t)=>{if(0===t.length)return{value:e,found:"yes"};const[n,...r]=t;let a;const o=[],s=Oe(e.map(e=>{if("exact"in e){const n=v(e.exact,t);return n.found&&o.push(z(n.value)),n.found?"yes":"no"}const s=(e,t)=>{if("no"===t)return"no";const n=(e=>e===E?a??=ie(E,r):ie(e,r))(e);return o.push(n.value),"yes"===t?n.found:"no"===n.found?"no":"maybe"};if(n===g)return"array"!==e.type?"no":(o.push(0===r.length?[e]:[{type:"array"}]),"yes");switch(e.type){case"array":{const t="number"==typeof n?n:Number(n);if(!Number.isInteger(t)||t<0)return"number"==typeof n?"no":"maybe";const r=void 0!==e.length?t<e.length?"yes":"no":t<(e.minLength??0)?"yes":"maybe";return void 0!==e.items&&"yes"===r?s(e.items[t],"yes"):s(e.element??E,r)}case"object":return void 0===e.keys?s(E,"maybe"):Object.hasOwn(e.keys,String(n))?s(e.keys[String(n)],"yes"):"no";case"opaque":return s(E,"maybe");default:return"no"}}));return{value:W(o),found:0===e.length?"yes":s}},ce={min:0,max:0,integer:!0},ue={min:1,max:1,integer:!0},le=e=>({min:e,max:e,integer:Number.isInteger(e)}),pe=e=>"exact"in e?G(e.exact)?le(e.exact):void 0:"number"===e.type||"integer"===e.type?{min:e.min??-1/0,max:e.max??1/0,integer:"integer"===e.type}:void 0,me=e=>e.reduce((e,t)=>void 0===e||void 0===t?e??t:{min:Math.min(e.min,t.min),max:Math.max(e.max,t.max),integer:e.integer&&t.integer},void 0),de=e=>me(e.map(pe)),ye=e=>{if(void 0===e)return F;const t=e.integer?Math.ceil(e.min):e.min,n=e.integer?Math.floor(e.max):e.max;return t>n?F:[{type:e.integer?"integer":"number",...t>-1/0?{min:t}:{},...n<1/0?{max:n}:{}}]},fe=e=>e.filter(e=>"exact"in e?"number"!=typeof e.exact:!["number","integer","nonFinite"].includes(e.type)),he=e=>te(e).filter(e=>"no"!==oe([e])),ve=(e,t,n)=>W(e.map(e=>"exact"in e?Array.isArray(e.exact)?t(Array.from(e.exact,e=>z(e))):F:"array"!==e.type?F:void 0!==e.items?t(e.items):0===e.length?n(F,0):n(e.element??E,e.length??e.minLength??0))),ge=(e,t,n)=>e.reduce((e,t)=>{const r=de(t);return e&&r&&n(e,r)},t),be=(e,t)=>({min:e.min+t.min,max:e.max+t.max,integer:e.integer&&t.integer}),we=(e,t)=>0===e||0===t?0:e*t,xe=(e,t)=>{const n=[we(e.min,t.min),we(e.min,t.max),we(e.max,t.min),we(e.max,t.max)];return{min:Math.min(...n),max:Math.max(...n),integer:e.integer&&t.integer}},ke=(e,t)=>H(fe(te(e)),he(e),ve(e,e=>{const n=e.map(de);if(e.some(e=>"no"!==oe(e)))return ye(me(n));if(0===n.length||n.includes(void 0))return F;const r="min"===t?Math.min:Math.max;return ye({min:n.map(e=>e.min).reduce((e,t)=>r(e,t)),max:n.map(e=>e.max).reduce((e,t)=>r(e,t)),integer:n.every(e=>e.integer)})},e=>ye(de(e)))),je=e=>e.includes("yes")?"yes":e.includes("maybe")?"maybe":"no",Oe=e=>e.every(e=>"yes"===e)?"yes":e.every(e=>"no"===e)?"no":"maybe",$e=(e,t)=>"no"===e||"no"===t?"no":"yes"===e&&"yes"===t?"yes":"maybe",Ae=(e,t)=>{if("exact"in e)return Ne([e.exact],t);if("object"!==e.type)return"no";if(void 0===e.keys)return"maybe";const n=e.keys;return Oe(Object.entries(t).map(([e,t])=>{if(!Object.hasOwn(n,e))return!1===t.required?"yes":"no";const r=void 0===t.type?"yes":Se(n[e],t.type);return void 0===t.constraints?r:$e(r,Se(n[e],"any",t.constraints))}))},Ne=(e,t)=>r(e,{elementShape:t},!1).ok?"yes":"no",Se=(e,t,a,o=!1)=>Oe(e.map(e=>{if("exact"in e){const s=e.exact;return n(s,t).ok&&(null===s||void 0===a||r(s,a,o).ok)?"yes":"no"}const s=((e,t)=>{if(h(t)){const n=t=>{const n=pe(e);return void 0!==n?"number"==typeof t&&(!n.integer||Number.isInteger(t))&&t>=n.min&&t<=n.max:"string"===e.type?"string"==typeof t&&K(t)>=(e.minLength??0):typeof t===e.type};return t.literal.some(n)?"maybe":"no"}const n="string"==typeof t?[t]:t;if(n.includes("any"))return"yes";switch(e.type){case"number":return n.includes("number")?"yes":n.includes("integer")?"maybe":"no";case"integer":return n.includes("integer")||n.includes("number")?"yes":"no";case"opaque":return n.includes("object")?"maybe":"no";case"nonFinite":return n.includes("number")?"yes":"no";default:return n.includes(e.type)?"yes":"no"}})(e,t);return"no"===s||void 0===a||"null"===e.type?s:$e(s,((e,t,n)=>{if(0===Object.keys(t).filter(e=>void 0!==t[e]).length)return"yes";if("array"!==e.type)return"no";let r="yes";void 0!==t.length&&(r=$e(r,void 0===e.length?"maybe":e.length===t.length?"yes":"no"));const a=0===e.length?F:e.element??E,o=n?Y(a):a;return void 0!==t.homogeneous&&(r=$e(r,0===o.length||t.homogeneous.some(e=>"yes"===Se(o,e))?"yes":"maybe")),void 0!==t.elementShape&&(r=$e(r,o.every(e=>"yes"===Ae(e,t.elementShape))?"yes":"maybe")),r})(e,a,o))})),Me=(e,t)=>"yes"===Se(e,t)?e:W(e.map(e=>"no"===Se([e],t)?F:"exact"in e?[e]:h(t)?t.literal.filter(t=>"no"!==Se([e],{literal:[t]})).map(e=>({exact:e})):"number"===e.type?ye({...pe(e),integer:!0}):[e])),Pe=e=>"string"==typeof e?e:Array.isArray(e)?e.join(" | "):`one of ${e.literal.map(e=>JSON.stringify(e)).join(", ")}`,Fe=(e,t,n)=>{const r=e.entry.hostDefaults;return void 0!==r&&Object.hasOwn(r,t)?z(r[t]):"default"in n?"symbol"==typeof n.default?E:z(n.default):void 0},Ee=(e,t)=>"lazyEntries"===e.evaluation?"entries"===t.kind:"elements"===t.kind,ze=(e,t)=>{const n=e.nullPolicy;if("string"==typeof n)return new Set([n]);const r=t[n.selector]?.known??F,a=r.every(e=>"exact"in e)?n.table.filter(e=>r.some(t=>"exact"in t&&t.exact===e.value)):n.table;return new Set(a.map(e=>e.policy))},Le=(e,t)=>{const{definition:n}=e.entry,{entries:r,whole:s}=n.resolution,i={},c=new Set,u=[],l={},p=new Set,m={},d=new Set;let y,f="no";const h=(t,n,r,a)=>{const o=Se(r,n.type,n.constraints,void 0!==n.elementNullPolicy);if("yes"===o)return;const s={path:e.path,code:"type-check",message:`${e.name} – parameter '${t}': may receive something other than ${Pe(n.type)}${void 0!==n.constraints?", as constrained":""}`,certainty:"no"===o&&a?"always":"may",operator:e.name,parameter:t,order:[e.order]};u.push(s),"no"===o&&a&&(y??=s)};for(const[n,a]of r){const r=e.params[n];switch(a.evaluation){case"eager":void 0!==r&&(l[n]={known:t[n],absent:!1});break;case"structural":"constant"===r?.kind&&(l[n]={known:z(r.value),absent:!1});break;case"lazy":if(void 0!==a.replacesNullAt){const o=void 0!==r?t[n]:Fe(e,n,a);if(void 0!==o)for(const e of a.replacesNullAt)m[e]={name:n,known:o}}else void 0!==r&&(p.add(n),h(n,a,t[n],!1),i[n]=Me(t[n],a.type));break;case"lazyElements":case"lazyEntries":case"race":if(void 0===r)break;Ee(a,r)?(p.add(n),i[n]=t[n]):l[n]={known:t[n],absent:!1}}}for(const[t,n]of s){if(p.has(t))continue;const r=l[t]??{known:F,absent:!0},o=a(n)&&V(r.known);if(!r.absent&&!o)continue;const s=Fe(e,t,n),i=o?Y(r.known):r.known;l[t]={known:void 0===s?i:H(i,s),absent:void 0===s}}for(const[e,t]of s){if(p.has(e))continue;let n=l[e]?.known??F;if(0===n.length)continue;l[e].absent&&c.add(e);const r=m[e];if(void 0!==r){(void 0!==t.elementNullPolicy?"no"!==Z(n):V(n))&&(d.add(r.name),n=void 0!==t.elementNullPolicy?_(n,r.known):H(Y(n),r.known))}const a="eager"!==t.evaluation&&"structural"!==t.evaluation;if(V(n)&&o(t.type)&&!a){const e=ze(t,l);if(e.has("propagate")){const t=1===e.size&&X(n);if(f=t?"yes":"maybe",t){y??="null";break}1===e.size&&(n=Y(n))}}if("propagate"===t.elementNullPolicy){const e=Z(n);if("no"!==e){if(f="yes"===e?"yes":"maybe","yes"===e){y??="null";break}n=ee(n)}}h(e,t,n,!0),i[e]=Je(t,n)}if("no"!==f)for(const e of u)"always"===e.certainty&&(e.certainty="may");return{received:i,absent:c,failures:u,propagates:f,consulted:d,...y?{ends:y}:{}}},qe=e=>{const t="string"==typeof e?[e]:Array.isArray(e)?e:[];return t.length>0&&t.every(e=>"array"===e||"object"===e)},De=(e,n)=>{if(qe(n)){if(Array.isArray(e))return e.map(s);if(t(e)){const t={};for(const[n,r]of Object.entries(e))t[n]=s(r);return t}}return s(e)},Je=(e,t)=>{const n=Me(t,e.type);return e.truthiness?n.length>0&&n.every(e=>"exact"in e)?W(n.map(t=>z(De(t.exact,e.type)))):qe(e.type)?E:D("boolean"):n},Be=(e,t)=>{const n=a(e)&&V(t),r=n?Y(t):t;let o=Se(r,e.type,e.constraints);"yes"===o&&void 0!==e.constraints&&V(r)&&(o="maybe");const s=n?z(e.default??null):F;return{known:H(Me(r,e.type),s),answer:o}},Ie=(e,t,n,r)=>{if("yes"!==Se(r,n.type,n.constraints))return{path:e.path,code:"type-check",message:`${e.name} – parameter '${t}': an element's result may be other than ${Pe(n.type)}`,certainty:"may",operator:e.name,parameter:t,order:[e.order]}},Ce="non-finite-result",Te="empty-aggregate",Re="operator-failure",We={code:Ce,overflow:!0},He=e=>({code:"type-check",parameter:"values",when:{expect:e,values:{some:{not:{type:e}}}}}),Ge={plus:[{code:Te,parameter:"values",when:{values:{empty:!0},expect:{supplied:!1}}},He("number"),He("string"),He("array"),He("object"),We],subtract:[We],multiply:[We],divide:[{code:Ce,parameter:"by",when:{by:0}},We],modulo:[{code:Ce,parameter:"mod",when:{mod:0}},We],power:[{code:Ce,parameter:"base",when:{base:0,exponent:{below:0}}},{code:Ce,parameter:"base",may:!0,when:{base:{below:0},exponent:{not:{type:"integer"}}}},{code:Ce,parameter:"exponent",may:!0,when:{exponent:{not:{below:100}}}},We],round:[{code:Ce,parameter:"decimals",may:!0,when:{decimals:{not:{below:300}}}},We],min:[{code:Te,parameter:"values",when:{values:{empty:!0}}}],max:[{code:Te,parameter:"values",when:{values:{empty:!0}}}],match:[{code:Re,may:!0,when:{default:{supplied:!1}}}],regex:[{code:Re,parameter:"flags",when:{flags:{invalid:!0}}},{code:Re,parameter:"pattern",when:{pattern:{invalid:!0}}}],get:[{code:Re,parameter:"path",when:{path:{invalid:!0}}},{code:"missing-data-path",may:!0,options:{strictDataPaths:!0},when:{default:{supplied:!1}}}],convert:[{code:Re,when:{to:"number",value:{type:["array","object"]}}},{code:Re,may:!0,when:{to:"number",value:{type:"string"}}},{code:Ce,may:!0,when:{to:"number",value:{type:"string"}}},{code:Re,when:{to:"string",value:{type:["array","object"]}}}]};let Ke;const Qe=e=>{const t=e.analysis;return void 0!==t?t.external?"external":t.failures??[]:(Ke??=new Map(i.map(e=>[e,Ge[e.name]??[]])),Ke.get(e)??"external")},Ue=e=>"yes"===e?"no":"no"===e?"yes":"maybe",Ve=(e,n)=>{if(null===e||"object"!=typeof e){if("exact"in n)return n.exact===e?"yes":"no";return"no"===Se([n],null===e?"null":{literal:[e]})?"no":"maybe"}if("type"in e)return Se([n],e.type);if("not"in e)return Ue(Ve(e.not,n));if("below"in e)return"exact"in n?"number"==typeof n.exact&&n.exact<e.below?"yes":"no":"number"===n.type||"integer"===n.type?(n.max??1/0)<e.below?"yes":(n.min??-1/0)>=e.below?"no":"maybe":"nonFinite"===n.type?"maybe":"no";if("empty"in e){if("exact"in n){const{exact:e}=n;return"string"==typeof e||Array.isArray(e)?0===e.length?"yes":"no":t(e)&&0===Object.keys(e).length?"yes":"no"}switch(n.type){case"array":return void 0!==n.length?0===n.length?"yes":"no":n.minLength?"no":"maybe";case"object":return void 0===n.keys?"maybe":0===Object.keys(n.keys).length?"yes":"no";case"string":return n.minLength?"no":"maybe";default:return"no"}}if("some"in e){if("exact"in n){const{exact:r}=n,a=Array.isArray(r)?Array.from(r):t(r)?Object.values(r):[];return je(a.map(t=>Ve(e.some,{exact:t??null})))}if("array"===n.type){if(0===n.length)return"no";const t=Xe(e.some,n.element??E);return"yes"!==t||void 0===n.length&&!n.minLength?"no"===t?"no":"maybe":"yes"}return"object"===n.type?void 0===n.keys?"maybe":je(Object.values(n.keys).map(t=>"no"===Xe(e.some,t)?"no":"maybe")):"no"}return"maybe"},Xe=(e,t)=>0===t.length?"no":Oe(t.map(t=>Ve(e,t))),Ye=e=>void 0!==e&&1===e.length&&"exact"in e[0]?{value:e[0].exact}:void 0,Ze=(e,t,n,r)=>{const a=r.received[t],o=void 0===a?"no":r.absent.has(t)?"maybe":"yes";return null!==n&&"object"==typeof n&&"supplied"in n?n.supplied?o:Ue(o):"no"===o?"no":null!==n&&"object"==typeof n&&"invalid"in n?((e,t,n)=>{const{validate:r}=e.entry.definition;if(void 0===r)return"no";if(void 0===Ye(n.received[t]))return"maybe";const a={};for(const[e,t]of Object.entries(n.received)){const r=Ye(t);void 0===r||n.absent.has(e)||(a[e]=r.value)}return r(a,c).some(e=>"error"===e.severity&&e.parameter===t)?"yes":"no"})(e,t,r):Xe(n,a)},_e=e=>null===e||"object"!=typeof e?JSON.stringify(e):"type"in e?"string"==typeof e.type?`a ${e.type}`:`of type ${JSON.stringify(e.type)}`:"not"in e?`not ${_e(e.not)}`:"below"in e?`below ${e.below}`:"empty"in e?"empty":"supplied"in e?e.supplied?"supplied":"not supplied":"invalid"in e?"refused by its validation":`with some element ${_e(e.some)}`,et=(e,t)=>{const n=Object.entries(t.when??{}).map(([e,t])=>null!==t&&"object"==typeof t&&"some"in t?`some element of '${e}' is ${_e(t.some)}`:`'${e}' is ${_e(t)}`),r=n.length>0?`when ${n.join(" and ")}`:t.overflow?"on extreme numbers":"whatever its inputs";return`${e} – ${t.code} ${t.may?"possible ":""}${r}`},tt=(e,t,n,r)=>{if(t.overflow&&!r.strictNumbers)return"no";for(const[e,n]of Object.entries(t.options??{}))if((r.evaluation[e]??!1)!==n)return"no";const a=Object.entries(t.when??{}).map(([t,r])=>Ze(e,t,r,n));return a.includes("no")?"no":a.every(e=>"yes"===e)?"yes":"maybe"},nt={if:{oneOf:[{param:"then"},{param:"else"}]},match:{oneOf:[{param:"branches"},{param:"default"}]},firstNonNull:{firstNonNull:"values"},find:{oneOf:[{elementOf:"input"},{param:"noMatchDefault"}]},plus:{oneOf:[{sum:"values"},{typeNamedBy:"expect"}]},subtract:{difference:["value","minus"]},multiply:{product:"values"},abs:{abs:"value"},min:{min:"values"},max:{max:"values"},length:{type:"integer",min:0},filter:{arrayOf:{elementOf:"input"}},map:{arrayOf:{param:"each"}},split:{byParam:"delimiter",cases:{"":{arrayOf:"string"}},otherwise:{arrayOf:"string",minLength:1}},convert:{typeNamedBy:"to"},regex:{byParam:"mode",cases:{test:"boolean",extract:{oneOf:["string",{param:"noMatchDefault"}]},match:{arrayOf:"string"}}}};let rt;const at=/*#__PURE__*/new Set(["lazyElements","lazyEntries","race"]),ot=(e,n)=>{const{inputs:r}=n,a=e=>r.received[e]??F;if((e=>"string"==typeof e||Array.isArray(e)||"literal"in e)(e))return D(e);if("type"in e)return(e=>{const{type:t,min:n=-1/0,max:r=1/0}=e;return"number"===t||"integer"===t?ye({min:n,max:r,integer:"integer"===t}):[U({type:t},e.minLength)]})(e);if("sum"in e)return o=a(e.sum),H(ae(fe(te(o))),he(o),ve(o,e=>ye(ge(e,ce,be)),(e,t)=>{const n=de(e);if(void 0===n)return 0===t?ye(ce):F;const r=t>0;return ye({min:n.min>=0?r?n.min:0:-1/0,max:n.max<=0?r?n.max:0:1/0,integer:n.integer})}));var o;if("product"in e)return(e=>H(he(e),ve(e,e=>ye(ge(e,ue,xe)),(e,t)=>{const n=de(e);if(void 0===n)return 0===t?ye(ue):F;const r=n.min>=-1&&n.max<=1;return ye({min:n.min>=1?1:n.min>=0?0:r?-1:-1/0,max:r?1:1/0,integer:n.integer})})))(a(e.product));if("difference"in e)return((e,t)=>{const n=de(e),r=de(t);return ye(n&&r&&{min:n.min-r.max,max:n.max-r.min,integer:n.integer&&r.integer})})(...e.difference.map(a));if("abs"in e)return(e=>{const t=de(e);if(void 0===t)return F;const{min:n,max:r}=t;return ye(n>=0?t:r<=0?{...t,min:-r,max:-n}:{...t,min:0,max:Math.max(-n,r)})})(a(e.abs));if("min"in e)return ke(a(e.min),"min");if("max"in e)return ke(a(e.max),"max");if("param"in e){const r=e.param;if(Object.hasOwn(n.elements,r))return n.elements[r];const o=a(r),s=n.definition.parameters[r]?.evaluation??"eager";return at.has(s)?H(te(o),(e=>W(e.map(e=>"exact"in e?t(e.exact)?W(Object.values(e.exact).map(e=>z(e))):F:"object"!==e.type?F:void 0===e.keys?E:W(Object.values(e.keys)))))(o)):o}if("elementOf"in e)return te(a(e.elementOf));if("kindOf"in e)return ae(te(a(e.kindOf)));if("arrayOf"in e){const{arrayOf:t,minLength:r}=e,a="object"==typeof t&&"param"in t?n.items[t.param]:void 0;return void 0!==a?re(a):ne([ot(t,n)],r?{minLength:r}:{})}if("oneOf"in e)return W(e.oneOf.map(e=>ot(e,n)));if("typeNamedBy"in e){const t=e.typeNamedBy,a=r.received[t];if(void 0===a)return F;const o=L(a)??((e,t)=>{const n=e.definition.parameters[t]?.type;return"object"==typeof n&&"literal"in n?[...n.literal]:void 0})(n,t);return void 0===o?E:W(o.filter(e=>"string"==typeof e).map(e=>D(e)))}if("byParam"in e){const{cases:t,otherwise:a}=e,o=r.received[e.byParam],s=void 0===o?void 0:L(o),i=s?.map(e=>"string"==typeof e&&Object.hasOwn(t,e)?t[e]:a)??[...Object.values(t),a];return W(i.map(e=>void 0===e?F:ot(e,n)))}return(e=>W(e.map(e=>{const t="exact"in e?Array.isArray(e.exact)?Array.from(e.exact,e=>z(e)):void 0:"array"===e.type?e.items:void 0;if(void 0===t)return H(Y(te([e])),z(null));const n=[];for(const e of t)if(n.push(Y(e)),!V(e))return W(n);return W([...n,z(null)])})))(a(e.firstNonNull))},st=[{type:"nonFinite"}],it=(e,t,n,r,a={})=>{if("yes"===t.propagates)return{output:z(null)};const{definition:o}=e.entry,s=(e=>void 0!==e.analysis?e.analysis.output:(rt??=new Map(i.filter(e=>Object.hasOwn(nt,e.name)).map(e=>[e,nt[e.name]])),rt.get(e)))(o);let c=void 0!==s?ot(s,{definition:o,inputs:t,elements:n,items:a}):D(o.returns);return Object.values(t.received).some(e=>"no"!==oe(e))&&"no"!==Se(c,"number")&&(c=H(c,st)),"maybe"===t.propagates&&(c=H(c,z(null))),ct(e,c,r,"no"===t.propagates)},ct=(e,t,n,r)=>{const a=oe(t),o=n?a:oe(ut(t)),s=t.filter(e=>"exact"in e?"number"!=typeof e.exact||Number.isFinite(e.exact):"nonFinite"!==e.type);return"no"===o?{output:s}:{output:s,boundary:{path:e.path,code:"non-finite-result",message:`${e.name} – non-finite-result possible: a NaN or infinite number may reach its result`,certainty:0===s.length&&r?"always":"may",operator:e.name,order:[e.order]}}},ut=e=>e.filter(e=>!("type"in e&&"nonFinite"===e.type)),lt={unknown:!0},pt={fails:!0},mt=async(e,t,n,r,a=new Set)=>{if(a.has(e.entry.definition))return;const{parameters:o}=e.entry.definition,s=new Set(n.map(e=>e.param)),i=[];for(const[e,n]of Object.entries(t)){if(s.has(e))continue;const t=L(n);if(void 0===t)return;i.push({name:e,outcomes:t.map(e=>({value:e}))})}const c=n.map(e=>{const t=o[e.param],n=((e,t)=>{const{verdict:n,output:r}=e.result,a=void 0!==t.replacesNullAt;if("always"===n)return[a?lt:pt];const o=L(r);if(void 0===o)return[lt];const s=o.map(e=>({value:e}));return"no"===n?s:a?[lt]:[...s,pt]})(e,t);return{child:e,outcomes:"perElement"===t.evaluation&&void 0===e.at&&n.length>1?[lt]:n}}),u=()=>[...i,...c].reduce((e,{outcomes:t})=>e*t.length,1);if(u()>16)for(const e of c)e.outcomes.length>1&&(e.outcomes=[lt]);const l=u();if(l>16)return;const p=new Set,m=new Set,d=[];for(let n=0;n<l;n++){let o=n;const s=e=>{const t=e[o%e.length];return o=Math.floor(o/e.length),t},u={};for(const{name:e,outcomes:t}of i)u[e]=s(t).value;const l=new Map(c.map(({child:e,outcomes:t})=>[e,s(t)])),y=await bt(e,t,u,l,r,p,m,a);if(void 0===y)return;d.push(y)}const y=[],f=new Map,h=new Set,v=new Set;let g=0;for(const e of d)if("value"in e)y.push(z(e.value));else if("passed"in e){const{passed:t}=e;v.add(t),h.add(t),y.push(dt(t,o[t.param]))}else if(g++,"escaped"in e)h.add(e.escaped);else{const t=`${e.failure.code}|${e.failure.parameter??""}`,n=f.get(t)??{failure:e.failure,count:0};n.count++,f.set(t,n)}const b=[...f.values()].map(({failure:e,count:t})=>({...e,certainty:t===d.length?"always":"may"}));return{output:W(y),failures:b,reached:p,awaited:m,escaped:h,passed:v,fails:g===d.length}},dt=(e,t)=>void 0===e.at||"perElement"===t.evaluation?Je(t,e.result.output):t.truthiness?D("boolean"):e.result.output,yt=Symbol("stopped"),ft=new Promise(()=>{}),ht=e=>{const t=Promise.reject(e);return t.catch(()=>{}),t},vt={memo:(e,t)=>t()},gt={note:()=>{}},bt=async(e,t,n,r,a,o,i,c)=>{const l=e=>{o.add(e),i.add(e)},{definition:p}=e.entry,{parameters:m}=p,d={...t};for(const[e,t]of Object.entries(n))d[e]=z(t);for(const[e,t]of r)void 0!==m[e.param].replacesNullAt&&"value"in t&&(d[e.param]=z(t.value));const y=Le(e,d);for(const[e,t]of r){if("race"===m[e.param].evaluation&&o.add(e),y.consulted.has(e.param)){if(!("value"in t))return;l(e)}}const f=Qe(p),h=(t,n,r)=>{const o=r??("external"===f?void 0:f.find(n=>n.code===t&&void 0!==n.parameter&&"no"!==tt(e,n,y,a))?.parameter);return{failure:{path:e.path,code:t,message:n,certainty:"always",operator:e.name,...void 0!==o?{parameter:o}:{},order:[e.order]}}};if("null"===y.ends)return{value:null};if(void 0!==y.ends)return{failure:y.ends};const v=new Map,g=new Set,k=new Map,j=new Map;let O=!1,$=()=>{};const A=new Promise(e=>{$=()=>e(yt)});let N=!1;const S=()=>{N?$():O=!0},M=e=>{const t=new x({code:b.operatorFailure,message:"",path:[]});return k.set(t,e),t},P=(t,n)=>r=>{const a=void 0!==n.elementNullPolicy;if("yes"!==Se(z(r),n.type,n.constraints,a)){const n=new x({code:b.typeCheck,message:`${e.name} – parameter '${t}': fails its type check`,path:[]});throw j.set(n,t),n}return n.truthiness?De(r,n.type):r},F=e=>t=>e.truthiness?s(t):t,E=(e,t)=>{void 0!==e&&l(e);const n=void 0===e?lt:r.get(e);if("unknown"in n){const t=new Promise(()=>{});return void 0!==e&&v.set(t,e),S(),t}if("fails"in n)return ht(M(e));try{return Promise.resolve(t(n.value))}catch(e){return ht(e)}},q=e=>{let t;const n={evaluate:()=>t??=e()};return g.add(n),n},D=(e,t)=>{const n=({index:e,child:n,value:a})=>{if(void 0===n)return{index:e,ok:!0,value:t(a)};l(n);const o=r.get(n);if("fails"in o)return{index:e,ok:!1,error:M(n)};try{return{index:e,ok:!0,value:t(o.value)}}catch(t){return{index:e,ok:!1,error:t}}},a=e=>void 0!==e.child&&"unknown"in r.get(e.child),o={length:e.length,async*[Symbol.asyncIterator](){for(const t of e)a(t)||(yield n(t));e.some(a)&&(S(),await ft)}};return g.add(o),o},J=(e,t)=>{const n=F(t);switch(t.evaluation){case"lazyElements":return e.map(e=>q(()=>Promise.resolve(n(e))));case"race":return D(e.map((e,t)=>({index:t,value:e})),n);case"lazyEntries":{const t={};for(const[r,a]of Object.entries(e))t[r]=q(()=>Promise.resolve(n(a)));return t}case"lazy":return q(()=>Promise.resolve(e));default:return e}},B=new Map;for(const e of r.keys())B.set(e.param,[...B.get(e.param)??[],e]);const I={};for(const[e,t]of Object.entries(m)){if("perElement"===t.evaluation||void 0!==t.replacesNullAt)continue;const n=B.get(e);if(void 0!==n){const r=F(t);if("lazy"===t.evaluation)I[e]=q(()=>E(n[0],P(e,t)));else if("race"===t.evaluation)I[e]=D(n.map((e,t)=>({index:t,child:e})),r);else if("lazyElements"===t.evaluation)I[e]=n.map(e=>q(()=>E(e,r)));else{const t={};for(const e of n)t[String(e.at)]=q(()=>E(e,r));I[e]=t}continue}const r=y.received[e];if(void 0===r)continue;const a=L(r);if(void 0===a||1!==a.length)return;I[e]=J(a[0],t)}for(const[t,n]of p.resolution.perElement){if(void 0===e.params[t]||void 0===n.over)continue;const r=B.get(t)??[],a=I[n.over],s=Array.isArray(a)?a:[],i=1===r.length&&void 0===r[0].at;if(!i&&r.length!==s.length)return;const c=e=>r[i?e>=0&&e<s.length?0:-1:e],u=P(t,n),l=new Map,p={evaluate:e=>{let t=l.get(e);return void 0===t&&l.set(e,t=E(c(e),u)),t},settle:()=>{const e=s.map((e,t)=>({index:t,child:c(t)}));for(const{child:t}of e)o.add(t);return D(e,u)}};g.add(p),I[t]=p}const C={options:a.evaluation,get signal(){return(new AbortController).signal},cache:vt,trace:gt},T=t=>{const n=k.get(t);if(void 0!==n)return{escaped:n};if(w(t))return h(t.code,t.message,j.get(t));const r=`${e.name} – ${t instanceof Error?t.message:String(t)}`;return h((u(t)?t.code:void 0)??b.operatorFailure,r)};let R;try{R=p.evaluate(I,C)}catch(e){return T(e)}if(W=R,"function"==typeof W?.then){const e=v.get(R);if(void 0!==e)return{passed:e};if(O)return;N=!0;const t=setTimeout(()=>{c.add(p),$()},100),n=await Promise.race([Promise.resolve(R).then(e=>({value:e}),e=>({error:e})),A]);if(clearTimeout(t),n===yt)return;if("error"in n)return T(n.error);R=n.value}var W;return void 0===R?{value:null}:"number"!=typeof R||Number.isFinite(R)?g.has(R)?h(b.escapedHandle,`${e.name} – returned a lazy handle instead of evaluating it`):{value:R}:h(b.nonFiniteResult,`${e.name} – produced a non-finite number (${String(R)})`)},wt=(e,t)=>void 0===t?e.scope:{vars:t,at:e,known:new Map},xt={verdict:"no",escapes:[],output:F},kt={result:xt,covered:[]},jt=[{type:"integer",min:0}],Ot=z(null),$t=[{type:"object"}],At=se(Object.fromEntries(Object.entries(k).map(([e,t])=>[e,D(t)]))),Nt=e=>{if(0===e.length)return $t;const{value:t,found:n}=ie(At,e);return"yes"===n?t:H(t,Ot)},St=({value:e,reads:t=[]},n=0)=>{if(0===t.length)return z(e);const r=t.find(({at:e})=>e.length===n);if(void 0!==r)return Nt(r.segments);const a=e,o=e=>St({value:a[e],reads:t.filter(({at:t})=>t[n]===e)},n+1);return Array.isArray(e)?re(e.map((e,t)=>o(t))):se(Object.fromEntries(Object.keys(a).map(e=>[e,o(e)])))},Mt=(e,t)=>{for(const n of t)e.push(n)},Pt=(e,t,n)=>{const r=[...e];for(const e of t)Mt(r,e.result.escapes);const a=t.some(e=>e.result.waits);return t.some(e=>e.eager&&"always"===e.result.verdict)||e.some(e=>!j(e)&&"always"===e.certainty)?{verdict:"always",escapes:r,output:F,waits:a}:{verdict:r.length>0?"may":"no",escapes:r,output:n,waits:a}},Ft=e=>`${e.order}|${e.code}|${e.parameter}`,Et=e=>{const t=e.map(e=>new Set([...e.result.escapes,...e.covered.map(({pending:e})=>e)].filter(e=>!j(e)&&"always"===e.certainty).map(e=>Ft(e)))),n=e=>j(e)||"may"===e.certainty||t.every(t=>t.has(Ft(e)))?e:{...e,certainty:"may"};for(const t of e)t.result={...t.result,escapes:t.result.escapes.map(n)},t.covered=t.covered.map(({pending:e,by:t})=>({pending:n(e),by:t}))};class zt{options;bodies=new Map;stalled=new Set;waiting=new Set;strict;constructor(e){this.options=e,this.strict=!0===e.evaluation.strictDataPaths}root(e,t){return this.walk(e,{scope:null,bindings:null,sink:t,frame:{},walks:1})}async walk(e,t){const n=await this.visit(e,t);return n.waits&&this.waiting.add(e),n}async visit(e,t){switch(e.kind){case"constant":return{...xt,output:z(e.value)};case"invalid":throw Lt("an invalid node");case"reference":return this.reference(e,t);case"skeleton":{const n={...t,scope:wt(t,e.vars)},r=[];for(const t of e.holes)r.push({result:await this.walk(t.node,n),eager:!0});const a=((e,t)=>{if(t.every(e=>1===e.length&&"exact"in e[0]))return z(m(e.skeleton,e.holes,t.map(e=>e[0].exact)));const n=e.holes.map((e,n)=>({at:e.at,output:t[n]})),r=(e,t,n)=>{const a=n.find(e=>e.at.length===t);if(void 0!==a)return a.output;if(0===n.length)return z(e);const o=new Map;for(const e of n){const n=o.get(e.at[t]);void 0===n?o.set(e.at[t],[e]):n.push(e)}const s=e=>o.get(e)??[];if(Array.isArray(e))return re(Array.from(e,(e,n)=>r(e,t+1,s(n))));const i=e,c=new Set([...Object.keys(i),...n.map(e=>String(e.at[t]))]),u={};for(const e of c)u[e]=r(i[e],t+1,s(e));return se(u)};return r(e.skeleton,0,n)})(e,r.map(e=>e.result.output));return Pt([],r,a)}case"elements":case"entries":{const n=[],r=await this.container("",e,t,n);for(const e of n)Mt(t.sink,e.covered);const a=n.map(({result:e})=>({result:e,eager:!1}));return Pt([],a,r)}case"operator":return this.operator(e,t);case"fragmentCall":return this.call(e,t)}return e}async operator(e,t){const{definition:n}=e.entry,r={...t,scope:wt(t,e.vars)},a={},o=[],s=[];for(const[t,i]of Object.entries(e.params)){const e=n.parameters[t]?.evaluation;if("perElement"!==e)if("elements"===i.kind||"entries"===i.kind)a[t]=await this.container(t,i,r,s);else if("lazy"===e){const e=await this.apart(t,i,r);a[t]=e.result.output,s.push(e)}else{const e=await this.walk(i,r);a[t]=e.output,o.push({result:e,eager:!0})}}const i=Le(e,a),c=l(e),u={},p={};for(const[a,o]of n.resolution.perElement){const n=e.params[a];if(void 0===n||void 0===o.over)continue;const l=i.received[o.over]??F,m=L(l),d=1===m?.length&&Array.isArray(m[0])?m[0]:void 0,y=t.walks*(d?.length??1/0);if(y<=16){const e=[];for(const[o,i]of Array.from(d).entries()){const u={as:c,element:z(i),index:z(o),parent:t.bindings},l=await this.apart(a,n,{...r,bindings:u,walks:y},o);s.push(l),e.push(l.result.output)}p[a]=e,u[a]=W(e)}else{const e={as:c,element:te(l),index:jt,parent:t.bindings},o=await this.apart(a,n,{...r,bindings:e});s.push(o),u[a]=o.result.output}}const m=o.some(e=>"always"===e.result.verdict)?{output:F,failures:[],reached:new Set(s.filter(e=>"race"===n.parameters[e.param].evaluation)),awaited:new Set,escaped:new Set,passed:new Set,fails:!0}:"external"===Qe(n)?void 0:await mt(e,a,s,this.options,this.stalled);for(const e of Object.keys(p))Et(s.filter(t=>t.param===e&&(m?.reached.has(t)??!0)));const d=[];void 0===m?(Mt(d,i.failures),"yes"!==i.propagates&&Mt(d,((e,t,n)=>{const r=Qe(e.entry.definition),a={path:e.path,operator:e.name,order:[e.order]};if("external"===r)return[{...a,code:Re,message:`${e.name} – may fail whatever its inputs: nothing describes what it fails on`,certainty:"may"}];const o=[];for(const s of r){const r=tt(e,s,t,n);"no"!==r&&o.push({...a,code:s.code,message:et(e.name,s),certainty:"yes"!==r||s.may||s.overflow||"no"!==t.propagates?"may":"always",...void 0!==s.parameter?{parameter:s.parameter}:{}})}return o})(e,i,this.options))):Mt(d,m.failures);for(const t of s){if(void 0!==m&&!m.passed.has(t))continue;const r=n.parameters[t.param];if("perElement"===r.evaluation){const n=Ie(e,t.param,r,t.result.output);void 0!==n&&d.push(n)}else void 0!==m&&void 0===t.at&&Mt(d,i.failures.filter(e=>e.parameter===t.param))}const{output:y,boundary:f}=void 0===m?it(e,i,u,this.options.strictNumbers,p):ct(e,m.output,this.options.strictNumbers,!1);void 0===f||d.some(e=>!j(e)&&e.code===f.code)||d.push(f);for(const e of s){if(void 0!==m&&!m.reached.has(e))continue;Mt(t.sink,e.covered);const n=void 0===m||m.escaped.has(e)?e.result.escapes:e.result.escapes.filter(j),r=e.result.waits&&(m?.awaited.has(e)??!0);o.push({result:{...e.result,escapes:n,waits:r},eager:!1})}const h=Pt(d,o,y);return!0===m?.fails&&Object.assign(h,{verdict:"always",output:F}),(e=>void 0!==e.analysis||"external"===Qe(e))(n)&&(h.waits=!0),this.withFallback(e,h,r)}async apart(e,t,n,r){const a=[];return{param:e,...void 0!==r?{at:r}:{},result:await this.walk(t,{...n,sink:a}),covered:a}}async container(e,t,n,r){if("elements"===t.kind){const a=[];for(const[o,s]of t.nodes.entries()){const t=await this.apart(e,s,n,o);r.push(t),a.push(t.result.output)}return re(a)}const a={...n,scope:wt(n,t.vars)},o={};for(const[n,s]of Object.entries(t.entries)){const t=await this.apart(e,s,a,n);r.push(t),o[n]=t.result.output}return se(o)}async withFallback(e,t,n){if("no"===t.verdict)return t;const r="operator"===e.kind?e.entry.defaultFallback:void 0;if(void 0===e.fallback&&void 0===r)return t;const a={path:e.path};for(const e of t.escapes)n.sink.push({pending:e,by:a});const{waits:o}=t;if(void 0===e.fallback)return{...xt,output:H(t.output,St(r)),waits:o};const s=await this.walk(e.fallback,n);if(e.fallbackReadsError&&"no"!==s.verdict){const r={path:e.path,givesNull:!0};for(const e of s.escapes)n.sink.push({pending:e,by:r});return{...xt,output:H(t.output,s.output,Ot),waits:o||s.waits}}return{verdict:"always"===t.verdict||"always"!==s.verdict?s.verdict:"may",escapes:s.escapes,output:H(t.output,s.output),waits:o||s.waits}}async reference(e,t){const{segments:n,namespace:r}=e;switch(r){case"data":return this.drilled(e,E,n,[],[]);case"element":case"index":for(let a=t.bindings;null!==a;a=a.parent)if(p(a.as,r,e.binding))return"index"===r?{...xt,output:a.index}:this.drilled(e,a.element,n,[],[]);throw Lt(`an unresolved '${e.raw}'`);case"vars":{const r=await this.varDefinition(n[0],t);if(void 0===r)throw Lt(`an unresolved '${e.raw}'`);Mt(t.sink,r.covered);const a=[{result:r.result,eager:!0}];return this.drilled(e,r.result.output,n.slice(1),a,[])}case"params":{const{entry:r,params:a={}}=t.frame;if(void 0===r)throw Lt(`'${e.raw}' outside a fragment body`);const[o,...s]=n;if(void 0===o){const t=Object.keys(r.parameters).map(e=>({demand:e}));return this.drilled(e,se(a),[],[],t)}const i="string"==typeof o?a[o]??E:E;return this.drilled(e,i,s,[],[{demand:String(o)}])}case"error":return{...xt,output:Nt(n)}}return r}drilled(e,t,n,r,a){const{value:o,found:s}=ie(t,n);if("yes"===s)return Pt(a,r,o);if(!this.strict)return Pt(a,r,H(o,Ot));const i={path:e.path,code:"missing-data-path",message:`'${e.raw}' may be absent (strictDataPaths)`,certainty:"no"===s?"always":"may",order:[e.order]};return Pt([...a,i],r,o)}async varDefinition(e,t){for(let n=t.scope;null!==n;n=n.at.scope){if("string"!=typeof e||!Object.hasOwn(n.vars,e))continue;const t=n.known.get(e);if(void 0!==t)return t;n.known.set(e,{result:{...xt,output:E},covered:[]});const r=[],a={result:await this.walk(n.vars[e],{...n.at,scope:n,sink:r}),covered:r};return n.known.set(e,a),a}}async call(e,t){const{entry:n}=e;if(void 0===n)throw Lt(`a call to the unknown fragment '${e.name}'`);const r={...t,scope:wt(t,e.vars)},a=[],o=[],s={},i=new Map;if("static"===e.argumentsMode)for(const[t,a]of Object.entries(n.parameters)){const n=await this.argument(e,t,a,r);i.set(t,n),s[t]=n.result.output}else{const t=e.parameters,i=await this.walk(t,r);o.push({result:i,eager:!0}),Mt(a,Dt(e,n,t,s))}let c=!1;const u=e=>{const n=i.get(e)??kt;return Mt(t.sink,n.covered),c||=!0===n.result.waits,n},l=await this.body(n,s);for(const{pending:n,by:r}of l.covered){const a=$(r,e);if(j(n))for(const e of u(n.demand).result.escapes)t.sink.push({pending:e,by:a});else t.sink.push({pending:O(n,e),by:a})}const p=[];for(const t of l.result.escapes)j(t)?Mt(p,u(t.demand).result.escapes):p.push(O(t,e));return o.push({result:{...l.result,escapes:[]},eager:!0},{result:{...xt,escapes:p,waits:c},eager:!1}),this.withFallback(e,Pt(a,o,l.result.output),r)}async argument(e,t,n,r){const a=e.parameters?.[t];if(void 0===a)return{result:{...xt,output:z(n.default??null)},covered:[]};const o=[],s=await this.walk(a,{...r,sink:o}),{known:i,answer:c}=Be(n,s.output),u="yes"===c?[]:[qt(e,t,a.path,a.order)];return{result:Pt(u,[{result:s,eager:!0}],i),covered:o}}async body(e,t){const n=Object.keys(t).map(e=>`${e}=${T(t[e])}`).join(";");let r=this.bodies.get(e);void 0===r&&this.bodies.set(e,r=new Map);const a=r.get(n);if(void 0!==a)return a;r.set(n,{result:{...xt,output:E},covered:[]});const o=[],s={entry:e,params:t},i={result:await this.walk(e.body,{scope:null,bindings:null,sink:o,frame:s,walks:1}),covered:o};return r.set(n,i),i}}const Lt=e=>new Error(`[fig-tree internal] ${e} reached the coverage walk — the static gate should have refused it`),qt=(e,t,n,r)=>({path:n,code:"type-check",message:`fragment '${e.name}' – parameter '${t}': the argument may not fit the declared type`,certainty:"may",parameter:t,order:[r]}),Dt=(e,t,n,r)=>{const a=(t,r)=>({path:n.path,code:t,message:`fragment '${e.name}' – ${r}`,certainty:"may",order:[n.order]}),o=Object.entries(t.parameters);for(const[e,t]of o)r[e]=Be(t,E).known;const s=[a("type-check","'parameters' may not match the declared parameters")];return o.some(([,e])=>e.required)&&s.push(a("missing-required","'parameters' may omit a required parameter")),s},Jt=async(e,t,n)=>{if(!(e instanceof d))throw new TypeError("fallbackCoverage() takes a FigTree instance");const r=n?.strictNumbers??!1;if("boolean"!=typeof r)throw new x({code:b.invalidOptions,message:`'strictNumbers' must be a boolean, received ${JSON.stringify(r)}`,path:[]});const{artifact:a,options:o}=y(e.compile(t)),s=f(a,o).filter(e=>"error"===e.severity);if(s.length>0)return{uncovered:s.map(N),covered:[]};const i=new zt({strictNumbers:r,evaluation:o}),c=[],{escapes:u,waits:l}=await i.root(a.root,c),p=u.filter(e=>!j(e)).map(M);if(void 0!==o.timeout&&l)for(const{node:e,timeoutFallback:t}of a.holes){const n={path:e.path,code:"timeout",certainty:"may",order:[e.order]};a.timeoutShielded?i.waiting.has(e)&&c.push({pending:{...n,message:"may be cut off by the timeout, which puts its static fallback in its place"},by:{path:e.path}}):void 0===t&&p.push(M({...n,message:"the timeout may reject the evaluation: something in it can wait, and this value has no static fallback to shield it"}))}const m=c.flatMap(({pending:e,by:t})=>j(e)?[]:[P(e,t)]);return{uncovered:S(p),covered:S(m)}};export{Jt as fallbackCoverage};
|
package/build/catalog/index.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ interface FragmentInfo {
|
|
|
127
127
|
declare class FigTree<InstanceOpts extends FigTreeOptions = NoOptions> {
|
|
128
128
|
private state;
|
|
129
129
|
private readonly results;
|
|
130
|
-
readonly version = "3.0.0-preview.
|
|
130
|
+
readonly version = "3.0.0-preview.14";
|
|
131
131
|
constructor(options?: InstanceOpts);
|
|
132
132
|
private static fromState;
|
|
133
133
|
updateOptions(options?: OptionsUpdate): void;
|
|
@@ -479,7 +479,10 @@ type TypeSeeds = {
|
|
|
479
479
|
interface CatalogCategory extends CategoryListing {
|
|
480
480
|
name: OperatorCategory;
|
|
481
481
|
}
|
|
482
|
+
type NullOutcome = 'propagate' | 'value' | 'unset' | 'error' | 'none';
|
|
482
483
|
interface CatalogParameter extends ParameterInfo {
|
|
484
|
+
nullOutcome: NullOutcome | CompiledNullPolicy;
|
|
485
|
+
elementNullOutcome?: NullPolicyValue | 'error';
|
|
483
486
|
description?: string;
|
|
484
487
|
seed: unknown;
|
|
485
488
|
}
|
package/build/catalog/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={logic:{displayName:"Logic & control",order:0,backgroundColor:"#632fbc",textColor:"#ffffff"},comparison:{displayName:"Comparison",order:1,backgroundColor:"#247f7c",textColor:"#ffffff"},math:{displayName:"Arithmetic & math",order:2,backgroundColor:"#2b8237",textColor:"#ffffff"},string:{displayName:"Strings",order:3,backgroundColor:"#a1660c",textColor:"#ffffff"},array:{displayName:"Arrays & iteration",order:4,backgroundColor:"#236ac7",textColor:"#ffffff"},data:{displayName:"Data & objects",order:5,backgroundColor:"#b93171",textColor:"#ffffff"},io:{displayName:"I/O",order:6,backgroundColor:"#6e7a24",textColor:"#ffffff"},other:{displayName:"Other",order:7,backgroundColor:"#606e8a",textColor:"#ffffff"}},a={any:"Replace me",string:"Replace me",number:1,integer:1,boolean:!0,array:[],object:{},null:null},r="https://github.com/CarlosNZ/fig-tree-evaluator",t={and:{displayName:"Logical AND",description:"True when every value is truthy — operands run in parallel",docUrl:r,backgroundColor:"#d6d0f0",textColor:"#26183f",seeds:{values:[!0,!0]},parameterDescriptions:{values:"Operands, judged by FigTree truthiness; null is falsy"}},or:{displayName:"Logical OR",description:"True when any value is truthy — operands run in parallel",docUrl:r,backgroundColor:"#cabfeb",textColor:"#26183f",seeds:{values:[!0,!1]},parameterDescriptions:{values:"Operands, judged by FigTree truthiness; null is falsy"}},not:{displayName:"Logical NOT (!)",description:"Negate the truthiness of a value",docUrl:r,backgroundColor:"#c0aee5",textColor:"#26183f",seeds:{value:!0},parameterDescriptions:{value:"Judged by FigTree truthiness; null is falsy, so not(null) is true"}},if:{displayName:"Conditional (?)",description:"Choose between two branches — only the chosen branch evaluates",docUrl:r,backgroundColor:"#ddd0f0",textColor:"#26183f",seeds:{condition:!0,then:"The condition is true",else:"The condition is false"},parameterDescriptions:{condition:"Judged by FigTree truthiness; null is falsy",then:"The value when the condition holds",else:"The value when it does not; omitted means null"}},match:{displayName:"Match",description:"Dispatch on a value — only the matching branch evaluates",docUrl:r,backgroundColor:"#d4bfeb",textColor:"#26183f",seeds:{value:"matchMe",branches:{matchMe:"YES",nonMatch:"NO"},default:"No match"},parameterDescriptions:{value:"Matched against branch keys by its canonical string form",branches:"A literal map of branches, or an expression computing one",default:"The branch taken when none matches; absent means failure"}},firstOf:{displayName:"First non-null",description:"The first candidate that is not null (SQL COALESCE) — later candidates never evaluate",docUrl:r,backgroundColor:"#ccaee5",textColor:"#26183f",seeds:{values:[null,"The first non-null value"]},parameterDescriptions:{values:"Candidates, tried in order; only null is skipped"}},equal:{displayName:"Equal (=)",description:"Are all the values equal? Deep, structural, key-order-insensitive; a cross-type comparison is false",docUrl:r,backgroundColor:"#d2efe9",textColor:"#183f3e",seeds:{values:["These are equal","These are equal"]},parameterDescriptions:{values:"The values compared; null is comparable (null equals null)",caseInsensitive:"Fold string operands to one case before comparing (shallow)"}},notEqual:{displayName:"Not equal (!=)",description:'Are the values NOT all equal? The exact negation of equal (never "all distinct")',docUrl:r,backgroundColor:"#c1e9e3",textColor:"#183f3e",seeds:{values:["These items","don't match"]},parameterDescriptions:{values:"The values compared; null is comparable (null equals null)",caseInsensitive:"Fold string operands to one case before comparing (shallow)"}},greaterThan:{displayName:"Greater than (>)",description:"Is the first value strictly greater than the second?",docUrl:r,backgroundColor:"#b0e3e0",textColor:"#183f3e",seeds:{values:[10,9]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},greaterThanOrEqual:{displayName:"Greater than or equal (>=)",description:"Is the first value greater than or equal to the second?",docUrl:r,backgroundColor:"#d2efef",textColor:"#183f3e",seeds:{values:[10,10]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},lessThan:{displayName:"Less than (<)",description:"Is the first value strictly less than the second?",docUrl:r,backgroundColor:"#c1e6e9",textColor:"#183f3e",seeds:{values:[9,10]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},lessThanOrEqual:{displayName:"Less than or equal (<=)",description:"Is the first value less than or equal to the second?",docUrl:r,backgroundColor:"#b0dbe3",textColor:"#183f3e",seeds:{values:[9,9]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},plus:{displayName:"Plus (+)",description:"Add numbers, concatenate strings or arrays, or shallow-merge objects — all operands must share one type",docUrl:r,backgroundColor:"#d7edd4",textColor:"#193e1e",seeds:{values:[1,2,3]},parameterDescriptions:{values:"The operands; homogeneous: all numbers, strings, arrays or objects",expect:"Pin the mode: every operand must be this type, and an empty input yields its identity",nullValueDefault:"Replaces any null operand before the addition"}},subtract:{displayName:"Subtract (-)",description:"Subtract one number from another",docUrl:r,backgroundColor:"#bfe4bc",textColor:"#193e1e",seeds:{value:10,minus:5},parameterDescriptions:{value:"The main operand",minus:"The amount subtracted from value"}},multiply:{displayName:"Multiply (*)",description:"Multiply numbers together — an empty input is 1, the empty product",docUrl:r,backgroundColor:"#b4e0b3",textColor:"#193e1e",seeds:{values:[5,5]},parameterDescriptions:{values:"The factors",nullValueDefault:"Replaces any null factor before multiplying"}},divide:{displayName:"Divide (/)",description:"Divide one number by another — true division; zero divisors fail",docUrl:r,backgroundColor:"#cceacd",textColor:"#193e1e",seeds:{value:100,by:10},parameterDescriptions:{value:"The main operand",by:"The divisor"}},modulo:{displayName:"Modulo",description:"The floored remainder: the result takes the sign of mod, so modulo(-7, 3) is 2",docUrl:r,backgroundColor:"#c3e7c6",textColor:"#193e1e",seeds:{value:10,mod:3},parameterDescriptions:{value:"The main operand",mod:"The modulus"}},power:{displayName:"Power (^)",description:"Raise a base to an exponent — overflow and complex results fail",docUrl:r,backgroundColor:"#acddb1",textColor:"#193e1e",seeds:{base:2,exponent:3},parameterDescriptions:{base:"The number to raise",exponent:"The power to raise it to"}},round:{displayName:"Round",description:"Round to a number of decimal places — ties go half away from zero; negative decimals round to tens, hundreds, …",docUrl:r,backgroundColor:"#d4edd8",textColor:"#193e1e",seeds:{value:3.14159,decimals:2},parameterDescriptions:{value:"The number to round",decimals:"Decimal places to keep; negative values round to powers of ten"}},floor:{displayName:"Round down",description:"Round down toward negative infinity",docUrl:r,backgroundColor:"#bce4c4",textColor:"#193e1e",seeds:{value:2.7},parameterDescriptions:{value:"The number to round down"}},ceil:{displayName:"Round up",description:"Round up toward positive infinity",docUrl:r,backgroundColor:"#b3e0be",textColor:"#193e1e",seeds:{value:2.3},parameterDescriptions:{value:"The number to round up"}},abs:{displayName:"Absolute value",description:"The absolute value",docUrl:r,backgroundColor:"#ccead5",textColor:"#193e1e",seeds:{value:-5},parameterDescriptions:{value:"The number"}},min:{displayName:"Minimum",description:"The smallest of the values — numbers numerically, strings in codepoint order",docUrl:r,backgroundColor:"#c3e7cf",textColor:"#193e1e",seeds:{values:[3,1,2]},parameterDescriptions:{values:"The candidates: all numbers, or all strings (codepoint order)",nullValueDefault:"Replaces any null candidate before comparing"}},max:{displayName:"Maximum",description:"The largest of the values — numbers numerically, strings in codepoint order",docUrl:r,backgroundColor:"#acddbf",textColor:"#193e1e",seeds:{values:[3,1,2]},parameterDescriptions:{values:"The candidates: all numbers, or all strings (codepoint order)",nullValueDefault:"Replaces any null candidate before comparing"}},buildString:{displayName:"String builder",description:"Render a template, filling its tokens — the result is always a string",docUrl:r,backgroundColor:"#f8d9c9",textColor:"#3f2f18",seeds:{template:"Hello {{$data.name}}"},parameterDescriptions:{template:"The text, with %N or {{name}} tokens; in a literal template, {{$data.x}} is that reference",substitutions:"An array pairs with %N tokens, an object with {{name}} tokens; the mode dispatches on which arrives",trim:"Trim whitespace from each rendered value, never from the template text",closeGaps:"A value that renders empty also takes one run of adjacent template whitespace",nullValueDefault:'Rendered in place of a null value, instead of ""'}},split:{displayName:"Split text",description:"Divide a string on a delimiter into an array of pieces — empty pieces are kept; an empty delimiter splits into code points",docUrl:r,backgroundColor:"#f5cbab",textColor:"#3f2f18",seeds:{value:"Alpha, Bravo, Charlie",delimiter:",",trim:!1},parameterDescriptions:{value:"The string to divide",delimiter:'Split on each occurrence; "" splits into code points',trim:"Trim whitespace from each piece"}},join:{displayName:"Join text",description:"Render array elements to text and concatenate them with a delimiter",docUrl:r,backgroundColor:"#f3cba0",textColor:"#3f2f18",seeds:{values:["Alpha","Bravo","Charlie"],delimiter:", "},parameterDescriptions:{values:'Elements of any type, rendered by the stringification table; a null renders "" and still occupies its slot',delimiter:"Placed between each adjacent pair — shares its contract with split",nullValueDefault:'Rendered in place of a null element, instead of ""'}},lower:{displayName:"Lower case",description:"Lowercase a string — Unicode default case mapping, locale-independent",docUrl:r,backgroundColor:"#f7e1bf",textColor:"#3f2f18",seeds:{value:"Hello World"},parameterDescriptions:{value:"The string to lowercase"}},upper:{displayName:"Upper case",description:"Uppercase a string — Unicode default case mapping, locale-independent",docUrl:r,backgroundColor:"#f6e1b4",textColor:"#3f2f18",seeds:{value:"Hello World"},parameterDescriptions:{value:"The string to uppercase"}},trim:{displayName:"Trim whitespace",description:"Strip whitespace (the JS trim set) from both ends of a string",docUrl:r,backgroundColor:"#f2dd97",textColor:"#3f2f18",seeds:{value:" Hello World "},parameterDescriptions:{value:"The string to trim"}},regex:{displayName:"Regular expression",description:"Test, extract or match a string against a regular expression",docUrl:r,backgroundColor:"#f8f1c9",textColor:"#3f2f18",seeds:{value:"test-this",pattern:"^[a-z]{4}-[a-z]{4}$",flags:"i"},parameterDescriptions:{value:"The subject string",pattern:"The regular expression source",flags:"The admitted subset: i, m, s, u",mode:"test gives a boolean, extract the first matching substring, match every one of them",noMatchDefault:"The extract answer when nothing matches — a matched empty string still passes through"}},length:{displayName:"Length",description:"An array's element count, or a string's Unicode code-point count",docUrl:r,backgroundColor:"#cde5f3",textColor:"#18293f",seeds:{value:[1,2,3,4,5]},parameterDescriptions:{value:"The array or string measured"}},map:{displayName:"Map each",description:"Transform every element of an array",docUrl:r,backgroundColor:"#bbd7ef",textColor:"#18293f",seeds:{input:[1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"Evaluated per element, with $element and $index bound"}},filter:{displayName:"Filter",description:"Keep the elements of an array whose predicate is truthy",docUrl:r,backgroundColor:"#a8c7eb",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},find:{displayName:"Find first",description:"The first element of an array whose predicate is truthy",docUrl:r,backgroundColor:"#cddcf3",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy",noMatchDefault:"The answer when nothing matches; a found null passes through unchanged"}},some:{displayName:"Any match",description:"True when any element satisfies the predicate",docUrl:r,backgroundColor:"#bbccef",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},every:{displayName:"All match",description:"True when every element satisfies the predicate",docUrl:r,backgroundColor:"#a8b9eb",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},get:{displayName:"Get data",description:"Read a path out of the evaluation data, or out of a supplied object — the dynamic face of a $data reference",docUrl:r,backgroundColor:"#f0d1e5",textColor:"#3f182a",seeds:{path:"path.to.value",from:{path:{to:{value:"Found it"}}},default:"Not found"},parameterDescriptions:{path:"Dot and bracket segments, quoted keys and the [*] projection — or an array of segments, taken verbatim",from:"The source the path reads: a value, or a bare namespace ($data, $vars, $params, $element) whose var or parameter name opens the path — replace, never merge; a null source misses every path",default:"The answer when the path is missing — a stored null passes through unchanged (firstOf replaces one); supplying it also opts out of strictDataPaths"}},buildObject:{displayName:"Build object",description:"Assemble an object from computed key/value entries — for keys known only at runtime",docUrl:r,backgroundColor:"#eac0cc",textColor:"#3f182a",seeds:{entries:[{key:"firstKey",value:"firstValue"},{key:"secondKey",value:"secondValue"}]},parameterDescriptions:{entries:'Objects with a "key" and a "value"; a null value keeps its key'}},convert:{displayName:"Convert type",description:"Convert a value to a number, string, boolean or array — strict: a failed conversion is an error, never a guess",docUrl:r,backgroundColor:"#dddfe3",textColor:"#272a30",seeds:{value:"42"},parameterDescriptions:{value:"The value to convert; null propagates except for boolean, where it is false",to:"The target type"}},http:{displayName:"HTTP request",description:"One HTTP request — GET or POST — returning the parsed JSON response",docUrl:r,backgroundColor:"#eeedd2",textColor:"#3a3f18",seeds:{url:"https://restcountries.com/v3.1/name/zealand",returnPath:"[0].name.common",timeout:5e3},parameterDescriptions:{url:"A full http(s) URL is used verbatim; anything else — including an empty string — joins http.baseEndpoint",method:"Lowercase; the mutating verbs are deliberately absent — an expression is a read",query:"Query-string pairs; a null value omits its pair, a composite one is an error",body:"The JSON payload; a whole-null body means NO body, while nulls inside one are JSON nulls",headers:"Merged over the http.headers option per key; a null value removes an inherited pair",returnPath:"Dot/bracket path or segments array applied to the response; a miss is null",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},graphQL:{displayName:"GraphQL query",description:"One GraphQL query — a POST of { query, variables } — returning the data field",docUrl:r,backgroundColor:"#e3e8c2",textColor:"#3a3f18",seeds:{query:'query getCountries {\n countries(filter: { continent: { eq: "OC" } }) {\n name\n }\n}',url:"https://countries.trevorblades.com/",returnPath:"countries[0].name",timeout:5e3},parameterDescriptions:{query:"The GraphQL document — the protocol’s own word, as sql.query is",variables:"Query variables; a null value is CARRIED as JSON null, a nullable argument being meaningful GraphQL",url:"Per-node endpoint override; unset means the graphQL.endpoint option",headers:"Merged over http.headers then graphQL.headers; a null value removes a pair",returnPath:"Dot/bracket path or segments array applied to the response; a miss is null",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},sql:{displayName:"SQL query",description:"One SQL query against the registered connection. Expressions are READS — give the connection a read-only role and run mutations host-side",docUrl:r,backgroundColor:"#d2e2b1",textColor:"#3a3f18",seeds:{query:"SELECT contact_name FROM customers LIMIT 5",timeout:5e3},parameterDescriptions:{query:"SQL text with the driver’s own placeholders — FigTree never parses SQL",values:"Bind values — positional as an array, named as an object; a null binds SQL NULL",shape:"rows: every row object; firstRow: the first; column: one column’s values; firstValue: one scalar",noRowDefault:"The answer when firstRow / firstValue find no row — never for rows / column, never on failure",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},literal:{displayName:"Literal",docUrl:r,backgroundColor:"#d5dae4",textColor:"#272a30",seeds:{value:"No content inside a literal node is evaluated"}}},o=(e,a)=>void 0!==e&&Object.hasOwn(e,a)?e[a]:void 0,s=e=>void 0!==e.backgroundColor&&void 0!==e.textColor?{backgroundColor:e.backgroundColor,textColor:e.textColor}:void 0,n=(e,r,t)=>void 0!==e.seeds&&Object.hasOwn(e.seeds,r)?e.seeds[r]:"string"==typeof t?a[t]:"literal"in t?t.literal[0]:a[t.find(e=>"null"!==e)??"null"],l=(e,a)=>{for(const[r,t]of Object.entries(a??{}))void 0!==t&&(e[r]=t)},i=(a,...r)=>({categories:Object.entries(e).map(([e,a])=>({name:e,...a})).sort((e,a)=>e.order-a.order),operators:a.getOperators().map(({name:a,parameters:i,...d})=>{const c=(e=>{const a={seeds:{},parameterDescriptions:{}};for(const n of[t,...r]){const r=o(n,e);if(void 0!==r){for(const e of["displayName","description","docUrl"]){const t=r[e];void 0!==t&&(a[e]=t)}Object.assign(a,s(r)),l(a.seeds,r.seeds),l(a.parameterDescriptions,r.parameterDescriptions)}}return a})(a),u={name:a,displayName:c.displayName??a,...d,...s(c)??s(e[d.category]),parameters:{}};void 0!==c.description&&(u.description=c.description),void 0!==c.docUrl&&(u.docUrl=c.docUrl);for(const[e,a]of Object.entries(i)){const r={...a,seed:n(c,e,a.type)},t=o(c.parameterDescriptions,e);void 0!==t&&(r.description=t),u.parameters[e]=r}return u}),fragments:a.getFragments().map(({name:e,parameters:a,...r})=>{const t=r.metadata??{},o={name:e,displayName:t.displayName??e,...r,...s(t),parameters:{}};void 0!==t.docUrl&&(o.docUrl=t.docUrl);for(const[e,r]of Object.entries(a))o.parameters[e]={...r,seed:n(t,e,r.type)};return o})});export{e as categoryListings,i as getCatalog,t as operatorListings,a as typeSeeds};
|
|
1
|
+
const e={logic:{displayName:"Logic & control",order:0,backgroundColor:"#632fbc",textColor:"#ffffff"},comparison:{displayName:"Comparison",order:1,backgroundColor:"#247f7c",textColor:"#ffffff"},math:{displayName:"Arithmetic & math",order:2,backgroundColor:"#2b8237",textColor:"#ffffff"},string:{displayName:"Strings",order:3,backgroundColor:"#a1660c",textColor:"#ffffff"},array:{displayName:"Arrays & iteration",order:4,backgroundColor:"#236ac7",textColor:"#ffffff"},data:{displayName:"Data & objects",order:5,backgroundColor:"#b93171",textColor:"#ffffff"},io:{displayName:"I/O",order:6,backgroundColor:"#6e7a24",textColor:"#ffffff"},other:{displayName:"Other",order:7,backgroundColor:"#606e8a",textColor:"#ffffff"}},a={any:"Replace me",string:"Replace me",number:1,integer:1,boolean:!0,array:[],object:{},null:null},r="https://github.com/CarlosNZ/fig-tree-evaluator",t={and:{displayName:"Logical AND",description:"True when every value is truthy — operands run in parallel",docUrl:r,backgroundColor:"#d6d0f0",textColor:"#26183f",seeds:{values:[!0,!0]},parameterDescriptions:{values:"Operands, judged by FigTree truthiness; null is falsy"}},or:{displayName:"Logical OR",description:"True when any value is truthy — operands run in parallel",docUrl:r,backgroundColor:"#cabfeb",textColor:"#26183f",seeds:{values:[!0,!1]},parameterDescriptions:{values:"Operands, judged by FigTree truthiness; null is falsy"}},not:{displayName:"Logical NOT (!)",description:"Negate the truthiness of a value",docUrl:r,backgroundColor:"#c0aee5",textColor:"#26183f",seeds:{value:!0},parameterDescriptions:{value:"Judged by FigTree truthiness; null is falsy, so not(null) is true"}},if:{displayName:"Conditional (?)",description:"Choose between two branches — only the chosen branch evaluates",docUrl:r,backgroundColor:"#ddd0f0",textColor:"#26183f",seeds:{condition:!0,then:"The condition is true",else:"The condition is false"},parameterDescriptions:{condition:"Judged by FigTree truthiness; null is falsy",then:"The value when the condition holds",else:"The value when it does not; omitted means null"}},match:{displayName:"Match",description:"Dispatch on a value — only the matching branch evaluates",docUrl:r,backgroundColor:"#d4bfeb",textColor:"#26183f",seeds:{value:"matchMe",branches:{matchMe:"YES",nonMatch:"NO"},default:"No match"},parameterDescriptions:{value:"Matched against branch keys by its canonical string form",branches:"A literal map of branches, or an expression computing one",default:"The branch taken when none matches; absent means failure"}},firstNonNull:{displayName:"First non-null",description:"The first candidate that is not null (SQL COALESCE) — later candidates never evaluate",docUrl:r,backgroundColor:"#ccaee5",textColor:"#26183f",seeds:{values:[null,"The first non-null value"]},parameterDescriptions:{values:"Candidates, tried in order; only null is skipped"}},equal:{displayName:"Equal (=)",description:"Are all the values equal? Deep, structural, key-order-insensitive; a cross-type comparison is false",docUrl:r,backgroundColor:"#d2efe9",textColor:"#183f3e",seeds:{values:["These are equal","These are equal"]},parameterDescriptions:{values:"The values compared; null is comparable (null equals null)",caseInsensitive:"Fold string operands to one case before comparing (shallow)"}},notEqual:{displayName:"Not equal (!=)",description:'Are the values NOT all equal? The exact negation of equal (never "all distinct")',docUrl:r,backgroundColor:"#c1e9e3",textColor:"#183f3e",seeds:{values:["These items","don't match"]},parameterDescriptions:{values:"The values compared; null is comparable (null equals null)",caseInsensitive:"Fold string operands to one case before comparing (shallow)"}},greaterThan:{displayName:"Greater than (>)",description:"Is the first value strictly greater than the second?",docUrl:r,backgroundColor:"#b0e3e0",textColor:"#183f3e",seeds:{values:[10,9]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},greaterThanOrEqual:{displayName:"Greater than or equal (>=)",description:"Is the first value greater than or equal to the second?",docUrl:r,backgroundColor:"#d2efef",textColor:"#183f3e",seeds:{values:[10,10]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},lessThan:{displayName:"Less than (<)",description:"Is the first value strictly less than the second?",docUrl:r,backgroundColor:"#c1e6e9",textColor:"#183f3e",seeds:{values:[9,10]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},lessThanOrEqual:{displayName:"Less than or equal (<=)",description:"Is the first value less than or equal to the second?",docUrl:r,backgroundColor:"#b0dbe3",textColor:"#183f3e",seeds:{values:[9,9]},parameterDescriptions:{values:"Exactly two operands: both numbers, or both strings (codepoint order)",nullValueDefault:"Replaces a null operand before comparing"}},plus:{displayName:"Plus (+)",description:"Add numbers, concatenate strings or arrays, or shallow-merge objects — all operands must share one type",docUrl:r,backgroundColor:"#d7edd4",textColor:"#193e1e",seeds:{values:[1,2,3]},parameterDescriptions:{values:"The operands; homogeneous: all numbers, strings, arrays or objects",expect:"Pin the mode: every operand must be this type, and an empty input yields its identity",nullValueDefault:"Replaces any null operand before the addition"}},subtract:{displayName:"Subtract (-)",description:"Subtract one number from another",docUrl:r,backgroundColor:"#bfe4bc",textColor:"#193e1e",seeds:{value:10,minus:5},parameterDescriptions:{value:"The main operand",minus:"The amount subtracted from value"}},multiply:{displayName:"Multiply (*)",description:"Multiply numbers together — an empty input is 1, the empty product",docUrl:r,backgroundColor:"#b4e0b3",textColor:"#193e1e",seeds:{values:[5,5]},parameterDescriptions:{values:"The factors",nullValueDefault:"Replaces any null factor before multiplying"}},divide:{displayName:"Divide (/)",description:"Divide one number by another — true division; zero divisors fail",docUrl:r,backgroundColor:"#cceacd",textColor:"#193e1e",seeds:{value:100,by:10},parameterDescriptions:{value:"The main operand",by:"The divisor"}},modulo:{displayName:"Modulo",description:"The floored remainder: the result takes the sign of mod, so modulo(-7, 3) is 2",docUrl:r,backgroundColor:"#c3e7c6",textColor:"#193e1e",seeds:{value:10,mod:3},parameterDescriptions:{value:"The main operand",mod:"The modulus"}},power:{displayName:"Power (^)",description:"Raise a base to an exponent — overflow and complex results fail",docUrl:r,backgroundColor:"#acddb1",textColor:"#193e1e",seeds:{base:2,exponent:3},parameterDescriptions:{base:"The number to raise",exponent:"The power to raise it to"}},round:{displayName:"Round",description:"Round to a number of decimal places — ties go half away from zero; negative decimals round to tens, hundreds, …",docUrl:r,backgroundColor:"#d4edd8",textColor:"#193e1e",seeds:{value:3.14159,decimals:2},parameterDescriptions:{value:"The number to round",decimals:"Decimal places to keep; negative values round to powers of ten"}},floor:{displayName:"Round down",description:"Round down toward negative infinity",docUrl:r,backgroundColor:"#bce4c4",textColor:"#193e1e",seeds:{value:2.7},parameterDescriptions:{value:"The number to round down"}},ceil:{displayName:"Round up",description:"Round up toward positive infinity",docUrl:r,backgroundColor:"#b3e0be",textColor:"#193e1e",seeds:{value:2.3},parameterDescriptions:{value:"The number to round up"}},abs:{displayName:"Absolute value",description:"The absolute value",docUrl:r,backgroundColor:"#ccead5",textColor:"#193e1e",seeds:{value:-5},parameterDescriptions:{value:"The number"}},min:{displayName:"Minimum",description:"The smallest of the values — numbers numerically, strings in codepoint order",docUrl:r,backgroundColor:"#c3e7cf",textColor:"#193e1e",seeds:{values:[3,1,2]},parameterDescriptions:{values:"The candidates: all numbers, or all strings (codepoint order)",nullValueDefault:"Replaces any null candidate before comparing"}},max:{displayName:"Maximum",description:"The largest of the values — numbers numerically, strings in codepoint order",docUrl:r,backgroundColor:"#acddbf",textColor:"#193e1e",seeds:{values:[3,1,2]},parameterDescriptions:{values:"The candidates: all numbers, or all strings (codepoint order)",nullValueDefault:"Replaces any null candidate before comparing"}},buildString:{displayName:"String builder",description:"Render a template, filling its tokens — the result is always a string",docUrl:r,backgroundColor:"#f8d9c9",textColor:"#3f2f18",seeds:{template:"Hello {{$data.name}}"},parameterDescriptions:{template:"The text, with %N or {{name}} tokens; in a literal template, {{$data.x}} is that reference",substitutions:"An array pairs with %N tokens, an object with {{name}} tokens; the mode dispatches on which arrives",trim:"Trim whitespace from each rendered value, never from the template text",closeGaps:"A value that renders empty also takes one run of adjacent template whitespace",nullValueDefault:'Rendered in place of a null value, instead of ""'}},split:{displayName:"Split text",description:"Divide a string on a delimiter into an array of pieces — empty pieces are kept; an empty delimiter splits into code points",docUrl:r,backgroundColor:"#f5cbab",textColor:"#3f2f18",seeds:{value:"Alpha, Bravo, Charlie",delimiter:",",trim:!1},parameterDescriptions:{value:"The string to divide",delimiter:'Split on each occurrence; "" splits into code points',trim:"Trim whitespace from each piece"}},join:{displayName:"Join text",description:"Render array elements to text and concatenate them with a delimiter",docUrl:r,backgroundColor:"#f3cba0",textColor:"#3f2f18",seeds:{values:["Alpha","Bravo","Charlie"],delimiter:", "},parameterDescriptions:{values:'Elements of any type, rendered by the stringification table; a null renders "" and still occupies its slot',delimiter:"Placed between each adjacent pair — shares its contract with split",nullValueDefault:'Rendered in place of a null element, instead of ""'}},lower:{displayName:"Lower case",description:"Lowercase a string — Unicode default case mapping, locale-independent",docUrl:r,backgroundColor:"#f7e1bf",textColor:"#3f2f18",seeds:{value:"Hello World"},parameterDescriptions:{value:"The string to lowercase"}},upper:{displayName:"Upper case",description:"Uppercase a string — Unicode default case mapping, locale-independent",docUrl:r,backgroundColor:"#f6e1b4",textColor:"#3f2f18",seeds:{value:"Hello World"},parameterDescriptions:{value:"The string to uppercase"}},trim:{displayName:"Trim whitespace",description:"Strip whitespace (the JS trim set) from both ends of a string",docUrl:r,backgroundColor:"#f2dd97",textColor:"#3f2f18",seeds:{value:" Hello World "},parameterDescriptions:{value:"The string to trim"}},regex:{displayName:"Regular expression",description:"Test, extract or match a string against a regular expression",docUrl:r,backgroundColor:"#f8f1c9",textColor:"#3f2f18",seeds:{value:"test-this",pattern:"^[a-z]{4}-[a-z]{4}$",flags:"i"},parameterDescriptions:{value:"The subject string",pattern:"The regular expression source",flags:"The admitted subset: i, m, s, u",mode:"test gives a boolean, extract the first matching substring, match every one of them",noMatchDefault:"The extract answer when nothing matches — a matched empty string still passes through"}},length:{displayName:"Length",description:"An array's element count, or a string's Unicode code-point count",docUrl:r,backgroundColor:"#cde5f3",textColor:"#18293f",seeds:{value:[1,2,3,4,5]},parameterDescriptions:{value:"The array or string measured"}},map:{displayName:"Map each",description:"Transform every element of an array",docUrl:r,backgroundColor:"#bbd7ef",textColor:"#18293f",seeds:{input:[1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"Evaluated per element, with $element and $index bound"}},filter:{displayName:"Filter",description:"Keep the elements of an array whose predicate is truthy",docUrl:r,backgroundColor:"#a8c7eb",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},find:{displayName:"Find first",description:"The first element of an array whose predicate is truthy",docUrl:r,backgroundColor:"#cddcf3",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy",noMatchDefault:"The answer when nothing matches; a found null passes through unchanged"}},some:{displayName:"Any match",description:"True when any element satisfies the predicate",docUrl:r,backgroundColor:"#bbccef",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},every:{displayName:"All match",description:"True when every element satisfies the predicate",docUrl:r,backgroundColor:"#a8b9eb",textColor:"#18293f",seeds:{input:[0,1,2,3],each:"$element",as:"item"},parameterDescriptions:{input:"The collection iterated over; a null input is a type error",as:"Rename the bindings: as: 'row' binds $row and $rowIndex",nullInputDefault:"Used as the collection when input evaluates to null — typically []",each:"The predicate, per element — a truthiness position, so null is falsy"}},get:{displayName:"Get data",description:"Read a path out of the evaluation data, or out of a supplied object — the dynamic face of a $data reference",docUrl:r,backgroundColor:"#f0d1e5",textColor:"#3f182a",seeds:{path:"path.to.value",from:{path:{to:{value:"Found it"}}},default:"Not found"},parameterDescriptions:{path:"Dot and bracket segments, quoted keys and the [*] projection — or an array of segments, taken verbatim",from:"The source the path reads: a value, or a bare namespace ($data, $vars, $params, $element) whose var or parameter name opens the path — replace, never merge; a null source misses every path",default:"The answer when the path is missing — a stored null passes through unchanged (firstNonNull replaces one); supplying it also opts out of strictDataPaths"}},buildObject:{displayName:"Build object",description:"Assemble an object from computed key/value entries — for keys known only at runtime",docUrl:r,backgroundColor:"#eac0cc",textColor:"#3f182a",seeds:{entries:[{key:"firstKey",value:"firstValue"},{key:"secondKey",value:"secondValue"}]},parameterDescriptions:{entries:'Objects with a "key" and a "value"; a null value keeps its key'}},convert:{displayName:"Convert type",description:"Convert a value to a number, string, boolean or array — strict: a failed conversion is an error, never a guess",docUrl:r,backgroundColor:"#dddfe3",textColor:"#272a30",seeds:{value:"42"},parameterDescriptions:{value:"The value to convert; null propagates except for boolean, where it is false",to:"The target type"}},http:{displayName:"HTTP request",description:"One HTTP request — GET or POST — returning the parsed JSON response",docUrl:r,backgroundColor:"#eeedd2",textColor:"#3a3f18",seeds:{url:"https://restcountries.com/v3.1/name/zealand",returnPath:"[0].name.common",timeout:5e3},parameterDescriptions:{url:"A full http(s) URL is used verbatim; anything else — including an empty string — joins http.baseEndpoint",method:"Lowercase; the mutating verbs are deliberately absent — an expression is a read",query:"Query-string pairs; a null value omits its pair, a composite one is an error",body:"The JSON payload; a whole-null body means NO body, while nulls inside one are JSON nulls",headers:"Merged over the http.headers option per key; a null value removes an inherited pair",returnPath:"Dot/bracket path or segments array applied to the response; a miss is null",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},graphQL:{displayName:"GraphQL query",description:"One GraphQL query — a POST of { query, variables } — returning the data field",docUrl:r,backgroundColor:"#e3e8c2",textColor:"#3a3f18",seeds:{query:'query getCountries {\n countries(filter: { continent: { eq: "OC" } }) {\n name\n }\n}',url:"https://countries.trevorblades.com/",returnPath:"countries[0].name",timeout:5e3},parameterDescriptions:{query:"The GraphQL document — the protocol’s own word, as sql.query is",variables:"Query variables; a null value is CARRIED as JSON null, a nullable argument being meaningful GraphQL",url:"Per-node endpoint override; unset means the graphQL.endpoint option",headers:"Merged over http.headers then graphQL.headers; a null value removes a pair",returnPath:"Dot/bracket path or segments array applied to the response; a miss is null",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},sql:{displayName:"SQL query",description:"One SQL query against the registered connection. Expressions are READS — give the connection a read-only role and run mutations host-side",docUrl:r,backgroundColor:"#d2e2b1",textColor:"#3a3f18",seeds:{query:"SELECT contact_name FROM customers LIMIT 5",timeout:5e3},parameterDescriptions:{query:"SQL text with the driver’s own placeholders — FigTree never parses SQL",values:"Bind values — positional as an array, named as an object; a null binds SQL NULL",shape:"rows: every row object; firstRow: the first; column: one column’s values; firstValue: one scalar",noRowDefault:"The answer when firstRow / firstValue find no row — never for rows / column, never on failure",timeout:"Per-request deadline in ms; expiry is an ordinary failure this node’s fallback catches"}},literal:{displayName:"Literal",docUrl:r,backgroundColor:"#d5dae4",textColor:"#272a30",seeds:{value:"No content inside a literal node is evaluated"}}},o=(e,a)=>void 0!==e&&Object.hasOwn(e,a)?e[a]:void 0,s=e=>void 0!==e.backgroundColor&&void 0!==e.textColor?{backgroundColor:e.backgroundColor,textColor:e.textColor}:void 0,n=(e,r,t)=>void 0!==e.seeds&&Object.hasOwn(e.seeds,r)?e.seeds[r]:"string"==typeof t?a[t]:"literal"in t?t.literal[0]:a[t.find(e=>"null"!==e)??"null"],l=(e,a,r)=>{const{type:t,evaluation:o}=a;return a.replacesNullAt?"none":"as"===e&&"structural"===o&&Object.values(r).some(e=>"perElement"===e.evaluation)?"error":[t].flat().some(e=>"null"===e||"any"===e)?"eager"===o||"structural"===o?a.nullPolicy:"value":a.required||"lazy"===o||"perElement"===o?"error":"unset"},i=(e,a)=>{for(const[r,t]of Object.entries(a??{}))void 0!==t&&(e[r]=t)},d=(a,...r)=>({categories:Object.entries(e).map(([e,a])=>({name:e,...a})).sort((e,a)=>e.order-a.order),operators:a.getOperators().map(({name:a,parameters:d,...c})=>{const u=(e=>{const a={seeds:{},parameterDescriptions:{}};for(const n of[t,...r]){const r=o(n,e);if(void 0!==r){for(const e of["displayName","description","docUrl"]){const t=r[e];void 0!==t&&(a[e]=t)}Object.assign(a,s(r)),i(a.seeds,r.seeds),i(a.parameterDescriptions,r.parameterDescriptions)}}return a})(a),p={name:a,displayName:u.displayName??a,...c,...s(u)??s(e[c.category]),parameters:{}};void 0!==u.description&&(p.description=u.description),void 0!==u.docUrl&&(p.docUrl=u.docUrl);for(const[e,a]of Object.entries(d)){const r={...a,nullOutcome:l(e,a,d),seed:n(u,e,a.type)};if(!a.replacesNullAt&&[a.type].flat().every(e=>"array"===e||"object"===e)){const{homogeneous:e,elementShape:t}=a.constraints??{};r.elementNullOutcome=a.elementNullPolicy??(t||e&&!e.includes("any")?"error":"value")}const t=o(u.parameterDescriptions,e);void 0!==t&&(r.description=t),p.parameters[e]=r}return p}),fragments:a.getFragments().map(({name:e,parameters:a,...r})=>{const t=r.metadata??{},o={name:e,displayName:t.displayName??e,...r,...s(t),parameters:{}};void 0!==t.docUrl&&(o.docUrl=t.docUrl);for(const[e,r]of Object.entries(a))o.parameters[e]={...r,seed:n(t,e,r.type)};return o})});export{e as categoryListings,d as getCatalog,t as operatorListings,a as typeSeeds};
|