"use strict";exports.id=6355,exports.ids=[6355],exports.modules={46355:(a,b,c)=>{function d(a,b){if(a&&b)return b.split(".").reduce((a,b)=>null==a?a:a[b],a)}function e(a,{intake:b,context:c}){if(!a||"string"!=typeof a)return{result:!0,error:null};try{let e=function(a){let b=[],c=0;for(;c<a.length;){let d=a[c];if(/\s/.test(d)){c++;continue}if("("===d||")"===d||"["===d||"]"===d||","===d){b.push({type:d}),c++;continue}if("&"===d&&"&"===a[c+1]){b.push({type:"&&"}),c+=2;continue}if("|"===d&&"|"===a[c+1]){b.push({type:"||"}),c+=2;continue}if("="===d&&"="===a[c+1]){b.push({type:"op",value:"=="}),c+=2;continue}if("!"===d&&"="===a[c+1]){b.push({type:"op",value:"!="}),c+=2;continue}if("<"===d&&"="===a[c+1]){b.push({type:"op",value:"<="}),c+=2;continue}if(">"===d&&"="===a[c+1]){b.push({type:"op",value:">="}),c+=2;continue}if("<"===d||">"===d){b.push({type:"op",value:d}),c++;continue}if("'"===d||'"'===d){let e=a.indexOf(d,c+1);if(-1===e)throw Error(`policy-gate: unterminated string at ${c}`);b.push({type:"string",value:a.slice(c+1,e)}),c=e+1;continue}if(/[0-9.]/.test(d)){let d=c;for(;d<a.length&&/[0-9.]/.test(a[d]);)d++;b.push({type:"number",value:Number(a.slice(c,d))}),c=d;continue}if(/[A-Za-z_]/.test(d)){let d=c;for(;d<a.length&&/[A-Za-z0-9_.]/.test(a[d]);)d++;let e=a.slice(c,d);if("IN"===e||"in"===e)b.push({type:"IN"});else if("true"===e)b.push({type:"boolean",value:!0});else if("false"===e)b.push({type:"boolean",value:!1});else if("prior_stage"===e&&"("===a[d]){let e=a.indexOf(")",d),f=a.slice(d+1,e).trim().replace(/^['"]|['"]$/g,""),g=e+1;if("."!==a[g])throw Error("policy-gate: expected '.' after prior_stage(...)");let h=g+1;for(;h<a.length&&/[A-Za-z0-9_.]/.test(a[h]);)h++;b.push({type:"ref",kind:"prior_stage",stage:f,path:a.slice(g+1,h)}),c=h;continue}else b.push({type:"ref",kind:"path",path:e});c=d;continue}throw Error(`policy-gate: unexpected character "${d}" at ${c}`)}return b}(a);return{result:!!function(a,b){let c=0;function e(){return a[c]}function f(b){let d=a[c];if(!d||d.type!==b)throw Error(`policy-gate: expected ${b}, got ${d?.type||"EOF"}`);return c++,d}function g(){let a=e();if(!a)throw Error("policy-gate: unexpected end of expression");if("("===a.type){c++;let a=j();return f(")"),a}if("number"===a.type||"string"===a.type||"boolean"===a.type)return c++,a.value;if("ref"===a.type)return c++,"prior_stage"===a.kind?d(b.context?.[a.stage],a.path):a.path.startsWith("intake.")?d(b.intake,a.path.slice(7)):a.path.startsWith("context.")?d(b.context,a.path.slice(8)):d(b,a.path);throw Error(`policy-gate: unexpected token ${a.type}`)}function h(){let a=g(),b=e();if(!b)return!!a;if("op"===b.type){c++;let d=g();switch(b.value){case"==":return a==d;case"!=":return a!=d;case"<":return Number(a)<Number(d);case"<=":return Number(a)<=Number(d);case">":return Number(a)>Number(d);case">=":return Number(a)>=Number(d)}}if("IN"===b.type){c++,f("[");let b=[];for(;e()&&"]"!==e().type;){let a=g();b.push(a),e()&&","===e().type&&c++}return f("]"),b.includes(a)}return!!a}function i(){let a=h();for(;e()&&"&&"===e().type;){c++;let b=h();a=!!a&&!!b}return a}function j(){let a=i();for(;e()&&"||"===e().type;){c++;let b=i();a=!!a||!!b}return a}let k=j();if(c!==a.length)throw Error(`policy-gate: unexpected trailing token at ${c}`);return k}(e,{intake:b,context:c}),error:null}}catch(a){return{result:!1,error:a?.message||String(a)}}}c.r(b),c.d(b,{evaluateRule:()=>e})}};