// @bun
var{defineProperty:M,getOwnPropertyNames:D,getOwnPropertyDescriptor:k}=Object,K=Object.prototype.hasOwnProperty;function R(q){return this[q]}var y=(q)=>{var J=(U??=new WeakMap).get(q),Q;if(J)return J;if(J=M({},"__esModule",{value:!0}),q&&typeof q==="object"||typeof q==="function"){for(var W of D(q))if(!K.call(J,W))M(J,W,{get:R.bind(q,W),enumerable:!(Q=k(q,W))||Q.enumerable})}return U.set(q,J),J},U;var N=(q)=>q;function _(q,J){this[q]=N.bind(null,J)}var u=(q,J)=>{for(var Q in J)M(q,Q,{get:J[Q],enumerable:!0,configurable:!0,set:_.bind(J,Q)})};var T=(q,J)=>()=>(q&&(J=q(q=0)),J);var E=import.meta.require;function l(q){Y={...Y,...q}}function d(){Y={...z}}function c(){return{...Y}}function g(q){let J="",Q=null,W=!1;for(let Z=0;Z<q.length;Z++){let $=q[Z];if(W){W=!1;continue}if($==="\\"&&Q){W=!0;continue}if(Q){if(Q==="`"&&$==="$"&&Z+1<q.length&&q[Z+1]==="{"){let w=1;Z+=2;while(Z<q.length&&w>0){if(q[Z]==="{")w++;else if(q[Z]==="}")w--;if(w>0)J+=q[Z],Z++}continue}if($===Q)Q=null;continue}if($==='"'||$==="'"||$==="`"){Q=$;continue}J+=$}return J}function h(q,J){let Q=/[$A-Z_a-z][$\w]*/g,W;while((W=Q.exec(q))!==null){let Z=W[0],$=q[W.index-1];if(v.has(Z))throw Error(`Potentially unsafe expression (matched /\\b${Z}\\b/; identifier ${Z}): ${J}`);if($==="."&&I.has(Z))throw Error(`Potentially unsafe expression (matched /.${Z}/; property ${Z}): ${J}`)}}function j(q){let J=/\[\s*(['"])(.*?)\1\s*\]/g,Q;while((Q=J.exec(q))!==null){let W=Q[2];if(!I.has(W))continue;let Z=q.slice(0,Q.index).match(/\S(?=\s*$)/)?.[0],$=q.slice(Q.index+Q[0].length).match(/^\s*(\S)/)?.[1];if(!((Z==="{"||Z===",")&&$===":"))throw Error(`Potentially unsafe expression (bracket key ${Q[2]}): ${q}`)}}function P(q){let J=q.trim(),Q=g(J);h(Q,J),j(J);for(let W of B)if(W.test(Q))throw Error(`Potentially unsafe expression (matched /${W.source}/): ${J}`);if(!Y.allowBracketNotation&&A.test(J))throw Error(`Bracket notation with strings not allowed: ${J}. Enable with configureSafeEvaluator({ allowBracketNotation: true })`);return J}function O(q){let J={};J.Math=Math,J.JSON=JSON,J.Date=Date,J.String=String,J.Number=Number,J.Boolean=Boolean,J.Array=Array,J.parseInt=Number.parseInt,J.parseFloat=Number.parseFloat,J.isNaN=Number.isNaN,J.isFinite=Number.isFinite,J.encodeURIComponent=encodeURIComponent,J.decodeURIComponent=decodeURIComponent;for(let[Q,W]of Object.entries(q)){if(Q.startsWith("__")||B.some((Z)=>Z.test(Q)))continue;if(W&&typeof W==="object"&&!Array.isArray(W))J[Q]=F(W);else J[Q]=W}return J}function F(q,J=0){if(J>=Y.maxSanitizeDepth)return"[Object too deep]";if(q===null||typeof q!=="object")return q;if(Array.isArray(q))return q.map((W)=>F(W,J+1));if(q instanceof Date||q instanceof RegExp||q instanceof Map||q instanceof Set||q instanceof Error)return q;let Q={};for(let[W,Z]of Object.entries(q)){if(W.startsWith("__")||W==="constructor"||W==="prototype")continue;if(Z&&typeof Z==="object")Q[W]=F(Z,J+1);else Q[W]=Z}return Q}function L(q,J){try{let Q=O(J),W=Object.keys(Q),Z=Object.values(Q);return b(q,W)(...Z)}catch{return}}function a(q){try{return P(q),!0}catch{return!1}}function x(q){try{return P(q),null}catch(J){return J instanceof Error?J.message:String(J)}}function p(q,J){try{let Q=L(q,J);return Boolean(Q)}catch{return!1}}function r(q,J){try{let Q=L(q,J);if(Array.isArray(Q))return Q;if(Q&&typeof Q==="object"&&"length"in Q){let W=Q.length;if(typeof W==="number"&&Number.isFinite(W)&&W>=0&&Number.isInteger(W))return Array.from(Q)}return[]}catch{return[]}}function o(q,J){try{let Q=L(q,J);if(Q&&typeof Q==="object"&&!Array.isArray(Q))return Q;return{}}catch{return{}}}function b(q,J){let Q=P(q),W=/^[A-Za-z_$][\w$]*$/,Z=[],$=[];for(let H=0;H<J.length;H++){let X=J[H];if(!W.test(X))continue;if(m.has(X))continue;Z.push(H),$.push(X)}let w=Function(...$,`
    'use strict';
    try {
      return ${Q};
    }
catch (e) {
      if (e instanceof ReferenceError || e instanceof TypeError) {
        return undefined;
      }
      throw e;
    }
  `);if($.length===J.length)return w;return(...H)=>{let X=Array(Z.length);for(let V=0;V<Z.length;V++)X[V]=H[Z[V]];return w(...X)}}function n(q,J){try{if(typeof q!=="string")return;if(q.length>G)throw Error(`safeEvaluateCode: input exceeds ${G} chars`);for(let w of B)if(w.test(q))throw Error("Potentially unsafe code detected");let Q=O(J),W=Object.keys(Q),Z=Object.values(Q);return Function(...W,`
      'use strict';
      ${q}
    `)(...Z)}catch{return}}function S(q){let J=q.trim(),Q=[/\beval\s*\(/i,/\bFunction\s*\(/i,/\bimport\s*\(/i,/\brequire\s*\(/i,/\bprocess\b/i,/\b__proto__\b/i,/\bconstructor\s*[.(]/i,/\bglobalThis\b/i,/\bwindow\b/i,/\bdocument\b/i,/\bfetch\s*\(/i,/\bBun\b/i,/\bDeno\b/i,/\bconsole\b/i,/\bthis\b/i,/\bReflect\b/i,/\bProxy\b/i,/\bprototype\b/i,/\.(bind|call|apply)\s*\(/i];for(let W of Q)if(W.test(J))return!1;return!0}function i(q,J,Q,W,Z=1000){if(!S(J))throw Error(`Unsafe expression in @${q}: ${J}`);let $=Q.replace(/`/g,"\\`").replace(/\$\{/g,"\\${").replace(/\{\{([^}]+)\}\}/g,(w,H)=>{return`\${${H}}`});if(q==="for")return Function(...W,`
      'use strict';
      let result = '';
      for (${J}) {
        result += \`${$}\`;
      }
      return result;
    // eslint-disable-next-line pickier/no-unused-vars
    `);else return Function(...W,`
      'use strict';
      let result = '';
      let __safeCounter = 0;
      const __maxIterations = ${Z};
      while (${J} && __safeCounter < __maxIterations) {
        __safeCounter++;
        result += \`${$}\`;
      }
      // Surface the truncation both inline (for end users) and via
      // console.warn (for developers running \`stx dev\`). A silent cut-off
      // made pages render half a list with no breadcrumb.
      if (__safeCounter >= __maxIterations) {
        result += '<!-- [Loop Error]: Maximum iterations exceeded -->';
        if (typeof console !== 'undefined' && typeof console.warn === 'function') {
          console.warn('[stx] @while loop hit max iterations (' + __maxIterations + '); template output was truncated. Raise via createSafeForLoop(..., maxIterations) if intentional.');
        }
      }
      return result;
    // eslint-disable-next-line pickier/no-unused-vars
    `)}var z,Y,B,v,I,A,m,G=65536;var C=T(()=>{z={maxSanitizeDepth:10,allowBracketNotation:!1},Y={...z};B=[/\b(eval|Function|setTimeout|setInterval|setImmediate)\b/,/\b(process|require|import|exports|module)\b/,/\b(window|document|global|globalThis)\b/,/\b(constructor|prototype|__proto__)\b/,/\b(Reflect|Proxy)\b/,/\bSymbol\b/,/\b(WeakMap|WeakSet|WeakRef|FinalizationRegistry)\b/,/\b(Generator|AsyncGenerator)\b/,/__\w+__/,/\.(bind|call|apply)\s*\(/,/\bnew\s+/,/\bdelete\s+/,/\bthis\b/],v=new Set(["eval","Function","setTimeout","setInterval","setImmediate","process","require","import","exports","module","window","document","global","globalThis","constructor","prototype","Reflect","Proxy","Symbol","WeakMap","WeakSet","WeakRef","FinalizationRegistry","Generator","AsyncGenerator","delete","this"]),I=new Set(["__proto__","constructor","prototype"]),A=/[\w)\]]\s*\[\s*['"]/;m=new Set(["break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","false","finally","for","function","if","import","in","instanceof","new","null","return","super","switch","this","throw","true","try","typeof","var","void","while","with","yield","let","static","implements","interface","package","private","protected","public","arguments","eval","await"])});C();export{P as sanitizeExpression,o as safeEvaluateObject,p as safeEvaluateCondition,n as safeEvaluateCode,r as safeEvaluateArray,L as safeEvaluate,d as resetSafeEvaluatorConfig,S as isForExpressionSafe,a as isExpressionSafe,c as getSafeEvaluatorConfig,x as getExpressionSafetyReason,i as createSafeLoopFunction,b as createSafeFunction,O as createSafeContext,l as configureSafeEvaluator};
