{"version":3,"sources":["../src/parser/HeldExpression.ts"],"names":["heldExpressionReadsLines","program","builder","verb","name","safeText","ErrorFactory"],"mappings":"qHA0BO,SAASA,EAAyBC,CAAAA,CAA0BC,CAAAA,CAA0BC,CAAAA,CAAkC,CAC9H,GAAI,CAACF,CAAAA,CAAQ,QAAA,EAAY,CAACC,EAAQ,aAAA,CAAe,OAAO,KACxD,IAAME,CAAAA,CAAOC,oBAASF,CAAI,CAAA,CAC1B,OAAOG,mBAAAA,CAAa,QAAQ,CAC3B,IAAA,CAAM,8BACN,OAAA,CAAS,CAAA,EAAGF,CAAI,CAAA,2MAAA,CAAA,CAChB,UAAA,CAAY,CAAA,oEAAA,EAAuEA,CAAI,QACvF,OAAA,CAAS,CAAE,KAAMA,CAAK,CACvB,CAAC,CACF","file":"chunk-R257464C.cjs","sourcesContent":["import type { BytecodeBuilder, BytecodeProgram } from \"@solve-js/parser/BytecodeBuilder\";\nimport { ErrorFactory, type EngineError } from \"@solve-js/errors/UnifiedErrorFramework\";\nimport { safeText } from \"@solve-js/parser/ParseMessages\";\n\n/**\n * The refusal for a held expression that reads other lines of the document,\n * or null when it reads none.\n *\n * A held expression is compiled on its own and worked out later, away from\n * the line that wrote it: once for each element of a `map`, `reduce`, `sum`\n * or `prod`, once for each point of a plot, or as a formula by an algebra verb\n * (`der`, `solve`, `integral`). A call that reads other lines (`prev`,\n * `line 1`, `total above`, a tag or a table column) waits for the document to\n * hand it a value, so such an expression used to be refused as reaching live\n * data, \"no weather/stocks/currency calls\", which named something the line\n * never did. It is refused for what it is, with the way to write it: give the\n * line's value a name on a line of its own and use the name.\n *\n * A held expression that reaches live data is not this refusal: its\n * `readsDocument` is false, and the caller's own refusal for that stands.\n *\n * @param program - The held expression, compiled.\n * @param builder - The builder it was compiled into, which knows whether a call read lines.\n * @param verb - The form holding it, as the reader wrote it (`map`, `sum`, `plot`, `der`).\n * @returns The refusal to throw, or null.\n */\nexport function heldExpressionReadsLines(program: BytecodeProgram, builder: BytecodeBuilder, verb: string): EngineError | null {\n\tif (!program.hasAsync || !builder.readsDocument) return null;\n\tconst name = safeText(verb);\n\treturn ErrorFactory.parsing({\n\t\tcode: \"HELD_EXPRESSION_READS_LINES\",\n\t\tmessage: `${name}'s expression reads other lines of the document, and it is worked out away from the line, where there are no lines to read: give the line's value a name first, as in p = prev, and use p in the expression`,\n\t\tsuggestion: `Write p = prev (or p = line 1) on the line above, then use p inside ${name}(...)`,\n\t\tcontext: { verb: name },\n\t});\n}\n"]}