diff --git a/packages/orgcheck-api/src/api/core/orgcheck-api-secretsauce.ts b/packages/orgcheck-api/src/api/core/orgcheck-api-secretsauce.ts index 343675ab..bc267572 100644 --- a/packages/orgcheck-api/src/api/core/orgcheck-api-secretsauce.ts +++ b/packages/orgcheck-api/src/api/core/orgcheck-api-secretsauce.ts @@ -738,7 +738,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ { id: 100, description: '[LFS] Inactive Flow', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('InactiveFlow') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'InactiveFlow') || false) as (data: unknown) => boolean, errorMessage: `This flow is inactive. Consider activating it or removing it from your org.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -746,7 +746,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 101, description: '[LFS] Process Builder', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('ProcessBuilder') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'ProcessBuilder') || false) as (data: unknown) => boolean, errorMessage: `Time to migrate this process builder to flow!`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -754,7 +754,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 102, description: '[LFS] Missing Flow Description', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('FlowDescription') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'FlowDescription') || false) as (data: unknown) => boolean, errorMessage: `This flow does not have a description. Add documentation about its purpose and usage.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -762,7 +762,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 103, description: '[LFS] Outdated API Version', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('APIVersion') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'APIVersion') || false) as (data: unknown) => boolean, errorMessage: `The API version of this flow is outdated. Update it to the newest version.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -770,7 +770,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 104, description: '[LFS] Unsafe Running Context', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('UnsafeRunningContext') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'UnsafeRunningContext') || false) as (data: unknown) => boolean, errorMessage: `This flow runs in System Mode without Sharing, which can lead to unsafe data access.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -778,7 +778,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 105, description: '[LFS] SOQL Query In Loop', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('SOQLQueryInLoop') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'SOQLQueryInLoop') || false) as (data: unknown) => boolean, errorMessage: `This flow has SOQL queries inside loops. Consolidate queries at the end of the flow to avoid governor limits.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -786,7 +786,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 106, description: '[LFS] DML Statement In Loop', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('DMLStatementInLoop') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'DMLStatementInLoop') || false) as (data: unknown) => boolean, errorMessage: `This flow has DML operations inside loops. Consolidate DML at the end to avoid governor limits.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -794,7 +794,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 107, description: '[LFS] Action Calls In Loop', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('ActionCallsInLoop') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'ActionCallsInLoop') || false) as (data: unknown) => boolean, errorMessage: `This flow has action calls inside loops. Bulkify apex calls using collection variables.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -802,7 +802,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 108, description: '[LFS] Hardcoded Id', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('HardcodedId') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'HardcodedId') || false) as (data: unknown) => boolean, errorMessage: `This flow contains hardcoded IDs which are org-specific. Use variables or merge fields instead.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -810,7 +810,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 109, description: '[LFS] Hardcoded Url', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('HardcodedUrl') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'HardcodedUrl') || false) as (data: unknown) => boolean, errorMessage: `This flow contains hardcoded URLs. Use $API formulas or custom labels instead.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -818,7 +818,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 110, description: '[LFS] Missing Null Handler', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('MissingNullHandler') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'MissingNullHandler') || false) as (data: unknown) => boolean, errorMessage: `This flow has Get Records operations without null checks. Use decision elements to validate results.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -826,7 +826,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 111, description: '[LFS] Missing Fault Path', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('MissingFaultPath') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'MissingFaultPath') || false) as (data: unknown) => boolean, errorMessage: `This flow has DML or action operations without fault handlers. Add fault paths for better error handling.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -834,7 +834,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 112, description: '[LFS] Recursive After Update', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('RecursiveAfterUpdate') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'RecursiveAfterUpdate') || false) as (data: unknown) => boolean, errorMessage: `This after-update flow modifies the same record that triggered it, risking recursion. Use before-save flows instead.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -842,7 +842,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 113, description: '[LFS] Duplicate DML Operation', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('DuplicateDMLOperation') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'DuplicateDMLOperation') || false) as (data: unknown) => boolean, errorMessage: `This flow allows navigation back after DML operations, which may cause duplicate changes.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -850,7 +850,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 114, description: '[LFS] Get Record All Fields', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('GetRecordAllFields') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'GetRecordAllFields') || false) as (data: unknown) => boolean, errorMessage: `This flow uses Get Records with "all fields". Specify only needed fields for better performance.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -858,7 +858,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 115, description: '[LFS] Record ID as String', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('RecordIdAsString') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'RecordIdAsString') || false) as (data: unknown) => boolean, errorMessage: `This flow uses a String recordId variable. Modern flows can receive the entire record object, eliminating Get Records queries.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -866,7 +866,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 116, description: '[LFS] Unconnected Element', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('UnconnectedElement') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'UnconnectedElement') || false) as (data: unknown) => boolean, errorMessage: `This flow has unconnected elements that are not in use. Remove them to maintain clarity.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -874,7 +874,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 117, description: '[LFS] Unused Variable', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('UnusedVariable') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'UnusedVariable') || false) as (data: unknown) => boolean, errorMessage: `This flow has unused variables. Remove them to maintain efficiency.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -882,7 +882,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 118, description: '[LFS] Copy API Name', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('CopyAPIName') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'CopyAPIName') || false) as (data: unknown) => boolean, errorMessage: `This flow has elements with copy-paste naming patterns like "Copy_X_Of_Element". Update API names for readability.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -890,7 +890,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 120, description: '[LFS] Same Record Field Updates', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('SameRecordFieldUpdates') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'SameRecordFieldUpdates') || false) as (data: unknown) => boolean, errorMessage: `This before-save flow uses Update Records on $Record. Use direct assignment instead for better performance.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -898,7 +898,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 122, description: '[LFS] Missing Metadata Description', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('MissingMetadataDescription') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'MissingMetadataDescription') || false) as (data: unknown) => boolean, errorMessage: `This flow has elements or variables without descriptions. Add documentation for better maintainability.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -906,7 +906,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 123, description: '[LFS] Missing Filter Record Trigger', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('MissingFilterRecordTrigger') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'MissingFilterRecordTrigger') || false) as (data: unknown) => boolean, errorMessage: `This record-triggered flow lacks filters on changed fields or entry conditions, causing unnecessary executions.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -914,7 +914,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 124, description: '[LFS] Transform Instead of Loop', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('TransformInsteadOfLoop') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'TransformInsteadOfLoop') || false) as (data: unknown) => boolean, errorMessage: `This flow uses Loop + Assignment which could be replaced with Transform element (10x faster).`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], @@ -922,7 +922,7 @@ const ALL_SCORE_RULES: ScoreRule[] = [ }, { id: 125, description: '[LFS] Missing Auto Layout', - formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.includes('AutoLayout') || false) as (data: unknown) => boolean, + formula: ((d: SfdcFlow) => d?.currentVersionRef?.lfsViolations?.some(v => v.name === 'AutoLayout') || false) as (data: unknown) => boolean, errorMessage: `This flow doesn't use Auto-Layout mode. Enable it to keep your flow organized automatically.`, badField: 'currentVersionRef.lfsViolations', applicable: [ DataAliases.SfdcFlow ], diff --git a/packages/orgcheck-api/src/api/core/salesforce/orgcheck-api-lfs-scanner.ts b/packages/orgcheck-api/src/api/core/salesforce/orgcheck-api-lfs-scanner.ts index eace447e..33d10c11 100644 --- a/packages/orgcheck-api/src/api/core/salesforce/orgcheck-api-lfs-scanner.ts +++ b/packages/orgcheck-api/src/api/core/salesforce/orgcheck-api-lfs-scanner.ts @@ -60,6 +60,13 @@ export class LFSScanner { // Scan flows const scanResults = lfsCore.scan(lfsFlows); + // Apply warning severity threshold via the LFS core if available (v6.19+) + if (lfsCore.filterByThreshold) { + for (const result of scanResults) { + result.ruleResults = lfsCore.filterByThreshold(result.ruleResults, 'warning'); + } + } + // Map results: flowVersionId -> violations results = this.mapResults(scanResults); } @@ -73,15 +80,15 @@ export class LFSScanner { /** * @description Map LFS scan results to OrgCheck format * @param {any[]} scanResults - LFS scan results - * @returns {Map} Map of flow version ID to violations + * @returns {Map} Map of flow version ID to violations */ - static mapResults(scanResults: Record[]): Map { + static mapResults(scanResults: Record[]): Map { const violationsMap = new Map(); for (const result of scanResults) { - const ruleResults = result.ruleResults as { occurs: boolean; ruleName: string }[]; + const ruleResults = result.ruleResults as { occurs: boolean; ruleName: string; severity?: string }[]; const violations = ruleResults .filter((ruleResult) => ruleResult.occurs === true) - .map((ruleResult) => ruleResult.ruleName); + .map((ruleResult) => ({ name: ruleResult.ruleName, severity: ruleResult.severity ?? 'warning' })); if (violations?.length > 0) { violationsMap.set((result.flow as { uri: string }).uri, violations); } diff --git a/packages/orgcheck-api/src/api/data/orgcheck-api-data-flow.ts b/packages/orgcheck-api/src/api/data/orgcheck-api-data-flow.ts index 4d6fe3eb..38cc2324 100644 --- a/packages/orgcheck-api/src/api/data/orgcheck-api-data-flow.ts +++ b/packages/orgcheck-api/src/api/data/orgcheck-api-data-flow.ts @@ -98,6 +98,14 @@ export interface SfdcFlow extends DataWithScoreAndDependencies { lastModifiedDate: number; } +/** + * Represents a single LFS rule violation with its name and severity + */ +export interface LfsViolation { + name: string; + severity: string; +} + /** * Represents a Flow Version */ @@ -237,9 +245,9 @@ export interface SfdcFlowVersion extends DataWithoutScore { recordTriggerType: string; /** - * @description LFS Violations (list of rule names) for this flow version - * @type {string[]} + * @description LFS Violations for this flow version, filtered to warning severity and above by the LFS core + * @type {LfsViolation[]} * @public */ - lfsViolations: string[]; + lfsViolations: LfsViolation[]; } \ No newline at end of file diff --git a/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-flows.ts b/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-flows.ts index 1a2f3a10..edd986a3 100644 --- a/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-flows.ts +++ b/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-flows.ts @@ -29,7 +29,7 @@ export class FlowsTableDefinition implements TableDefinition { { label: '# DML Delete Nodes', type: ColumnType.NUM, data: { value: 'currentVersionRef.dmlDeleteNodeCount' }}, { label: '# DML Update Nodes', type: ColumnType.NUM, data: { value: 'currentVersionRef.dmlUpdateNodeCount' }}, { label: '# Screen Nodes', type: ColumnType.NUM, data: { value: 'currentVersionRef.screenNodeCount' }}, - { label: 'Its LFS Violations', type: ColumnType.TXTS, data: { values: 'currentVersionRef.lfsViolations', value: '.' }}, + { label: 'Its LFS Violations', type: ColumnType.TXTS, data: { values: 'currentVersionRef.lfsViolations', value: 'name' }}, { label: 'Its created date', type: ColumnType.DTM, data: { value: 'currentVersionRef.createdDate' }}, { label: 'Its modified date', type: ColumnType.DTM, data: { value: 'currentVersionRef.lastModifiedDate' }}, { label: 'Its description', type: ColumnType.TXT, data: { value: 'currentVersionRef.description' }, modifier: { maximumLength: 45, valueIfEmpty: 'No description.' }}, diff --git a/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-processbuilders.ts b/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-processbuilders.ts index c3e0f5e6..07e7cb6f 100644 --- a/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-processbuilders.ts +++ b/packages/orgcheck-api/src/ui/table/definitions/orgcheck-ui-tabledef-processbuilders.ts @@ -27,7 +27,7 @@ export class ProcessBuildersTableDefinition implements TableDefinition { { label: '# DML Delete Nodes', type: ColumnType.NUM, data: { value: 'currentVersionRef.dmlDeleteNodeCount' }}, { label: '# DML Update Nodes', type: ColumnType.NUM, data: { value: 'currentVersionRef.dmlUpdateNodeCount' }}, { label: '# Screen Nodes', type: ColumnType.NUM, data: { value: 'currentVersionRef.screenNodeCount' }}, - { label: 'Its LFS Violations', type: ColumnType.TXTS, data: { values: 'currentVersionRef.lfsViolations', value: '.' }}, + { label: 'Its LFS Violations', type: ColumnType.TXTS, data: { values: 'currentVersionRef.lfsViolations', value: 'name' }}, { label: 'Its created date', type: ColumnType.DTM, data: { value: 'currentVersionRef.createdDate' }}, { label: 'Its modified date', type: ColumnType.DTM, data: { value: 'currentVersionRef.lastModifiedDate' }}, { label: 'Its description', type: ColumnType.TXT, data: { value: 'currentVersionRef.description' }, modifier: { maximumLength: 45, valueIfEmpty: 'No description.' }}, diff --git a/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/install.readme b/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/install.readme index 6bc36284..2986f70c 100644 --- a/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/install.readme +++ b/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/install.readme @@ -1,6 +1,14 @@ Name: Lightning Flow Scanner Website: https://lightningflowscanner.org/ -Version: unknown -Release: unknown +Version: 6.19.4 +Release: https://github.com/Flow-Scanner/lightning-flow-scanner/releases/tag/core-v6.19.4 Source: https://github.com/Flow-Scanner/lightning-flow-scanner -Comment: UMD distribution of Lightning Flow Scanner Core \ No newline at end of file +Package: https://www.npmjs.com/package/@flow-scanner/lightning-flow-scanner-core/v/6.19.4 +Comment: UMD distribution of Lightning Flow Scanner Core, bundled from the published + package so it is self contained in the browser. Reproduce with: + npm i @flow-scanner/lightning-flow-scanner-core@6.19.4 esbuild path-browserify + echo "export * from '@flow-scanner/lightning-flow-scanner-core';" > entry.js + npx esbuild entry.js --bundle --format=iife --global-name=lightningflowscanner \ + --minify --platform=browser --alias:path=path-browserify --alias:fs=./stub-fs.js \ + --outfile=lfscore.js + The fs alias is a stub that throws, since the browser build never reads from disk. diff --git a/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/lfscore.js b/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/lfscore.js index ceb63e6b..d680e0ae 100644 --- a/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/lfscore.js +++ b/packages/orgcheck-salesforce-app/build/static-resource/libs/lfs/lfscore.js @@ -1,4 +1,10 @@ -(function(g,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("fast-xml-parser")):typeof define=="function"&&define.amd?define(["exports","fast-xml-parser"],O):(g=typeof globalThis<"u"?globalThis:g||self,O(g.lightningflowscanner={},g["fast-xml-parser"]))})(this,(function(g,O){"use strict";class Q{constructor(){this.visitedElements=new Set}traverseFlow(e,t,s,r,n){let o=[e];for(;o.length>0;){const i=[];for(const c of o)if(!this.visitedElements.has(c)){const l=s.get(c);l&&(t(l),this.visitedElements.add(c),i.push(...this.findNextElements(c,r,s,n)))}if(i.length===0)break;o=i}}findNextElements(e,t,s,r){const n=[],o=t.get(e);if(o)for(const i of o)i!==r&&s.has(i)&&n.push(i);return n}}function Re(a,e=!1){return a.flatMap(t=>{const s=t.flow,r=s.name||s.label,n=s.fsPath?s.fsPath.replace(/\\/g,"/"):s.uri?s.uri.replace(/\\/g,"/"):`${s.name}.flow-meta.xml`;return t.ruleResults.filter(o=>{var i;return o.occurs&&((i=o.details)==null?void 0:i.length)}).flatMap(o=>o.details.map(i=>{const{details:c,...l}=i,u={...l,flowFile:n,flowName:r,ruleName:o.ruleName,severity:o.severity??"warning"};return e&&c&&("dataType"in c&&(u.dataType=c.dataType),"locationX"in c&&(u.locationX=String(c.locationX)),"locationY"in c&&(u.locationY=String(c.locationY)),"connectsTo"in c&&(u.connectsTo=Array.isArray(c.connectsTo)?c.connectsTo.join(", "):String(c.connectsTo)),"expression"in c&&(u.expression=c.expression)),u}))})}function Ee(a){const e=a.map(t=>{const s=t.flow,r=Ne(s);return{artifacts:[{location:{uri:r},sourceLanguage:"xml"}],results:t.ruleResults.filter(n=>n.occurs).flatMap(n=>n.details.map(o=>({level:ce(n.severity),locations:[{physicalLocation:{artifactLocation:{index:0,uri:r},region:xe(o)}}],message:{text:n.errorMessage||`${n.ruleName} in ${o.name}`},properties:{element:o.name,flow:s.name,type:o.type,...o.details},ruleId:n.ruleName}))),tool:{driver:{informationUri:"https://github.com/Flow-Scanner/lightning-flow-scanner",name:"Lightning Flow Scanner",rules:t.ruleResults.filter(n=>n.occurs).map(n=>({defaultConfiguration:{level:ce(n.severity)},fullDescription:{text:n.ruleDefinition.description||""},id:n.ruleName,shortDescription:{text:n.ruleDefinition.description||n.ruleName}})),version:"1.0.0"}}}});return JSON.stringify({$schema:"https://json.schemastore.org/sarif-2.1.0.json",runs:e,version:"2.1.0"},null,2)}function Ne(a){if(a.uri)return a.uri.replace(/\\/g,"/");if(a.fsPath){const e=a.fsPath.match(/(?:force-app|src)\/.+$/);return e?e[0].replace(/\\/g,"/"):a.fsPath.replace(/\\/g,"/")}return`flows/${a.name}.flow-meta.xml`}function xe(a){return{startColumn:a.columnNumber??1,startLine:a.lineNumber??1}}function ce(a){switch(a==null?void 0:a.toLowerCase()){case"info":case"note":return"note";case"warning":return"warning";default:return"warning"}}function Le(a){return a&&a.__esModule&&Object.prototype.hasOwnProperty.call(a,"default")?a.default:a}var le={exports:{}},T=le.exports={},L,F;function Y(){throw new Error("setTimeout has not been defined")}function J(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?L=setTimeout:L=Y}catch{L=Y}try{typeof clearTimeout=="function"?F=clearTimeout:F=J}catch{F=J}})();function ue(a){if(L===setTimeout)return setTimeout(a,0);if((L===Y||!L)&&setTimeout)return L=setTimeout,setTimeout(a,0);try{return L(a,0)}catch{try{return L.call(null,a,0)}catch{return L.call(this,a,0)}}}function Fe(a){if(F===clearTimeout)return clearTimeout(a);if((F===J||!F)&&clearTimeout)return F=clearTimeout,clearTimeout(a);try{return F(a)}catch{try{return F.call(null,a)}catch{return F.call(this,a)}}}var D=[],V=!1,U,W=-1;function ke(){!V||!U||(V=!1,U.length?D=U.concat(D):W=-1,D.length&&de())}function de(){if(!V){var a=ue(ke);V=!0;for(var e=D.length;e;){for(U=D,D=[];++W1)for(var t=1;t2){var f=o.lastIndexOf("/");if(f!==o.length-1){f===-1?(o="",i=0):(o=o.slice(0,f),i=o.length-1-o.lastIndexOf("/")),c=d,l=0;continue}}else if(o.length===2||o.length===1){o="",i=0,c=d,l=0;continue}}n&&(o.length>0?o+="/..":o="..",i=2)}else o.length>0?o+="/"+r.slice(c+1,d):o=r.slice(c+1,d),i=d-c-1;c=d,l=0}else u===46&&l!==-1?++l:l=-1}return o}function t(r,n){var o=n.dir||n.root,i=n.base||(n.name||"")+(n.ext||"");return o?o===n.root?o+i:o+r+i:i}var s={resolve:function(){for(var n="",o=!1,i,c=arguments.length-1;c>=-1&&!o;c--){var l;c>=0?l=arguments[c]:(i===void 0&&(i=Z.cwd()),l=i),a(l),l.length!==0&&(n=l+"/"+n,o=l.charCodeAt(0)===47)}return n=e(n,!o),o?n.length>0?"/"+n:"/":n.length>0?n:"."},normalize:function(n){if(a(n),n.length===0)return".";var o=n.charCodeAt(0)===47,i=n.charCodeAt(n.length-1)===47;return n=e(n,!o),n.length===0&&!o&&(n="."),n.length>0&&i&&(n+="/"),o?"/"+n:n},isAbsolute:function(n){return a(n),n.length>0&&n.charCodeAt(0)===47},join:function(){if(arguments.length===0)return".";for(var n,o=0;o0&&(n===void 0?n=i:n+="/"+i)}return n===void 0?".":s.normalize(n)},relative:function(n,o){if(a(n),a(o),n===o||(n=s.resolve(n),o=s.resolve(o),n===o))return"";for(var i=1;ib){if(o.charCodeAt(u+p)===47)return o.slice(u+p+1);if(p===0)return o.slice(u+p)}else l>b&&(n.charCodeAt(i+p)===47?m=p:p===0&&(m=0));break}var S=n.charCodeAt(i+p),R=o.charCodeAt(u+p);if(S!==R)break;S===47&&(m=p)}var C="";for(p=i+m+1;p<=c;++p)(p===c||n.charCodeAt(p)===47)&&(C.length===0?C+="..":C+="/..");return C.length>0?C+o.slice(u+m):(u+=m,o.charCodeAt(u)===47&&++u,o.slice(u))},_makeLong:function(n){return n},dirname:function(n){if(a(n),n.length===0)return".";for(var o=n.charCodeAt(0),i=o===47,c=-1,l=!0,u=n.length-1;u>=1;--u)if(o=n.charCodeAt(u),o===47){if(!l){c=u;break}}else l=!1;return c===-1?i?"/":".":i&&c===1?"//":n.slice(0,c)},basename:function(n,o){if(o!==void 0&&typeof o!="string")throw new TypeError('"ext" argument must be a string');a(n);var i=0,c=-1,l=!0,u;if(o!==void 0&&o.length>0&&o.length<=n.length){if(o.length===n.length&&o===n)return"";var d=o.length-1,f=-1;for(u=n.length-1;u>=0;--u){var b=n.charCodeAt(u);if(b===47){if(!l){i=u+1;break}}else f===-1&&(l=!1,f=u+1),d>=0&&(b===o.charCodeAt(d)?--d===-1&&(c=u):(d=-1,c=f))}return i===c?c=f:c===-1&&(c=n.length),n.slice(i,c)}else{for(u=n.length-1;u>=0;--u)if(n.charCodeAt(u)===47){if(!l){i=u+1;break}}else c===-1&&(l=!1,c=u+1);return c===-1?"":n.slice(i,c)}},extname:function(n){a(n);for(var o=-1,i=0,c=-1,l=!0,u=0,d=n.length-1;d>=0;--d){var f=n.charCodeAt(d);if(f===47){if(!l){i=d+1;break}continue}c===-1&&(l=!1,c=d+1),f===46?o===-1?o=d:u!==1&&(u=1):o!==-1&&(u=-1)}return o===-1||c===-1||u===0||u===1&&o===c-1&&o===i+1?"":n.slice(o,c)},format:function(n){if(n===null||typeof n!="object")throw new TypeError('The "pathObject" argument must be of type Object. Received type '+typeof n);return t("/",n)},parse:function(n){a(n);var o={root:"",dir:"",base:"",ext:"",name:""};if(n.length===0)return o;var i=n.charCodeAt(0),c=i===47,l;c?(o.root="/",l=1):l=0;for(var u=-1,d=0,f=-1,b=!0,m=n.length-1,p=0;m>=l;--m){if(i=n.charCodeAt(m),i===47){if(!b){d=m+1;break}continue}f===-1&&(b=!1,f=m+1),i===46?u===-1?u=m:p!==1&&(p=1):u!==-1&&(p=-1)}return u===-1||f===-1||p===0||p===1&&u===f-1&&u===d+1?f!==-1&&(d===0&&c?o.base=o.name=n.slice(1,f):o.base=o.name=n.slice(d,f)):(d===0&&c?(o.name=n.slice(1,u),o.base=n.slice(1,f)):(o.name=n.slice(d,u),o.base=n.slice(d,f)),o.ext=n.slice(u,f)),d>0?o.dir=n.slice(0,d-1):c&&(o.dir="/"),o},sep:"/",delimiter:":",win32:null,posix:null};return s.posix=s,K=s,K}var z=De(),N=(a=>(a.ATTRIBUTE="attribute",a.VARIABLE="variable",a.RESOURCE="resource",a.NODE="node",a))(N||{});class B{constructor(e,t,s,r={}){this.element={},this.element=r,this.subtype=t,this.name=s,this.metaType=e}}class Me extends B{constructor(e,t,s){super(N.ATTRIBUTE,t,e,s)}}class w{constructor(e,t,s){this.element={},this.processed=!1,this.type=e,this.element=t,this.childName=s.childName?s.childName:void 0,this.childOf=s.childOf?s.childOf:void 0,t&&"targetReference"in t&&(this.reference=t.targetReference),t&&"connector"in t&&(this.connectorTargetReference=t.connector)}}const ee={actionCalls:{apex:"⚙️",emailAlert:"📧",emailSimple:"📧",submit:"⚡",default:"⚡"},assignments:{default:"🟰"},collectionProcessors:{FilterCollectionProcessor:"🔽",SortCollectionProcessor:"🔃",default:"📦"},customErrors:{default:"🚫"},decisions:{default:"🔀"},loops:{default:"🔁"},recordCreates:{default:"➕"},recordDeletes:{default:"🗑️"},recordLookups:{default:"🔍"},recordUpdates:{default:"🛠️"},screens:{default:"💻"},subflows:{default:"🔗"},transforms:{default:"♻️"}},he={actionCalls:{apex:"[A]",emailAlert:"[E]",emailSimple:"[E]",submit:"[!]",default:"[!]"},assignments:{default:"[=]"},collectionProcessors:{FilterCollectionProcessor:"[F]",SortCollectionProcessor:"[S]",default:"[C]"},customErrors:{default:"[X]"},decisions:{default:"[?]"},loops:{default:"[L]"},recordCreates:{default:"[+]"},recordDeletes:{default:"[-]"},recordLookups:{default:"[S]"},recordUpdates:{default:"[U]"},screens:{default:"[#]"},subflows:{default:"[>]"},transforms:{default:"[T]"}},$=class $ extends B{constructor(e,t,s){const r=t==="start"?"flowstart":e;super(N.NODE,t,r,s),this.connectors=[],this.label=s.label,this.description=s.description,this.locationX=s.locationX,this.locationY=s.locationY,this.extractTypeSpecificProperties(t,s),this.connectors=this.getConnectors(t,s),this.faultConnector=this.connectors.find(n=>n.type==="faultConnector")}static setIconConfig(e){$.iconConfig=e}static useAsciiIcons(){$.iconConfig=he}static useDefaultIcons(){$.iconConfig=ee}extractTypeSpecificProperties(e,t){switch(e){case"actionCalls":this.actionType=t.actionType,this.actionName=t.actionName;break;case"recordCreates":case"recordUpdates":case"recordDeletes":case"recordLookups":this.object=t.object,this.inputReference=t.inputReference,this.outputReference=t.outputReference;break;case"collectionProcessors":this.elementSubtype=t.elementSubtype,this.collectionReference=t.collectionReference;break;case"subflows":this.flowName=t.flowName;break;case"decisions":this.rules=Array.isArray(t.rules)?t.rules:t.rules?[t.rules]:[],this.defaultConnectorLabel=t.defaultConnectorLabel;break;case"loops":this.collectionReference=t.collectionReference,this.iterationOrder=t.iterationOrder;break;case"screens":this.fields=Array.isArray(t.fields)?t.fields:t.fields?[t.fields]:[],this.allowPause=t.allowPause,this.showFooter=t.showFooter;break}}getSummary(){var t,s;const e=[];switch(this.subtype){case"actionCalls":this.actionType&&e.push(this.prettifyValue(this.actionType)),this.actionName&&e.push(this.actionName);break;case"recordCreates":case"recordUpdates":case"recordDeletes":case"recordLookups":this.object&&e.push(this.object);break;case"collectionProcessors":this.elementSubtype&&e.push(this.prettifyValue(this.elementSubtype));break;case"decisions":e.push(`${((t=this.rules)==null?void 0:t.length)||0} rule${((s=this.rules)==null?void 0:s.length)!==1?"s":""}`);break;case"loops":this.collectionReference&&e.push(`Loop: ${this.collectionReference}`);break;case"subflows":this.flowName&&e.push(this.flowName);break}return this.description&&e.push(this.description.substring(0,50)+(this.description.length>50?"...":"")),e.join(" • ")}getIcon(){const e=$.iconConfig[this.subtype];if(!e){const r=$.iconConfig.default;return r&&"default"in r?r.default:"•"}const t=this.actionType||this.elementSubtype,s=e;return t&&s[t]?s[t]:s.default||"•"}getTypeLabel(){return{actionCalls:"Action",assignments:"Assignment",collectionProcessors:"Collection",customErrors:"Error",decisions:"Decision",loops:"Loop",recordCreates:"Create",recordDeletes:"Delete",recordLookups:"Get Records",recordUpdates:"Update",screens:"Screen",subflows:"Subflow",transforms:"Transform"}[this.subtype]||this.subtype}prettifyValue(e){return e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()).trim()}getConnectors(e,t){const s=[];if(e==="start"){if(t.connector&&s.push(new w("connector",t.connector,{})),Array.isArray(t.scheduledPaths))for(const r of(t==null?void 0:t.scheduledPaths)||[])r.connector&&s.push(new w("connector",r.connector,{childName:(r==null?void 0:r.name)??"AsyncAfterCommit",childOf:"scheduledPaths"}));else t.scheduledPaths&&s.push(new w("connector",t.scheduledPaths,{childName:t.scheduledPaths.name,childOf:"scheduledPaths"}));return s}else if(e==="decisions"){if(t.defaultConnector&&s.push(new w("defaultConnector",t.defaultConnector,{})),t.rules)if(Array.isArray(t.rules))for(const r of t.rules)r.connector&&s.push(new w("connector",r.connector,{childName:r.name,childOf:"rules"}));else t.rules.connector&&s.push(new w("connector",t.rules.connector,{childName:t.rules.name,childOf:"rules"}));return s}else{if(e==="assignments"||e==="transforms"||e==="customErrors")return t.connector?[new w("connector",t.connector,{})]:[];if(e==="loops")return t.nextValueConnector&&s.push(new w("nextValueConnector",t.nextValueConnector,{})),t.noMoreValuesConnector&&s.push(new w("noMoreValuesConnector",t.noMoreValuesConnector,{})),s;if(e==="actionCalls")return t.connector&&s.push(new w("connector",t.connector,{})),t.faultConnector&&s.push(new w("faultConnector",t.faultConnector,{})),s;if(e==="waits"){if(t.defaultConnector&&s.push(new w("defaultConnector",t.defaultConnector,{})),t.faultConnector&&s.push(new w("faultConnector",t.faultConnector,{})),Array.isArray(t.waitEvents))for(const r of t.waitEvents)r.connector&&s.push(new w("connector",r.connector,{childName:r.name,childOf:"waitEvents"}));return s}else return e==="recordCreates"?(t.connector&&s.push(new w("connector",t.connector,{})),t.faultConnector&&s.push(new w("faultConnector",t.faultConnector,{})),s):e==="recordDeletes"?(t.connector&&s.push(new w("connector",t.connector,{})),t.faultConnector&&s.push(new w("faultConnector",t.faultConnector,{})),s):e==="recordLookups"?(t.connector&&s.push(new w("connector",t.connector,{})),t.faultConnector&&s.push(new w("faultConnector",t.faultConnector,{})),s):e==="recordUpdates"?(t.connector&&s.push(new w("connector",t.connector,{})),t.faultConnector&&s.push(new w("faultConnector",t.faultConnector,{})),s):e==="subflows"?t.connector?[new w("connector",t.connector,{})]:[]:e==="screens"?t.connector?[new w("connector",t.connector,{})]:[]:t.connector?[new w("connector",t.connector,{})]:[]}}};$.iconConfig=ee;let x=$;class te extends B{constructor(e,t,s){super(N.RESOURCE,t,e,s)}}const se={subtypes:{variables:"📊",constants:"🔒",formulas:"🧮",choices:"📋",dynamicChoiceSets:"🔄"},boolean:{true:"✅",false:"⬜"}},me={subtypes:{variables:"[V]",constants:"[C]",formulas:"[F]",choices:"[CH]",dynamicChoiceSets:"[D]"},boolean:{true:"[X]",false:"[ ]"}},P=class P extends B{static setIconConfig(e){P.iconConfig=e}static useAsciiIcons(){P.iconConfig=me}static useDefaultIcons(){P.iconConfig=se}constructor(e,t,s){super(N.VARIABLE,t,e,s),this.dataType=s.dataType,this.isCollection=s.isCollection,this.isInput=s.isInput,this.isOutput=s.isOutput,this.objectType=s.objectType,this.description=s.description,t==="constants"?this.value=s.value:t==="formulas"&&(this.value=s.expression)}getIcon(){return P.iconConfig.subtypes[this.subtype]||"📊"}getBooleanIcon(e){return e===!0?P.iconConfig.boolean.true:e===!1?P.iconConfig.boolean.false:""}getTypeLabel(){return{variables:"Variable",constants:"Constant",formulas:"Formula",choices:"Choice",dynamicChoiceSets:"Dynamic Choice"}[this.subtype]||this.subtype}toTableRow(){return`| ${[this.name,this.dataType||"",this.getBooleanIcon(this.isCollection),this.getBooleanIcon(this.isInput),this.getBooleanIcon(this.isOutput),this.objectType||"",this.description||""].join(" | ")} |`}toMarkdownTable(){let e=`| Property | Value | +var lightningflowscanner=(()=>{var Va=Object.create;var Ze=Object.defineProperty;var $a=Object.getOwnPropertyDescriptor;var ka=Object.getOwnPropertyNames;var Ua=Object.getPrototypeOf,Ba=Object.prototype.hasOwnProperty;var Wa=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(i){throw t=[i],i}};var P=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},ja=(r,e)=>{for(var t in e)Ze(r,t,{get:e[t],enumerable:!0})},Ye=(r,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of ka(e))!Ba.call(r,l)&&l!==t&&Ze(r,l,{get:()=>e[l],enumerable:!(i=$a(e,l))||i.enumerable});return r},Ft=(r,e,t)=>(Ye(r,e,"default"),t&&Ye(t,e,"default")),Ha=(r,e,t)=>(t=r!=null?Va(Ua(r)):{},Ye(e||!r||!r.__esModule?Ze(t,"default",{value:r,enumerable:!0}):t,r)),si=r=>Ye(Ze({},"__esModule",{value:!0}),r);var Lt=P(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});function Ga(r,e){for(var t in e)Object.defineProperty(r,t,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,t).get})}Ga(Dt,{get DetailLevel(){return za},get SEVERITY_ORDER(){return It},get countThresholdViolations(){return Xa},get filterByThreshold(){return Ya},get meetsThreshold(){return Mt}});var za=(function(r){return r.ENRICHED="enriched",r.SIMPLE="simple",r})({}),It=["error","warning","note"];function Mt(r,e){if(e==="never")return!1;let t=r||"warning",i=It.indexOf(t),l=It.indexOf(e);return i>=0&&i<=l}function Xa(r,e){return e==="never"?0:r.filter(t=>Mt(t.severity,e)).length}function Ya(r,e){return e==="never"?r:r.filter(t=>Mt(t.severity,e))}});var Qe=P(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});Object.defineProperty(qt,"Compiler",{enumerable:!0,get:function(){return Qa}});function Za(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}var Qa=class{traverseFlow(e,t,i,l,s){let d=[e];for(;d.length>0;){let y=[];for(let g of d)if(!this.visitedElements.has(g)){let b=i.get(g);b&&(t(b),this.visitedElements.add(g),y.push(...this.findNextElements(g,l,i,s)))}if(y.length===0)break;d=y}}findNextElements(e,t,i,l){let s=[],d=t.get(e);if(d)for(let y of d)y!==l&&i.has(y)&&s.push(y);return s}constructor(){Za(this,"visitedElements",void 0),this.visitedElements=new Set}}});var ai=P(Vt=>{"use strict";Object.defineProperty(Vt,"__esModule",{value:!0});Object.defineProperty(Vt,"exportDetails",{enumerable:!0,get:function(){return il}});function Ja(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Ka(r){for(var e=1;e=0)&&Object.prototype.propertyIsEnumerable.call(r,i)&&(t[i]=r[i])}return t}function nl(r,e){if(r==null)return{};var t={},i=Object.keys(r),l,s;for(s=0;s=0)&&(t[l]=r[l]);return t}function il(r,e=!1){return r.flatMap(t=>{let i=t.flow,l=i.name||i.label,s=i.fsPath?i.fsPath.replace(/\\/g,"/"):i.uri?i.uri.replace(/\\/g,"/"):`${i.name}.flow-meta.xml`;return t.ruleResults.filter(d=>{var y;return d.occurs&&((y=d.details)===null||y===void 0?void 0:y.length)}).flatMap(d=>d.details.map(y=>{let{details:g}=y,b=rl(y,["details"]);var w;let x=tl(Ka({},b),{flowFile:s,flowName:l,ruleId:d.ruleId,ruleName:d.ruleName,severity:(w=d.severity)!==null&&w!==void 0?w:"warning",message:d.message||d.ruleDefinition.description,messageUrl:d.messageUrl});return e&&g&&("dataType"in g&&(x.dataType=g.dataType),"locationX"in g&&(x.locationX=String(g.locationX)),"locationY"in g&&(x.locationY=String(g.locationY)),"connectsTo"in g&&(x.connectsTo=Array.isArray(g.connectsTo)?g.connectsTo.join(", "):String(g.connectsTo)),"expression"in g&&(x.expression=g.expression)),x}))})}});var ci=P($t=>{"use strict";Object.defineProperty($t,"__esModule",{value:!0});Object.defineProperty($t,"exportSarif",{enumerable:!0,get:function(){return al}});function ol(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function sl(r){for(var e=1;e{let i=t.flow,l=ll(i);return{artifacts:[{location:{uri:l},sourceLanguage:"xml"}],results:t.ruleResults.filter(s=>s.occurs).flatMap(s=>s.details.map(d=>({level:li(s.severity),locations:[{physicalLocation:{artifactLocation:{index:0,uri:l},region:cl(d)}}],message:{text:s.errorMessage||(s.message||s.ruleDefinition.description?`${s.message||s.ruleDefinition.description} (${d.name})`:`${s.ruleId} in ${d.name}`)},properties:sl({element:d.name,flow:i.name,type:d.type},d.details),ruleId:s.ruleId}))),tool:{driver:{informationUri:"https://github.com/Flow-Scanner/lightning-flow-scanner",name:"Lightning Flow Scanner",rules:t.ruleResults.filter(s=>s.occurs).map(s=>({defaultConfiguration:{level:li(s.severity)},fullDescription:{text:s.message||s.ruleDefinition.description||""},id:s.ruleId,shortDescription:{text:s.message||s.ruleDefinition.description||s.ruleId}})),version:"1.0.0"}}}});return JSON.stringify({$schema:"https://json.schemastore.org/sarif-2.1.0.json",runs:e,version:"2.1.0"},null,2)}function ll(r){if(r.uri)return r.uri.replace(/\\/g,"/");if(r.fsPath){let e=r.fsPath.match(/(?:force-app|src)\/.+$/);return e?e[0].replace(/\\/g,"/"):r.fsPath.replace(/\\/g,"/")}return`flows/${r.name}.flow-meta.xml`}function cl(r){var e,t;return{startColumn:(e=r.columnNumber)!==null&&e!==void 0?e:1,startLine:(t=r.lineNumber)!==null&&t!==void 0?t:1}}function li(r){switch(r?.toLowerCase()){case"info":case"note":return"note";case"warning":return"warning";default:return"warning"}}});var kt=P((wf,ui)=>{(()=>{"use strict";var r={d:(a,n)=>{for(var o in n)r.o(n,o)&&!r.o(a,o)&&Object.defineProperty(a,o,{enumerable:!0,get:n[o]})},o:(a,n)=>Object.prototype.hasOwnProperty.call(a,n),r:a=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})}},e={};r.r(e),r.d(e,{XMLBuilder:()=>La,XMLParser:()=>Pa,XMLValidator:()=>qa});let t=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",i=new RegExp("^["+t+"]["+t+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$"),l=function(a){return i.exec(a)!=null},s=["hasOwnProperty","toString","valueOf","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__"],d=["__proto__","constructor","prototype"],y={allowBooleanAttributes:!1,unpairedTags:[]};function g(a,n){n=Object.assign({},y,n);let o=[],c=!1,u=!1;a[0]==="\uFEFF"&&(a=a.substr(1));for(let p=0;p"&&a[p]!==" "&&a[p]!==" "&&a[p]!==` +`&&a[p]!=="\r";p++)f+=a[p];if(f=f.trim(),f[f.length-1]==="/"&&(f=f.substring(0,f.length-1),p--),!we(f)){let O;return O=f.trim().length===0?"Invalid space after '<'.":"Tag '"+f+"' is an invalid name.",F("InvalidTag",O,j(a,p))}let v=$(a,p);if(v===!1)return F("InvalidAttr","Attributes for '"+f+"' have open quote.",j(a,p));let _=v.value;if(p=v.index,_[_.length-1]==="/"){let O=p-_.length;_=_.substring(0,_.length-1);let R=M(_,n);if(R!==!0)return F(R.err.code,R.err.msg,j(a,O+R.err.line));c=!0}else if(h){if(!v.tagClosed)return F("InvalidTag","Closing tag '"+f+"' doesn't have proper closing.",j(a,p));if(_.trim().length>0)return F("InvalidTag","Closing tag '"+f+"' can't have attributes or invalid starting.",j(a,m));if(o.length===0)return F("InvalidTag","Closing tag '"+f+"' has not been opened.",j(a,m));{let O=o.pop();if(f!==O.tagName){let R=j(a,O.tagStartPos);return F("InvalidTag","Expected closing tag '"+O.tagName+"' (opened in line "+R.line+", col "+R.col+") instead of closing tag '"+f+"'.",j(a,m))}o.length==0&&(u=!0)}}else{let O=M(_,n);if(O!==!0)return F(O.err.code,O.err.msg,j(a,p-_.length+O.err.line));if(u===!0)return F("InvalidXml","Multiple possible root nodes found.",j(a,p));n.unpairedTags.indexOf(f)!==-1||o.push({tagName:f,tagStartPos:m}),c=!0}for(p++;p0)||F("InvalidXml","Invalid '"+JSON.stringify(o.map(p=>p.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):F("InvalidXml","Start tag expected.",1)}function b(a){return a===" "||a===" "||a===` +`||a==="\r"}function w(a,n){let o=n;for(;n5&&c==="xml")return F("InvalidXml","XML declaration allowed only at the start of the document.",j(a,n));if(a[n]=="?"&&a[n+1]==">"){n++;break}continue}return n}function x(a,n){if(a.length>n+5&&a[n+1]==="-"&&a[n+2]==="-"){for(n+=3;n"){n+=2;break}}else if(a.length>n+8&&a[n+1]==="D"&&a[n+2]==="O"&&a[n+3]==="C"&&a[n+4]==="T"&&a[n+5]==="Y"&&a[n+6]==="P"&&a[n+7]==="E"){let o=1;for(n+=8;n"&&(o--,o===0))break}else if(a.length>n+9&&a[n+1]==="["&&a[n+2]==="C"&&a[n+3]==="D"&&a[n+4]==="A"&&a[n+5]==="T"&&a[n+6]==="A"&&a[n+7]==="["){for(n+=8;n"){n+=2;break}}return n}let C='"',N="'";function $(a,n){let o="",c="",u=!1;for(;n"&&c===""){u=!0;break}o+=a[n]}return c===""&&{value:o,index:n,tagClosed:u}}function M(a,n){let o=(function(u){let p=[],m=u.length,h=0;for(;h=m)break;if(u[h]==="="){h=f+1;continue}let v=u.slice(f,h),_=h;for(;hs.includes(a)?"__"+a:a,je={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0,unicode:!1},tagValueProcessor:function(a,n){return n},attributeValueProcessor:function(a,n){return n},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,entityDecoder:null,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(a,n,o){return a},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Te};function He(a,n){if(typeof a!="string")return;let o=a.toLowerCase();if(s.some(c=>o===c.toLowerCase()))throw new Error(`[SECURITY] Invalid ${n}: "${a}" is a reserved JavaScript keyword that could cause prototype pollution`);if(d.some(c=>o===c.toLowerCase()))throw new Error(`[SECURITY] Invalid ${n}: "${a}" is a reserved JavaScript keyword that could cause prototype pollution`)}function Ae(a,n){return typeof a=="boolean"?{enabled:a,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:typeof a=="object"&&a!==null?{enabled:a.enabled!==!1,maxEntitySize:Math.max(1,a.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,a.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,a.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,a.maxExpandedLength??1e5),maxEntityCount:Math.max(1,a.maxEntityCount??1e3),allowedTags:a.allowedTags??null,tagFilter:a.tagFilter??null,appliesTo:a.appliesTo??"all"}:Ae(!0)}let ht=function(a){let n=Object.assign({},je,a),o=[{value:n.attributeNamePrefix,name:"attributeNamePrefix"},{value:n.attributesGroupName,name:"attributesGroupName"},{value:n.textNodeName,name:"textNodeName"},{value:n.cdataPropName,name:"cdataPropName"},{value:n.commentPropName,name:"commentPropName"}];for(let{value:c,name:u}of o)c&&He(c,u);return n.onDangerousProperty===null&&(n.onDangerousProperty=Te),n.processEntities=Ae(n.processEntities,n.htmlEntities),n.unpairedTagsSet=new Set(n.unpairedTags),n.stopNodes&&Array.isArray(n.stopNodes)&&(n.stopNodes=n.stopNodes.map(c=>typeof c=="string"&&c.startsWith("*.")?".."+c.substring(2):c)),n},se;se=typeof Symbol!="function"?"@@xmlMetadata":Symbol("XML Node Metadata");class ae{constructor(n){this.tagname=n,this.child=[],this[":@"]=Object.create(null)}add(n,o){n==="__proto__"&&(n="#__proto__"),this.child.push({[n]:o})}addChild(n,o){n.tagname==="__proto__"&&(n.tagname="#__proto__"),n[":@"]&&Object.keys(n[":@"]).length>0?this.child.push({[n.tagname]:n.child,":@":n[":@"]}):this.child.push({[n.tagname]:n.child}),this.addStartIndex(o)}addStartIndex(n){n!==void 0&&(this.child[this.child.length-1][se]={startIndex:n})}addEndIndex(n){let o=this.child[this.child.length-1];o!==void 0&&o[se]!==void 0&&o[se].endIndex===void 0&&(o[se].endIndex=n)}static getMetaDataSymbol(){return se}}let Dn=":A-Za-z_\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD",Ln=":A-Za-z_\xC0-\u02FF\u0370-\u037D\u037F-\u0486\u0488-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}",qs=Ln+"\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040",mt=(a,n,o="")=>{let c=`[${a.replace(":","")}][${n.replace(":","")}]*`;return{name:new RegExp(`^[${a}][${n}]*$`,o),ncName:new RegExp(`^${c}$`,o),qName:new RegExp(`^${c}(?::${c})?$`,o),nmToken:new RegExp(`^[${n}]+$`,o),nmTokens:new RegExp(`^[${n}]+(?:\\s+[${n}]+)*$`,o)}},Vs=mt(Dn,Dn+"\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040"),$s=mt(Ln,qs,"u"),qn=":A-Za-z_",ks=mt(qn,qn+"\\-\\.\\d"),Vn=(a,{xmlVersion:n="1.0",asciiOnly:o=!1}={})=>((c="1.0",u=!1)=>u?ks:c==="1.1"?$s:Vs)(n,o).qName.test(a);class Us{constructor(n,o){this.suppressValidationErr=!n,this.options=n,this.xmlVersion=o||1}setXmlVersion(n=1){this.xmlVersion=n}readDocType(n,o){let c=Object.create(null),u=0;if(n[o+3]!=="O"||n[o+4]!=="C"||n[o+5]!=="T"||n[o+6]!=="Y"||n[o+7]!=="P"||n[o+8]!=="E")throw new Error("Invalid Tag instead of DOCTYPE");{o+=9;let p=1,m=!1,h=!1,f=null,v="";for(;o"){if(h?n[o-1]==="-"&&n[o-2]==="-"&&(h=!1,p--):p--,p===0)break}else n[o]==="["?m=!0:v+=n[o];else{if(m&&pe(n,"!ENTITY",o)){let _,O;if(o+=7,[_,O,o]=this.readEntityExp(n,o+1,this.suppressValidationErr),O.indexOf("&")===-1){if(this.options.enabled!==!1&&this.options.maxEntityCount!=null&&u>=this.options.maxEntityCount)throw new Error(`Entity count (${u+1}) exceeds maximum allowed (${this.options.maxEntityCount})`);c[_]=O,u++}}else if(m&&pe(n,"!ELEMENT",o)){o+=8;let{index:_}=this.readElementExp(n,o+1);o=_}else if(m&&pe(n,"!ATTLIST",o))o+=8;else if(m&&pe(n,"!NOTATION",o)){o+=9;let{index:_}=this.readNotationExp(n,o+1,this.suppressValidationErr);o=_}else{if(!pe(n,"!--",o))throw new Error("Invalid DOCTYPE");h=!0}p++,v=""}else f=n[o],v+=n[o];else n[o]===f&&(f=null),v+=n[o];if(f!==null||p!==0)throw new Error("Unclosed DOCTYPE")}return{entities:c,i:o}}readEntityExp(n,o){let c=o=G(n,o);for(;othis.options.maxEntitySize)throw new Error(`Entity "${u}" size (${p.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return[u,p,--o]}readNotationExp(n,o){let c=o=G(n,o);for(;o{for(;n=48&&f<=57||f===45)){if(f=55296&&f<=56319){if(h+1=56320&&v<=57343){let _=65536+(f-55296<<10)+(v-56320);if(gt.has(_)){p=h;break}}}}else if(yt[f-Ne]!==255||Ge.has(f)){p=h;break}}}if(p===-1)return c;let m=[];p>0&&m.push(c.slice(0,p));for(let h=p;h=48&&f<=57||f===45){m.push(c[h]);continue}if(f=55296&&f<=56319){if(h+1=56320&&_<=57343){let O=65536+(f-55296<<10)+(_-56320),R=gt.get(O);if(R!==void 0){m.push(String.fromCharCode(R+48)),h++;continue}}}m.push(c[h]);continue}if(Ge.has(f)){m.push("-");continue}let v=yt[f-Ne];m.push(v!==255?String.fromCharCode(v+48):c[h])}return m.join("")})(o),o==="0"))return 0;if(n.hex&&Ws.test(o))return vt(o,16);if(n.binary&&js.test(o))return vt(o,2);if(n.octal&&Hs.test(o))return vt(o,8);if(isFinite(o)){if(o.includes("e")||o.includes("E"))return(function(c,u,p){if(!p.eNotation)return c;let m=u.match(Ys);if(m){let h=m[1]||"",f=m[3].indexOf("e")===-1?"E":"e",v=m[2],_=h?c[v.length+1]===f:c[v.length]===f;return v.length>1&&_?c:(v.length!==1||!m[3].startsWith(`.${f}`)&&m[3][0]!==f)&&v.length>0?p.leadingZeros&&!_?(u=(m[1]||"")+m[3],Number(u)):c:Number(u)}return c})(a,o,n);{let c=Gs.exec(o);if(c){let u=c[1]||"",p=c[2],m=(function(f){if(f&&f.indexOf(".")!==-1){let v=f.length;for(;v>0&&f.charCodeAt(v-1)===48;)v--;return(f=f.slice(0,v))==="."?f="0":f[0]==="."?f="0"+f:f[f.length-1]==="."&&(f=f.substring(0,f.length-1)),f}return f})(c[3]),h=u?a[p.length+1]===".":a[p.length]===".";if(!n.leadingZeros&&(p.length>1||p.length===1&&!h))return a;{let f=Number(o),v=String(f);if(f===0)return f;if(v.search(/[eE]/)!==-1)return n.eNotation?f:a;if(o.indexOf(".")!==-1)return v==="0"||v===m||v===`${u}${m}`?f:a;let _=p?m:o;return p?_===v||u+_===v?f:a:_===v||_===u+v?f:a}}return a}}return(function(c,u,p){let m=u===1/0;switch(p.infinity.toLowerCase()){case"null":return null;case"infinity":return u;case"string":return m?"Infinity":"-Infinity";default:return c}})(a,Number(o),n)}let Ys=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function vt(a,n){let o=a.trim();if(n!==2&&n!==8||(a=o.substring(2)),parseInt)return parseInt(a,n);if(Number.parseInt)return Number.parseInt(a,n);if(window&&window.parseInt)return window.parseInt(a,n);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}class Zs{constructor(n){this._matcher=n}get separator(){return this._matcher.separator}getCurrentTag(){let n=this._matcher.path;return n.length>0?n[n.length-1].tag:void 0}getCurrentNamespace(){let n=this._matcher.path;return n.length>0?n[n.length-1].namespace:void 0}getAttrValue(n){let o=this._matcher.path;if(o.length!==0)return o[o.length-1].values?.[n]}hasAttr(n){let o=this._matcher.path;if(o.length===0)return!1;let c=o[o.length-1];return c.values!==void 0&&n in c.values}getAnyParentAttr(n){return this._matcher.getAnyParentAttr(n)}hasAnyParentAttr(n){return this._matcher.hasAnyParentAttr(n)}getPosition(){let n=this._matcher.path;return n.length===0?-1:n[n.length-1].position??0}getCounter(){let n=this._matcher.path;return n.length===0?-1:n[n.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this._matcher.path.length}toString(n,o=!0){return this._matcher.toString(n,o)}toArray(){return this._matcher.path.map(n=>n.tag)}matches(n){return this._matcher.matches(n)}matchesAny(n){return n.matchesAny(this._matcher)}}class bt{constructor(n={}){this.separator=n.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new Zs(this),this._keptAttrs=[]}push(n,o=null,c=null,u=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);let p=this.path.length,m=this.siblingStacks[p];m||(m={counts:new Map,total:0},this.siblingStacks[p]=m);let h=c?`${c}:${n}`:n,f=m.counts.get(h)||0,v=m.total;m.counts.set(h,f+1),m.total++;let _={tag:n,position:v,counter:f};c!=null&&(_.namespace=c),o!=null&&(_.values=o),this.path.push(_);let O=this.path.length,R=u!==null?u.keep:null;if(R!=null&&R.length>0&&o)for(let E=0;Ethis.path.length+1&&(this.siblingStacks.length=this.path.length+1);let o=this.path.length+1;for(;this._keptAttrs.length>0&&this._keptAttrs[this._keptAttrs.length-1].depth>=o;)this._keptAttrs.pop();return n}updateCurrent(n){if(this.path.length>0){let o=this.path[this.path.length-1];n!=null&&(o.values=n)}}getCurrentTag(){return this.path.length>0?this.path[this.path.length-1].tag:void 0}getCurrentNamespace(){return this.path.length>0?this.path[this.path.length-1].namespace:void 0}getAttrValue(n){if(this.path.length!==0)return this.path[this.path.length-1].values?.[n]}hasAttr(n){if(this.path.length===0)return!1;let o=this.path[this.path.length-1];return o.values!==void 0&&n in o.values}getAnyParentAttr(n){let o=this._keptAttrs;for(let c=o.length-1;c>=0;c--)if(o[c].name===n)return o[c].value}hasAnyParentAttr(n){let o=this._keptAttrs;for(let c=o.length-1;c>=0;c--)if(o[c].name===n)return!0;return!1}getPosition(){return this.path.length===0?-1:this.path[this.path.length-1].position??0}getCounter(){return this.path.length===0?-1:this.path[this.path.length-1].counter??0}getIndex(){return this.getPosition()}getDepth(){return this.path.length}toString(n,o=!0){let c=n||this.separator;if(c===this.separator&&o===!0){if(this._pathStringCache!==null)return this._pathStringCache;let u=this.path.map(p=>p.namespace?`${p.namespace}:${p.tag}`:p.tag).join(c);return this._pathStringCache=u,u}return this.path.map(u=>o&&u.namespace?`${u.namespace}:${u.tag}`:u.tag).join(c)}toArray(){return this.path.map(n=>n.tag)}reset(){this._pathStringCache=null,this.path=[],this.siblingStacks=[],this._keptAttrs=[]}matches(n){let o=n.segments;return o.length!==0&&(n.hasDeepWildcard()?this._matchWithDeepWildcard(o):this._matchSimple(o))}_matchSimple(n){if(this.path.length!==n.length)return!1;for(let o=0;o=0&&o>=0;){let u=n[c];if(u.type==="deep-wildcard"){if(c--,c<0)return!0;let p=n[c],m=!1;for(let h=o;h>=0;h--)if(this._matchSegment(p,this.path[h],h===this.path.length-1)){o=h-1,c--,m=!0;break}if(!m)return!1}else{if(!this._matchSegment(u,this.path[o],o===this.path.length-1))return!1;o--,c--}}return c<0}_matchSegment(n,o,c){if(n.tag!=="*"&&n.tag!==o.tag||n.namespace!==void 0&&n.namespace!=="*"&&n.namespace!==o.namespace||n.attrName!==void 0&&(!c||!o.values||!(n.attrName in o.values)||n.attrValue!==void 0&&String(o.values[n.attrName])!==String(n.attrValue)))return!1;if(n.position!==void 0){if(!c)return!1;let u=o.counter??0;if(n.position==="first"&&u!==0||n.position==="odd"&&u%2!=1||n.position==="even"&&u%2!=0||n.position==="nth"&&u!==n.positionValue)return!1}return!0}matchesAny(n){return n.matchesAny(this)}snapshot(){return{path:this.path.map(n=>({...n})),siblingStacks:this.siblingStacks.map(n=>n&&{counts:new Map(n.counts),total:n.total}),keptAttrs:this._keptAttrs.map(n=>({...n}))}}restore(n){this._pathStringCache=null,this.path=n.path.map(o=>({...o})),this.siblingStacks=n.siblingStacks.map(o=>o&&{counts:new Map(o.counts),total:o.total}),this._keptAttrs=(n.keptAttrs||[]).map(o=>({...o}))}readOnly(){return this._view}}class _e{constructor(n,o={},c){this.pattern=n,this.separator=o.separator||".",this.segments=this._parse(n),this.data=c,this._hasDeepWildcard=this.segments.some(u=>u.type==="deep-wildcard"),this._hasAttributeCondition=this.segments.some(u=>u.attrName!==void 0),this._hasPositionSelector=this.segments.some(u=>u.position!==void 0)}_parse(n){let o=[],c=0,u="";for(;c",lt:"<",quot:'"'},Ks={nbsp:"\xA0",copy:"\xA9",reg:"\xAE",trade:"\u2122",mdash:"\u2014",ndash:"\u2013",hellip:"\u2026",laquo:"\xAB",raquo:"\xBB",lsquo:"\u2018",rsquo:"\u2019",ldquo:"\u201C",rdquo:"\u201D",bull:"\u2022",para:"\xB6",sect:"\xA7",deg:"\xB0",frac12:"\xBD",frac14:"\xBC",frac34:"\xBE"},ze=Object.freeze({ALLOW:"allow",BLOCK:"block",THROW:"throw"}),ea=new Set("!?\\\\/[]$%{}^&*()<>|+");function kn(a){if(a[0]==="#")throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${a}"`);for(let n of a)if(ea.has(n))throw new Error(`[EntityReplacer] Invalid character '${n}' in entity name: "${a}"`);return a}function Fe(...a){let n=Object.create(null);for(let o of a)if(o)for(let c of Object.keys(o)){let u=o[c];if(typeof u=="string")n[c]=u;else if(u&&typeof u=="object"&&u.val!==void 0){let p=u.val;typeof p=="string"&&(n[c]=p)}}return n}let fe="external",Xe="base",wt="all",X=Object.freeze({allow:0,leave:1,remove:2,throw:3}),ta=new Set([9,10,13]);class ra{constructor(n={}){var o;this._limit=n.limit||{},this._maxTotalExpansions=this._limit.maxTotalExpansions||0,this._maxExpandedLength=this._limit.maxExpandedLength||0,this._postCheck=typeof n.postCheck=="function"?n.postCheck:u=>u,this._limitTiers=(o=this._limit.applyLimitsTo??fe)&&o!==fe?o===wt?new Set([wt]):o===Xe?new Set([Xe]):Array.isArray(o)?new Set(o):new Set([fe]):new Set([fe]),this._numericAllowed=n.numericAllowed??!0,this._baseMap=Fe($n,n.namedEntities||null),this._externalMap=Object.create(null),this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this._removeSet=new Set(n.remove&&Array.isArray(n.remove)?n.remove:[]),this._leaveSet=new Set(n.leave&&Array.isArray(n.leave)?n.leave:[]);let c=(function(u){if(!u)return{xmlVersion:1,onLevel:X.allow,nullLevel:X.remove};let p=u.xmlVersion===1.1?1.1:1,m=X[u.onNCR]??X.allow,h=X[u.nullNCR]??X.remove;return{xmlVersion:p,onLevel:m,nullLevel:Math.max(h,X.remove)}})(n.ncr);this._ncrXmlVersion=c.xmlVersion,this._ncrOnLevel=c.onLevel,this._ncrNullLevel=c.nullLevel,this._onExternalEntity=typeof n.onExternalEntity=="function"?n.onExternalEntity:null,this._onInputEntity=typeof n.onInputEntity=="function"?n.onInputEntity:null}_applyRegistrationHook(n,o,c,u){if(!n)return!0;let p=n(o,c);if(p===ze.BLOCK)return!1;if(p===ze.THROW)throw new Error(`[EntityDecoder] Registration of ${u} entity "&${o};" was rejected by hook`);return!0}setExternalEntities(n){if(n)for(let u of Object.keys(n))kn(u);if(!this._onExternalEntity)return void(this._externalMap=Fe(n));let o=Fe(n),c=Object.create(null);for(let[u,p]of Object.entries(o))this._applyRegistrationHook(this._onExternalEntity,u,p,"external")&&(c[u]=p);this._externalMap=c}addExternalEntity(n,o){kn(n),typeof o=="string"&&o.indexOf("&")===-1&&this._applyRegistrationHook(this._onExternalEntity,n,o,"external")&&(this._externalMap[n]=o)}addInputEntities(n){if(this._totalExpansions=0,this._expandedLength=0,!this._onInputEntity)return void(this._inputMap=Fe(n));let o=Fe(n),c=Object.create(null);for(let[u,p]of Object.entries(o))this._applyRegistrationHook(this._onInputEntity,u,p,"input")&&(c[u]=p);this._inputMap=c}reset(){return this._inputMap=Object.create(null),this._totalExpansions=0,this._expandedLength=0,this}setXmlVersion(n){this._ncrXmlVersion=n===1.1?1.1:1}decode(n){if(typeof n!="string"||n.length===0||n.indexOf("&")===-1)return n;let o=n,c=[],u=n.length,p=0,m=0,h=this._maxTotalExpansions>0,f=this._maxExpandedLength>0,v=h||f;for(;m=u||n.charCodeAt(O)!==59){m++;continue}let R=n.slice(m+1,O);if(R.length===0){m++;continue}let E,S;if(this._removeSet.has(R))E="",S===void 0&&(S=fe);else{if(this._leaveSet.has(R)){m++;continue}if(R.charCodeAt(0)===35){let T=this._resolveNCR(R);if(T===void 0){m++;continue}E=T,S=Xe}else{let T=this._resolveName(R);E=T?.value,S=T?.tier}}if(E!==void 0){if(m>p&&c.push(n.slice(p,m)),c.push(E),p=O+1,m=p,v&&this._tierCounts(S)){if(h&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(f){let T=E.length-(R.length+2);if(T>0&&(this._expandedLength+=T,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else m++}p=55296&&n<=57343||this._ncrXmlVersion===1&&n>=1&&n<=31&&!ta.has(n)?X.remove:-1}_applyNCRAction(n,o,c){switch(n){case X.allow:return String.fromCodePoint(c);case X.remove:return"";case X.leave:return;case X.throw:throw new Error(`[EntityDecoder] Prohibited numeric character reference &${o}; (U+${c.toString(16).toUpperCase().padStart(4,"0")})`);default:return String.fromCodePoint(c)}}_resolveNCR(n){let o=n.charCodeAt(1),c;if(c=o===120||o===88?parseInt(n.slice(2),16):parseInt(n.slice(1),10),Number.isNaN(c)||c<0||c>1114111)return;let u=this._classifyNCR(c);if(!this._numericAllowed&&u/]/i},{id:"html-script-close",description:"<\/script closing tag",pattern:/<\/script[\s>]/i},{id:"html-javascript-protocol",description:"javascript: URI scheme (with optional whitespace/encoding)",pattern:/j[\t\n\r ]*a[\t\n\r ]*v[\t\n\r ]*a[\t\n\r ]*s[\t\n\r ]*c[\t\n\r ]*r[\t\n\r ]*i[\t\n\r ]*p[\t\n\r ]*t[\t\n\r ]*:/i},{id:"html-vbscript-protocol",description:"vbscript: URI scheme",pattern:/vbscript[\t\n\r ]*:/i},{id:"html-data-html",description:"data:text/html URI \u2014 can execute scripts in browsers",pattern:/data[\t\n\r ]*:[\t\n\r ]*text\/html/i},{id:"html-data-xhtml",description:"data:application/xhtml+xml URI",pattern:/data[\t\n\r ]*:[\t\n\r ]*application\/xhtml/i},{id:"html-data-svg",description:"data:image/svg+xml URI \u2014 can execute scripts",pattern:/data[\t\n\r ]*:[\t\n\r ]*image\/svg\+xml/i},{id:"html-inline-event-handler",description:"Inline event handler attributes: onclick=, onerror=, onload=, etc.",pattern:/\bon\w{1,30}\s*=/i},{id:"html-entity-obfuscated-script",description:"HTML-entity-encoded