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..a8a8b854 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,6 @@ Name: Lightning Flow Scanner Website: https://lightningflowscanner.org/ -Version: unknown +Version: 6.19.2 Release: unknown Source: https://github.com/Flow-Scanner/lightning-flow-scanner -Comment: UMD distribution of Lightning Flow Scanner Core \ No newline at end of file +Comment: UMD distribution of Lightning Flow Scanner Core 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..30479af2 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 | +"use strict";var lightningflowscanner=(()=>{var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var _t=P(bt=>{"use strict";Object.defineProperty(bt,"__esModule",{value:!0});function Xs(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}Xs(bt,{get DetailLevel(){return Zs},get SEVERITY_ORDER(){return vt},get countThresholdViolations(){return Ys},get filterByThreshold(){return Qs},get meetsThreshold(){return wt}});var Zs=(function(t){return t.ENRICHED="enriched",t.SIMPLE="simple",t})({}),vt=["error","warning","note"];function wt(t,e){if(e==="never")return!1;let r=t||"warning",i=vt.indexOf(r),l=vt.indexOf(e);return i>=0&&i<=l}function Ys(t,e){return e==="never"?0:t.filter(r=>wt(r.severity,e)).length}function Qs(t,e){return e==="never"?t:t.filter(r=>wt(r.severity,e))}});var We=P(Ot=>{"use strict";Object.defineProperty(Ot,"__esModule",{value:!0});Object.defineProperty(Ot,"Compiler",{enumerable:!0,get:function(){return Ks}});function Js(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ks=class{traverseFlow(e,r,i,l,a){let d=[e];for(;d.length>0;){let v=[];for(let y of d)if(!this.visitedElements.has(y)){let _=i.get(y);_&&(r(_),this.visitedElements.add(y),v.push(...this.findNextElements(y,l,i,a)))}if(v.length===0)break;d=v}}findNextElements(e,r,i,l){let a=[],d=r.get(e);if(d)for(let v of d)v!==l&&i.has(v)&&a.push(v);return a}constructor(){Js(this,"visitedElements",void 0),this.visitedElements=new Set}}});var In=P(xt=>{"use strict";Object.defineProperty(xt,"__esModule",{value:!0});Object.defineProperty(xt,"exportDetails",{enumerable:!0,get:function(){return sa}});function ea(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ta(t){for(var e=1;e=0)&&Object.prototype.propertyIsEnumerable.call(t,i)&&(r[i]=t[i])}return r}function oa(t,e){if(t==null)return{};var r={},i=Object.keys(t),l,a;for(a=0;a=0)&&(r[l]=t[l]);return r}function sa(t,e=!1){return t.flatMap(r=>{let i=r.flow,l=i.name||i.label,a=i.fsPath?i.fsPath.replace(/\\/g,"/"):i.uri?i.uri.replace(/\\/g,"/"):`${i.name}.flow-meta.xml`;return r.ruleResults.filter(d=>{var v;return d.occurs&&((v=d.details)===null||v===void 0?void 0:v.length)}).flatMap(d=>d.details.map(v=>{let{details:y}=v,_=ia(v,["details"]);var b;let x=na(ta({},_),{flowFile:a,flowName:l,ruleId:d.ruleId,ruleName:d.ruleName,severity:(b=d.severity)!==null&&b!==void 0?b:"warning",message:d.message||d.ruleDefinition.description,messageUrl:d.messageUrl});return e&&y&&("dataType"in y&&(x.dataType=y.dataType),"locationX"in y&&(x.locationX=String(y.locationX)),"locationY"in y&&(x.locationY=String(y.locationY)),"connectsTo"in y&&(x.connectsTo=Array.isArray(y.connectsTo)?y.connectsTo.join(", "):String(y.connectsTo)),"expression"in y&&(x.expression=y.expression)),x}))})}});var Dn=P(Pt=>{"use strict";Object.defineProperty(Pt,"__esModule",{value:!0});Object.defineProperty(Pt,"exportSarif",{enumerable:!0,get:function(){return ca}});function aa(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function la(t){for(var e=1;e{let i=r.flow,l=ua(i);return{artifacts:[{location:{uri:l},sourceLanguage:"xml"}],results:r.ruleResults.filter(a=>a.occurs).flatMap(a=>a.details.map(d=>({level:Mn(a.severity),locations:[{physicalLocation:{artifactLocation:{index:0,uri:l},region:da(d)}}],message:{text:a.errorMessage||(a.message||a.ruleDefinition.description?`${a.message||a.ruleDefinition.description} (${d.name})`:`${a.ruleId} in ${d.name}`)},properties:la({element:d.name,flow:i.name,type:d.type},d.details),ruleId:a.ruleId}))),tool:{driver:{informationUri:"https://github.com/Flow-Scanner/lightning-flow-scanner",name:"Lightning Flow Scanner",rules:r.ruleResults.filter(a=>a.occurs).map(a=>({defaultConfiguration:{level:Mn(a.severity)},fullDescription:{text:a.message||a.ruleDefinition.description||""},id:a.ruleId,shortDescription:{text:a.message||a.ruleDefinition.description||a.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 ua(t){if(t.uri)return t.uri.replace(/\\/g,"/");if(t.fsPath){let e=t.fsPath.match(/(?:force-app|src)\/.+$/);return e?e[0].replace(/\\/g,"/"):t.fsPath.replace(/\\/g,"/")}return`flows/${t.name}.flow-meta.xml`}function da(t){var e,r;return{startColumn:(e=t.columnNumber)!==null&&e!==void 0?e:1,startLine:(r=t.lineNumber)!==null&&r!==void 0?r:1}}function Mn(t){switch(t?.toLowerCase()){case"info":case"note":return"note";case"warning":return"warning";default:return"warning"}}});var Ct=P((wp,Ln)=>{(()=>{"use strict";var t={d:(s,n)=>{for(var o in n)t.o(n,o)&&!t.o(s,o)&&Object.defineProperty(s,o,{enumerable:!0,get:n[o]})},o:(s,n)=>Object.prototype.hasOwnProperty.call(s,n),r:s=>{typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(s,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(s,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{XMLBuilder:()=>js,XMLParser:()=>Vs,XMLValidator:()=>zs});let r=":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("^["+r+"]["+r+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$");function l(s,n){let o=[],c=n.exec(s);for(;c;){let u=[];u.startIndex=n.lastIndex-c[0].length;let p=c.length;for(let h=0;h"&&s[p]!==" "&&s[p]!==" "&&s[p]!==` +`&&s[p]!=="\r";p++)g+=s[p];if(g=g.trim(),g[g.length-1]==="/"&&(g=g.substring(0,g.length-1),p--),!ve(g)){let O;return O=g.trim().length===0?"Invalid space after '<'.":"Tag '"+g+"' is an invalid name.",L("InvalidTag",O,W(s,p))}let m=F(s,p);if(m===!1)return L("InvalidAttr","Attributes for '"+g+"' have open quote.",W(s,p));let w=m.value;if(p=m.index,w[w.length-1]==="/"){let O=p-w.length;w=w.substring(0,w.length-1);let R=B(w,n);if(R!==!0)return L(R.err.code,R.err.msg,W(s,O+R.err.line));c=!0}else if(f){if(!m.tagClosed)return L("InvalidTag","Closing tag '"+g+"' doesn't have proper closing.",W(s,p));if(w.trim().length>0)return L("InvalidTag","Closing tag '"+g+"' can't have attributes or invalid starting.",W(s,h));if(o.length===0)return L("InvalidTag","Closing tag '"+g+"' has not been opened.",W(s,h));{let O=o.pop();if(g!==O.tagName){let R=W(s,O.tagStartPos);return L("InvalidTag","Expected closing tag '"+O.tagName+"' (opened in line "+R.line+", col "+R.col+") instead of closing tag '"+g+"'.",W(s,h))}o.length==0&&(u=!0)}}else{let O=B(w,n);if(O!==!0)return L(O.err.code,O.err.msg,W(s,p-w.length+O.err.line));if(u===!0)return L("InvalidXml","Multiple possible root nodes found.",W(s,p));n.unpairedTags.indexOf(g)!==-1||o.push({tagName:g,tagStartPos:h}),c=!0}for(p++;p0)||L("InvalidXml","Invalid '"+JSON.stringify(o.map(p=>p.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1}):L("InvalidXml","Start tag expected.",1)}function b(s){return s===" "||s===" "||s===` +`||s==="\r"}function x(s,n){let o=n;for(;n5&&c==="xml")return L("InvalidXml","XML declaration allowed only at the start of the document.",W(s,n));if(s[n]=="?"&&s[n+1]==">"){n++;break}continue}return n}function C(s,n){if(s.length>n+5&&s[n+1]==="-"&&s[n+2]==="-"){for(n+=3;n"){n+=2;break}}else if(s.length>n+8&&s[n+1]==="D"&&s[n+2]==="O"&&s[n+3]==="C"&&s[n+4]==="T"&&s[n+5]==="Y"&&s[n+6]==="P"&&s[n+7]==="E"){let o=1;for(n+=8;n"&&(o--,o===0))break}else if(s.length>n+9&&s[n+1]==="["&&s[n+2]==="C"&&s[n+3]==="D"&&s[n+4]==="A"&&s[n+5]==="T"&&s[n+6]==="A"&&s[n+7]==="["){for(n+=8;n"){n+=2;break}}return n}let A='"',k="'";function F(s,n){let o="",c="",u=!1;for(;n"&&c===""){u=!0;break}o+=s[n]}return c===""&&{value:o,index:n,tagClosed:u}}let re=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function B(s,n){let o=l(s,re),c={};for(let u=0;ud.includes(s)?"__"+s:s,qe={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},tagValueProcessor:function(s,n){return n},attributeValueProcessor:function(s,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(s,n,o){return s},captureMetaData:!1,maxNestedTags:100,strictReservedNames:!0,jPath:!0,onDangerousProperty:Re};function it(s,n){if(typeof s!="string")return;let o=s.toLowerCase();if(d.some(c=>o===c.toLowerCase()))throw new Error(`[SECURITY] Invalid ${n}: "${s}" is a reserved JavaScript keyword that could cause prototype pollution`);if(v.some(c=>o===c.toLowerCase()))throw new Error(`[SECURITY] Invalid ${n}: "${s}" is a reserved JavaScript keyword that could cause prototype pollution`)}function $e(s,n){return typeof s=="boolean"?{enabled:s,maxEntitySize:1e4,maxExpansionDepth:1e4,maxTotalExpansions:1/0,maxExpandedLength:1e5,maxEntityCount:1e3,allowedTags:null,tagFilter:null,appliesTo:"all"}:typeof s=="object"&&s!==null?{enabled:s.enabled!==!1,maxEntitySize:Math.max(1,s.maxEntitySize??1e4),maxExpansionDepth:Math.max(1,s.maxExpansionDepth??1e4),maxTotalExpansions:Math.max(1,s.maxTotalExpansions??1/0),maxExpandedLength:Math.max(1,s.maxExpandedLength??1e5),maxEntityCount:Math.max(1,s.maxEntityCount??1e3),allowedTags:s.allowedTags??null,tagFilter:s.tagFilter??null,appliesTo:s.appliesTo??"all"}:$e(!0)}let es=function(s){let n=Object.assign({},qe,s),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&&it(c,u);return n.onDangerousProperty===null&&(n.onDangerousProperty=Re),n.processEntities=$e(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},ot;ot=typeof Symbol!="function"?"@@xmlMetadata":Symbol("XML Node Metadata");class ie{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}),o!==void 0&&(this.child[this.child.length-1][ot]={startIndex:o})}static getMetaDataSymbol(){return ot}}let wn=":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",bn=":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}",ts=bn+"\\-\\.\\d\xB7\u0300-\u036F\u0487\u203F-\u2040",_n=(s,n,o="")=>{let c=`[${s.replace(":","")}][${n.replace(":","")}]*`;return{name:new RegExp(`^[${s}][${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)}},rs=_n(wn,wn+"\\-\\.\\d\xB7\u0300-\u036F\u203F-\u2040"),ns=_n(bn,ts,"u"),Ue=(s,{xmlVersion:n="1.0"}={})=>((o="1.0")=>o==="1.1"?ns:rs)(n).qName.test(s);class is{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,h=!1,f=!1,g="";for(;o"){if(f?n[o-1]==="-"&&n[o-2]==="-"&&(f=!1,p--):p--,p===0)break}else n[o]==="["?h=!0:g+=n[o];else{if(h&&ce(n,"!ENTITY",o)){let m,w;if(o+=7,[m,w,o]=this.readEntityExp(n,o+1,this.suppressValidationErr),w.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[m]=w,u++}}else if(h&&ce(n,"!ELEMENT",o)){o+=8;let{index:m}=this.readElementExp(n,o+1);o=m}else if(h&&ce(n,"!ATTLIST",o))o+=8;else if(h&&ce(n,"!NOTATION",o)){o+=9;let{index:m}=this.readNotationExp(n,o+1,this.suppressValidationErr);o=m}else{if(!ce(n,"!--",o))throw new Error("Invalid DOCTYPE");f=!0}p++,g=""}if(p!==0)throw new Error("Unclosed DOCTYPE")}return{entities:c,i:o}}readEntityExp(n,o){let c=o=z(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=z(n,o);for(;o{for(;n0?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}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 at{constructor(n={}){this.separator=n.separator||".",this.path=[],this.siblingStacks=[],this._pathStringCache=null,this._view=new ds(this)}push(n,o=null,c=null){this._pathStringCache=null,this.path.length>0&&(this.path[this.path.length-1].values=void 0);let u=this.path.length;this.siblingStacks[u]||(this.siblingStacks[u]=new Map);let p=this.siblingStacks[u],h=c?`${c}:${n}`:n,f=p.get(h)||0,g=0;for(let w of p.values())g+=w;p.set(h,f+1);let m={tag:n,position:g,counter:f};c!=null&&(m.namespace=c),o!=null&&(m.values=o),this.path.push(m)}pop(){if(this.path.length===0)return;this._pathStringCache=null;let n=this.path.pop();return this.siblingStacks.length>this.path.length+1&&(this.siblingStacks.length=this.path.length+1),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}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=[]}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],h=!1;for(let f=o;f>=0;f--)if(this._matchSegment(p,this.path[f],f===this.path.length-1)){o=f-1,c--,h=!0;break}if(!h)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=>new Map(n))}}restore(n){this._pathStringCache=null,this.path=n.path.map(o=>({...o})),this.siblingStacks=n.siblingStacks.map(o=>new Map(o))}readOnly(){return this._view}}class we{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:'"'},hs={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"},ms=new Set("!?\\\\/[]$%{}^&*()<>|+");function xn(s){if(s[0]==="#")throw new Error(`[EntityReplacer] Invalid character '#' in entity name: "${s}"`);for(let n of s)if(ms.has(n))throw new Error(`[EntityReplacer] Invalid character '${n}' in entity name: "${s}"`);return s}function lt(...s){let n=Object.create(null);for(let o of s)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 ue="external",ke="base",ct="all",X=Object.freeze({allow:0,leave:1,remove:2,throw:3}),gs=new Set([9,10,13]);class ys{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??ue)&&o!==ue?o===ct?new Set([ct]):o===ke?new Set([ke]):Array.isArray(o)?new Set(o):new Set([ue]):new Set([ue]),this._numericAllowed=n.numericAllowed??!0,this._baseMap=lt(On,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,h=X[u.onNCR]??X.allow,f=X[u.nullNCR]??X.remove;return{xmlVersion:p,onLevel:h,nullLevel:Math.max(f,X.remove)}})(n.ncr);this._ncrXmlVersion=c.xmlVersion,this._ncrOnLevel=c.onLevel,this._ncrNullLevel=c.nullLevel}setExternalEntities(n){if(n)for(let o of Object.keys(n))xn(o);this._externalMap=lt(n)}addExternalEntity(n,o){xn(n),typeof o=="string"&&o.indexOf("&")===-1&&(this._externalMap[n]=o)}addInputEntities(n){this._totalExpansions=0,this._expandedLength=0,this._inputMap=lt(n)}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)return n;let o=n,c=[],u=n.length,p=0,h=0,f=this._maxTotalExpansions>0,g=this._maxExpandedLength>0,m=f||g;for(;h=u||n.charCodeAt(O)!==59){h++;continue}let R=n.slice(h+1,O);if(R.length===0){h++;continue}let N,T;if(this._removeSet.has(R))N="",T===void 0&&(T=ue);else{if(this._leaveSet.has(R)){h++;continue}if(R.charCodeAt(0)===35){let E=this._resolveNCR(R);if(E===void 0){h++;continue}N=E,T=ke}else{let E=this._resolveName(R);N=E?.value,T=E?.tier}}if(N!==void 0){if(h>p&&c.push(n.slice(p,h)),c.push(N),p=O+1,h=p,m&&this._tierCounts(T)){if(f&&(this._totalExpansions++,this._totalExpansions>this._maxTotalExpansions))throw new Error(`[EntityReplacer] Entity expansion count limit exceeded: ${this._totalExpansions} > ${this._maxTotalExpansions}`);if(g){let E=N.length-(R.length+2);if(E>0&&(this._expandedLength+=E,this._expandedLength>this._maxExpandedLength))throw new Error(`[EntityReplacer] Expanded content length limit exceeded: ${this._expandedLength} > ${this._maxExpandedLength}`)}}}else h++}p=55296&&n<=57343||this._ncrXmlVersion===1&&n>=1&&n<=31&&!gs.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&&u0){let o=s.substring(0,n);if(o!=="xmlns")return o}}class bs{constructor(n,o){var c;this.options=n,this.currentNode=null,this.tagsNodeStack=[],this.parseXml=Cs,this.parseTextData=_s,this.resolveNameSpace=Os,this.buildAttributesMap=Ps,this.isItStopNode=Es,this.replaceEntitiesValue=Ns,this.readStopNodeData=Ss,this.saveTextToParentTag=Ts,this.addChild=Rs,this.ignoreAttributesFn=typeof(c=this.options.ignoreAttributes)=="function"?c:Array.isArray(c)?h=>{for(let f of c)if(typeof f=="string"&&h===f||f instanceof RegExp&&f.test(h))return!0}:()=>!1,this.entityExpansionCount=0,this.currentExpandedLength=0;let u={...On};this.options.entityDecoder?this.entityDecoder=this.options.entityDecoder:(typeof this.options.htmlEntities=="object"?u=this.options.htmlEntities:this.options.htmlEntities===!0&&(u={...hs,...fs}),this.entityDecoder=new ys({namedEntities:{...u,...o},numericAllowed:this.options.htmlEntities,limit:{maxTotalExpansions:this.options.processEntities.maxTotalExpansions,maxExpandedLength:this.options.processEntities.maxExpandedLength,applyLimitsTo:this.options.processEntities.appliesTo}})),this.matcher=new at,this.readonlyMatcher=this.matcher.readOnly(),this.isCurrentNodeStopNode=!1,this.stopNodeExpressionsSet=new ps;let p=this.options.stopNodes;if(p&&p.length>0){for(let h=0;h0)){h||(s=this.replaceEntitiesValue(s,n,o));let g=f.jPath?o.toString():o,m=f.tagValueProcessor(n,s,g,u,p);return m==null?s:typeof m!=typeof s||m!==s?m:f.trimValues||s.trim()===s?Pn(s,f.parseTagValue,f.numberParseOptions):s}}function Os(s){if(this.options.removeNSPrefix){let n=s.split(":"),o=s.charAt(0)==="/"?"/":"";if(n[0]==="xmlns")return"";n.length===2&&(s=o+n[1])}return s}let xs=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Ps(s,n,o,c=!1){let u=this.options;if(c===!0||u.ignoreAttributes!==!0&&typeof s=="string"){let p=l(s,xs),h=p.length,f={},g=new Array(h),m=!1,w={};for(let N=0;N",f,"Closing Tag is not closed."),w=s.substring(f+2,m).trim();if(u.removeNSPrefix){let R=w.indexOf(":");R!==-1&&(w=w.substr(R+1))}w=dt(u.transformTagName,w,"",u).tagName,o&&(c=this.saveTextToParentTag(c,o,this.readonlyMatcher));let O=this.matcher.getCurrentTag();if(w&&u.unpairedTagsSet.has(w))throw new Error(`Unpaired tag can not be used as closing tag: `);O&&u.unpairedTagsSet.has(O)&&(this.matcher.pop(),this.tagsNodeStack.pop()),this.matcher.pop(),this.isCurrentNodeStopNode=!1,o=this.tagsNodeStack.pop(),c="",f=m}else if(g===63){let m=ut(s,f,!1,"?>");if(!m)throw new Error("Pi Tag is not closed.");c=this.saveTextToParentTag(c,o,this.readonlyMatcher);let w=this.buildAttributesMap(m.tagExp,this.matcher,m.tagName,!0);if(w){let O=w[this.options.attributeNamePrefix+"version"];this.entityDecoder.setXmlVersion(Number(O)||1),p.setXmlVersion(Number(O)||1)}if(!(u.ignoreDeclaration&&m.tagName==="?xml"||u.ignorePiTags)){let O=new ie(m.tagName);O.add(u.textNodeName,""),m.tagName!==m.tagExp&&m.attrExpPresent&&u.ignoreAttributes!==!0&&(O[":@"]=w),this.addChild(o,O,this.readonlyMatcher,f)}f=m.closeIndex+1}else if(g===33&&s.charCodeAt(f+2)===45&&s.charCodeAt(f+3)===45){let m=be(s,"-->",f+4,"Comment is not closed.");if(u.commentPropName){let w=s.substring(f+4,m-2);c=this.saveTextToParentTag(c,o,this.readonlyMatcher),o.add(u.commentPropName,[{[u.textNodeName]:w}])}f=m}else if(g===33&&s.charCodeAt(f+2)===68){let m=p.readDocType(s,f);this.entityDecoder.addInputEntities(m.entities),f=m.i}else if(g===33&&s.charCodeAt(f+2)===91){let m=be(s,"]]>",f,"CDATA is not closed.")-2,w=s.substring(f+9,m);c=this.saveTextToParentTag(c,o,this.readonlyMatcher);let O=this.parseTextData(w,o.tagname,this.readonlyMatcher,!0,!1,!0,!0);O==null&&(O=""),u.cdataPropName?o.add(u.cdataPropName,[{[u.textNodeName]:w}]):o.add(u.textNodeName,O),f=m+2}else{let m=ut(s,f,u.removeNSPrefix);if(!m){let $=s.substring(Math.max(0,f-50),Math.min(h,f+50));throw new Error(`readTagExp returned undefined at position ${f}. Context: "${$}"`)}let w=m.tagName,O=m.rawTagName,R=m.tagExp,N=m.attrExpPresent,T=m.closeIndex;if({tagName:w,tagExp:R}=dt(u.transformTagName,w,R,u),u.strictReservedNames&&(w===u.commentPropName||w===u.cdataPropName||w===u.textNodeName||w===u.attributesGroupName))throw new Error(`Invalid tag name: ${w}`);o&&c&&o.tagname!=="!xml"&&(c=this.saveTextToParentTag(c,o,this.readonlyMatcher,!1));let E=o;E&&u.unpairedTagsSet.has(E.tagname)&&(o=this.tagsNodeStack.pop(),this.matcher.pop());let I=!1;R.length>0&&R.lastIndexOf("/")===R.length-1&&(I=!0,w[w.length-1]==="/"?(w=w.substr(0,w.length-1),R=w):R=R.substr(0,R.length-1),N=w!==R);let G,H=null,Oe={};G=ws(O),w!==n.tagname&&this.matcher.push(w,{},G),w!==R&&N&&(H=this.buildAttributesMap(R,this.matcher,w),H&&(Oe=vs(H,u))),w!==n.tagname&&(this.isCurrentNodeStopNode=this.isItStopNode());let j=f;if(this.isCurrentNodeStopNode){let $="";if(I)f=m.closeIndex;else if(u.unpairedTagsSet.has(w))f=m.closeIndex;else{let yt=this.readStopNodeData(s,O,T+1);if(!yt)throw new Error(`Unexpected end of ${O}`);f=yt.i,$=yt.tagContent}let gt=new ie(w);H&&(gt[":@"]=H),gt.add(u.textNodeName,$),this.matcher.pop(),this.isCurrentNodeStopNode=!1,this.addChild(o,gt,this.readonlyMatcher,j)}else{if(I){({tagName:w,tagExp:R}=dt(u.transformTagName,w,R,u));let $=new ie(w);H&&($[":@"]=H),this.addChild(o,$,this.readonlyMatcher,j),this.matcher.pop(),this.isCurrentNodeStopNode=!1}else{if(u.unpairedTagsSet.has(w)){let $=new ie(w);H&&($[":@"]=H),this.addChild(o,$,this.readonlyMatcher,j),this.matcher.pop(),this.isCurrentNodeStopNode=!1,f=m.closeIndex;continue}{let $=new ie(w);if(this.tagsNodeStack.length>u.maxNestedTags)throw new Error("Maximum nested tags exceeded");this.tagsNodeStack.push(o),H&&($[":@"]=H),this.addChild(o,$,this.readonlyMatcher,j),o=$}}c="",f=T}}}else c+=s[f];return n.child};function Rs(s,n,o,c){this.options.captureMetaData||(c=void 0);let u=this.options.jPath?o.toString():o,p=this.options.updateTag(n.tagname,u,n[":@"]);p===!1||(typeof p=="string"&&(n.tagname=p),s.addChild(n,c))}function Ns(s,n,o){let c=this.options.processEntities;if(!c||!c.enabled)return s;if(c.allowedTags){let u=this.options.jPath?o.toString():o;if(!(Array.isArray(c.allowedTags)?c.allowedTags.includes(n):c.allowedTags(n,u)))return s}if(c.tagFilter){let u=this.options.jPath?o.toString():o;if(!c.tagFilter(n,u))return s}return this.entityDecoder.decode(s)}function Ts(s,n,o,c){return s&&(c===void 0&&(c=n.child.length===0),(s=this.parseTextData(s,n.tagname,o,!1,!!n[":@"]&&Object.keys(n[":@"]).length!==0,c))!==void 0&&s!==""&&n.add(this.options.textNodeName,s),s=""),s}function Es(){return this.stopNodeExpressionsSet.size!==0&&this.matcher.matchesAny(this.stopNodeExpressionsSet)}function be(s,n,o,c){let u=s.indexOf(n,o);if(u===-1)throw new Error(c);return u+n.length-1}function As(s,n,o,c){let u=s.indexOf(n,o);if(u===-1)throw new Error(c);return u}function ut(s,n,o,c=">"){let u=(function(O,R,N=">"){let T=0,E=O.length,I=N.charCodeAt(0),G=N.length>1?N.charCodeAt(1):-1,H="",Oe=R;for(let j=R;j",o,`${n} is not closed`);if(s.substring(o+2,f).trim()===n&&(u--,u===0))return{tagContent:s.substring(c,o),i:f};o=f}else if(h===63)o=be(s,"?>",o+1,"StopNode is not closed.");else if(h===33&&s.charCodeAt(o+2)===45&&s.charCodeAt(o+3)===45)o=be(s,"-->",o+3,"StopNode is not closed.");else if(h===33&&s.charCodeAt(o+2)===91)o=be(s,"]]>",o,"StopNode is not closed.")-2;else{let f=ut(s,o,!1);f&&((f&&f.tagName)===n&&f.tagExp[f.tagExp.length-1]!=="/"&&u++,o=f.closeIndex)}}}function Pn(s,n,o){if(n&&typeof s=="string"){let c=s.trim();return c==="true"||c!=="false"&&(function(u,p={}){if(p=Object.assign({},cs,p),!u||typeof u!="string")return u;let h=u.trim();if(h.length===0||p.skipLike!==void 0&&p.skipLike.test(h))return u;if(h==="0")return 0;if(p.hex&&os.test(h))return st(h,16);if(p.binary&&ss.test(h))return st(h,2);if(p.octal&&as.test(h))return st(h,8);if(isFinite(h)){if(h.includes("e")||h.includes("E"))return(function(g,m,w){if(!w.eNotation)return g;let O=m.match(us);if(O){let R=O[1]||"",N=O[3].indexOf("e")===-1?"E":"e",T=O[2],E=R?g[T.length+1]===N:g[T.length]===N;return T.length>1&&E?g:(T.length!==1||!O[3].startsWith(`.${N}`)&&O[3][0]!==N)&&T.length>0?w.leadingZeros&&!E?(m=(O[1]||"")+O[3],Number(m)):g:Number(m)}return g})(u,h,p);{let g=ls.exec(h);if(g){let m=g[1]||"",w=g[2],O=((f=g[3])&&f.indexOf(".")!==-1&&((f=f.replace(/0+$/,""))==="."?f="0":f[0]==="."?f="0"+f:f[f.length-1]==="."&&(f=f.substring(0,f.length-1))),f),R=m?u[w.length+1]===".":u[w.length]===".";if(!p.leadingZeros&&(w.length>1||w.length===1&&!R))return u;{let N=Number(h),T=String(N);if(N===0)return N;if(T.search(/[eE]/)!==-1)return p.eNotation?N:u;if(h.indexOf(".")!==-1)return T==="0"||T===O||T===`${m}${O}`?N:u;let E=w?O:h;return w?E===T||m+E===T?N:u:E===T||E===m+T?N:u}}return u}}var f;return(function(g,m,w){let O=m===1/0;switch(w.infinity.toLowerCase()){case"null":return null;case"infinity":return m;case"string":return O?"Infinity":"-Infinity";default:return g}})(u,Number(h),p)})(s,o)}return s!==void 0?s:""}function dt(s,n,o,c){if(s){let u=s(n);o===n&&(o=u),n=u}return{tagName:n=Cn(n,c),tagExp:o}}function Cn(s,n){if(v.includes(s))throw new Error(`[SECURITY] Invalid name: "${s}" is a reserved JavaScript keyword that could cause prototype pollution`);return d.includes(s)?n.onDangerousProperty(s):s}let pt=ie.getMetaDataSymbol();function Fs(s,n){if(!s||typeof s!="object")return{};if(!n)return s;let o={};for(let c in s)c.startsWith(n)?o[c.substring(n.length)]=s[c]:o[c]=s[c];return o}function Is(s,n,o,c){return Rn(s,n,o,c)}function Rn(s,n,o,c){let u,p={};for(let h=0;h0&&(p[n.textNodeName]=u):u!==void 0&&(p[n.textNodeName]=u),p}function Ms(s){let n=Object.keys(s);for(let o=0;o/g,"]]]]>")}function _e(s){return String(s).replace(/"/g,""").replace(/'/g,"'")}function En(s,n,o,c,u){return o.sanitizeName?Ue(s,{xmlVersion:u})?s:o.sanitizeName(s,{isAttribute:n,matcher:c.readOnly()}):s}function qs(s,n){let o="";n.format&&(o=` +`);let c=[];if(n.stopNodes&&Array.isArray(n.stopNodes))for(let p=0;pn.maxNestedTags)throw new Error("Maximum nested tags exceeded");if(!Array.isArray(s)){if(s!=null){let g=s.toString();return g=ht(g,n),g}return""}for(let g=0;g`,f=!1,c.pop();continue}if(O===n.commentPropName){h+=o+``,f=!0,c.pop();continue}if(O[0]==="?"){h+=(O==="?xml"?"":o)+`<${O}${Fn(m[":@"],n,N,c,p)}?>`,f=!0,c.pop();continue}let T=o;T!==""&&(T+=n.indentBy);let E=o+`<${O}${Fn(m[":@"],n,N,c,p)}`,I;I=N?Sn(m[w],n):An(m[w],n,T,c,u,p),n.unpairedTags.indexOf(O)!==-1?n.suppressUnpairedNode?h+=E+">":h+=E+"/>":I&&I.length!==0||!n.suppressEmptyNode?I&&I.endsWith(">")?h+=E+`>${I}${o}`:(h+=E+">",I&&o!==""&&(I.includes("/>")||I.includes("`):h+=E+"/>",f=!0,c.pop()}return h}function $s(s,n){if(!s||n.ignoreAttributes)return null;let o={},c=!1;for(let u in s)Object.prototype.hasOwnProperty.call(s,u)&&(o[u.startsWith(n.attributeNamePrefix)?u.substr(n.attributeNamePrefix.length):u]=_e(s[u]),c=!0);return c?o:null}function Sn(s,n){if(!Array.isArray(s))return s!=null?s.toString():"";let o="";for(let c=0;c${f}`:o+=`<${p}${h}/>`}}}return o}function Us(s,n){let o="";if(s&&!n.ignoreAttributes)for(let c in s){if(!Object.prototype.hasOwnProperty.call(s,c))continue;let u=s[c];u===!0&&n.suppressBooleanAttributes?o+=` ${c.substr(n.attributeNamePrefix.length)}`:o+=` ${c.substr(n.attributeNamePrefix.length)}="${_e(u)}"`}return o}function ft(s){let n=Object.keys(s);for(let o=0;o0&&n.processEntities)for(let o=0;o","g"),val:">"},{regex:new RegExp("<","g"),val:"<"},{regex:new RegExp("'","g"),val:"'"},{regex:new RegExp('"',"g"),val:"""}],processEntities:!0,stopNodes:[],oneListGroup:!1,maxNestedTags:100,jPath:!0,sanitizeName:!1};function Y(s){if(this.options=Object.assign({},Ws,s),this.options.stopNodes&&Array.isArray(this.options.stopNodes)&&(this.options.stopNodes=this.options.stopNodes.map(o=>typeof o=="string"&&o.startsWith("*.")?".."+o.substring(2):o)),this.stopNodeExpressions=[],this.options.stopNodes&&Array.isArray(this.options.stopNodes))for(let o=0;o{for(let c of n)if(typeof c=="string"&&o===c||c instanceof RegExp&&c.test(o))return!0}:()=>!1,this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=Gs),this.processTextOrObjNode=Bs,this.options.format?(this.indentate=Hs,this.tagEndChar=`> +`,this.newLine=` +`):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}function mt(s,n,o,c,u){return o.sanitizeName?Ue(s,{xmlVersion:u})?s:o.sanitizeName(s,{isAttribute:n,matcher:c.readOnly()}):s}function Bs(s,n,o,c,u){let p=this.extractAttributes(s);if(c.push(n,p),this.checkStopNode(c)){let f=this.buildRawContent(s),g=this.buildAttributesForStopNode(s);return c.pop(),this.buildObjectNode(f,n,g,o)}let h=this.j2x(s,o+1,c,u);return c.pop(),n[0]==="?"?this.buildTextValNode("",n,h.attrStr,o,c):s[this.options.textNodeName]!==void 0&&Object.keys(s).length===1?this.buildTextValNode(s[this.options.textNodeName],n,h.attrStr,o,c):this.buildObjectNode(h.val,n,h.attrStr,o)}function Hs(s){return this.options.indentBy.repeat(s)}function Gs(s){return!(!s.startsWith(this.options.attributeNamePrefix)||s===this.options.textNodeName)&&s.substr(this.attrPrefixLen)}Y.prototype.build=function(s){if(this.options.preserveOrder)return qs(s,this.options);{Array.isArray(s)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(s={[this.options.arrayNodeName]:s});let n=new at,o=(function(c,u){let p=c["?xml"];if(p&&typeof p=="object"){if(u.attributesGroupName&&p[u.attributesGroupName]){let f=p[u.attributesGroupName][u.attributeNamePrefix+"version"];if(f)return f}let h=p[u.attributeNamePrefix+"version"];if(h)return h}return"1.0"})(s,this.options);return this.j2x(s,0,n,o).val}},Y.prototype.j2x=function(s,n,o,c){let u="",p="";if(this.options.maxNestedTags&&o.getDepth()>=this.options.maxNestedTags)throw new Error("Maximum nested tags exceeded");let h=this.options.jPath?o.toString():o,f=this.checkStopNode(o);for(let g in s){if(!Object.prototype.hasOwnProperty.call(s,g))continue;let m=g===this.options.textNodeName||g===this.options.cdataPropName||g===this.options.commentPropName||this.options.attributesGroupName&&g===this.options.attributesGroupName||this.isAttribute(g)||g[0]==="?"?g:mt(g,!1,this.options,o,c);if(s[g]===void 0)this.isAttribute(g)&&(p+="");else if(s[g]===null)this.isAttribute(g)||m===this.options.cdataPropName||m===this.options.commentPropName?p+="":m[0]==="?"?p+=this.indentate(n)+"<"+m+"?"+this.tagEndChar:p+=this.indentate(n)+"<"+m+"/"+this.tagEndChar;else if(s[g]instanceof Date)p+=this.buildTextValNode(s[g],m,"",n,o);else if(typeof s[g]!="object"){let w=this.isAttribute(g);if(w&&!this.ignoreAttributesFn(w,h)){let O=mt(w,!0,this.options,o,c);u+=this.buildAttrPairStr(O,""+s[g],f)}else if(!w)if(g===this.options.textNodeName){let O=this.options.tagValueProcessor(g,""+s[g]);p+=this.replaceEntitiesValue(O)}else{o.push(m);let O=this.checkStopNode(o);if(o.pop(),O){let R=""+s[g];p+=R===""?this.indentate(n)+"<"+m+this.closeTag(m)+this.tagEndChar:this.indentate(n)+"<"+m+">"+R+""+I+"${u}`;else if(typeof u=="object"&&u!==null){let p=this.buildRawContent(u),h=this.buildAttributesForStopNode(u);n+=p===""?`<${o}${h}/>`:`<${o}${h}>${p}`}}else if(typeof c=="object"&&c!==null){let u=this.buildRawContent(c),p=this.buildAttributesForStopNode(c);n+=u===""?`<${o}${p}/>`:`<${o}${p}>${u}`}else n+=`<${o}>${c}`}return n},Y.prototype.buildAttributesForStopNode=function(s){if(!s||typeof s!="object")return"";let n="";if(this.options.attributesGroupName&&s[this.options.attributesGroupName]){let o=s[this.options.attributesGroupName];for(let c in o){if(!Object.prototype.hasOwnProperty.call(o,c))continue;let u=c.startsWith(this.options.attributeNamePrefix)?c.substring(this.options.attributeNamePrefix.length):c,p=o[c];p===!0&&this.options.suppressBooleanAttributes?n+=" "+u:n+=" "+u+'="'+p+'"'}}else for(let o in s){if(!Object.prototype.hasOwnProperty.call(s,o))continue;let c=this.isAttribute(o);if(c){let u=s[o];u===!0&&this.options.suppressBooleanAttributes?n+=" "+c:n+=" "+c+'="'+u+'"'}}return n},Y.prototype.buildObjectNode=function(s,n,o,c){if(s==="")return n[0]==="?"?this.indentate(c)+"<"+n+o+"?"+this.tagEndChar:this.indentate(c)+"<"+n+o+this.closeTag(n)+this.tagEndChar;if(n[0]==="?")return this.indentate(c)+"<"+n+o+"?"+this.tagEndChar;{let u="`+this.newLine:this.indentate(c)+"<"+n+o+p+this.tagEndChar+s+this.indentate(c)+u:this.indentate(c)+"<"+n+o+p+">"+s+u}},Y.prototype.closeTag=function(s){let n="";return this.options.unpairedTags.indexOf(s)!==-1?this.options.suppressUnpairedNode||(n="/"):n=this.options.suppressEmptyNode?"/":`>`+this.newLine}if(this.options.commentPropName!==!1&&n===this.options.commentPropName){let p=Nn(s);return this.indentate(c)+``+this.newLine}if(n[0]==="?")return this.indentate(c)+"<"+n+o+"?"+this.tagEndChar;{let p=this.options.tagValueProcessor(n,s);return p=this.replaceEntitiesValue(p),p===""?this.indentate(c)+"<"+n+o+this.closeTag(n)+this.tagEndChar:this.indentate(c)+"<"+n+o+">"+p+"0&&this.options.processEntities)for(let n=0;n{Vn.exports={}});var de=P(Rt=>{"use strict";Object.defineProperty(Rt,"__esModule",{value:!0});Object.defineProperty(Rt,"MetaType",{enumerable:!0,get:function(){return pa}});var pa=(function(t){return t.ATTRIBUTE="attribute",t.VARIABLE="variable",t.RESOURCE="resource",t.NODE="node",t})({})});var oe=P(Nt=>{"use strict";Object.defineProperty(Nt,"__esModule",{value:!0});Object.defineProperty(Nt,"FlowElement",{enumerable:!0,get:function(){return fa}});function pe(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var fa=class{constructor(e,r,i,l={}){pe(this,"subtype",void 0),pe(this,"metaType",void 0),pe(this,"element",{}),pe(this,"connectors",void 0),pe(this,"name",void 0),pe(this,"locationX",void 0),pe(this,"locationY",void 0),this.element=l,this.subtype=r,this.name=i,this.metaType=e}}});var qn=P(Tt=>{"use strict";Object.defineProperty(Tt,"__esModule",{value:!0});Object.defineProperty(Tt,"FlowMetadata",{enumerable:!0,get:function(){return ga}});var ha=de(),ma=oe(),ga=class extends ma.FlowElement{constructor(e,r,i){super(ha.MetaType.ATTRIBUTE,r,e,i)}}});var $n=P(Et=>{"use strict";Object.defineProperty(Et,"__esModule",{value:!0});Object.defineProperty(Et,"FlowElementConnector",{enumerable:!0,get:function(){return ya}});function se(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ya=class{constructor(e,r,i){se(this,"type",void 0),se(this,"element",{}),se(this,"processed",!1),se(this,"alias",void 0),se(this,"reference",void 0),se(this,"childName",void 0),se(this,"childOf",void 0),se(this,"connectorTargetReference",void 0),this.type=e,this.element=r,this.childName=i.childName?i.childName:void 0,this.childOf=i.childOf?i.childOf:void 0,r&&"targetReference"in r&&(this.reference=r.targetReference),r&&"connector"in r&&(this.connectorTargetReference=r.connector)}}});var St=P(At=>{"use strict";Object.defineProperty(At,"__esModule",{value:!0});function va(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}va(At,{get ASCII_ICONS(){return wa},get DEFAULT_ICONS(){return Un},get getDefaultIconConfig(){return ba}});var Un={actionCalls:{apex:"\u2699\uFE0F",emailAlert:"\u{1F4E7}",emailSimple:"\u{1F4E7}",submit:"\u26A1",default:"\u26A1"},assignments:{default:"\u{1F7F0}"},collectionProcessors:{FilterCollectionProcessor:"\u{1F53D}",SortCollectionProcessor:"\u{1F503}",default:"\u{1F4E6}"},customErrors:{default:"\u{1F6AB}"},decisions:{default:"\u{1F500}"},loops:{default:"\u{1F501}"},recordCreates:{default:"\u2795"},recordDeletes:{default:"\u{1F5D1}\uFE0F"},recordLookups:{default:"\u{1F50D}"},recordUpdates:{default:"\u{1F6E0}\uFE0F"},screens:{default:"\u{1F4BB}"},subflows:{default:"\u{1F517}"},transforms:{default:"\u267B\uFE0F"}},wa={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]"}};function ba(){return Un}});var He=P(It=>{"use strict";Object.defineProperty(It,"__esModule",{value:!0});Object.defineProperty(It,"FlowNode",{enumerable:!0,get:function(){return kn}});var _a=de(),Oa=oe(),V=$n(),Ft=St();function U(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var kn=class xe extends Oa.FlowElement{static setIconConfig(e){xe.iconConfig=e}static useAsciiIcons(){xe.iconConfig=Ft.ASCII_ICONS}static useDefaultIcons(){xe.iconConfig=Ft.DEFAULT_ICONS}extractTypeSpecificProperties(e,r){switch(e){case"actionCalls":this.actionType=r.actionType,this.actionName=r.actionName;break;case"recordCreates":case"recordUpdates":case"recordDeletes":case"recordLookups":this.object=r.object,this.inputReference=r.inputReference,this.outputReference=r.outputReference;break;case"collectionProcessors":this.elementSubtype=r.elementSubtype,this.collectionReference=r.collectionReference;break;case"subflows":this.flowName=r.flowName;break;case"decisions":this.rules=Array.isArray(r.rules)?r.rules:r.rules?[r.rules]:[],this.defaultConnectorLabel=r.defaultConnectorLabel;break;case"loops":this.collectionReference=r.collectionReference,this.iterationOrder=r.iterationOrder;break;case"screens":this.fields=Array.isArray(r.fields)?r.fields:r.fields?[r.fields]:[],this.allowPause=r.allowPause,this.showFooter=r.showFooter;break}}getSummary(){let 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":var r,i;e.push(`${((r=this.rules)===null||r===void 0?void 0:r.length)||0} rule${((i=this.rules)===null||i===void 0?void 0:i.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(" \u2022 ")}getIcon(){let e=xe.iconConfig[this.subtype];if(!e){let l=xe.iconConfig.default;return l&&"default"in l?l.default:"\u2022"}let r=this.actionType||this.elementSubtype,i=e;return r&&i[r]?i[r]:i.default||"\u2022"}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(/^./,r=>r.toUpperCase()).trim()}getConnectors(e,r){let i=[];if(e==="start"){if(r.connector&&i.push(new V.FlowElementConnector("connector",r.connector,{})),Array.isArray(r.scheduledPaths)){for(let a of r?.scheduledPaths||[])if(a.connector){var l;i.push(new V.FlowElementConnector("connector",a.connector,{childName:(l=a?.name)!==null&&l!==void 0?l:"AsyncAfterCommit",childOf:"scheduledPaths"}))}}else r.scheduledPaths&&i.push(new V.FlowElementConnector("connector",r.scheduledPaths,{childName:r.scheduledPaths.name,childOf:"scheduledPaths"}));return i}else if(e==="decisions"){if(r.defaultConnector&&i.push(new V.FlowElementConnector("defaultConnector",r.defaultConnector,{})),r.rules)if(Array.isArray(r.rules))for(let a of r.rules)a.connector&&i.push(new V.FlowElementConnector("connector",a.connector,{childName:a.name,childOf:"rules"}));else r.rules.connector&&i.push(new V.FlowElementConnector("connector",r.rules.connector,{childName:r.rules.name,childOf:"rules"}));return i}else{if(e==="assignments"||e==="transforms"||e==="customErrors")return r.connector?[new V.FlowElementConnector("connector",r.connector,{})]:[];if(e==="loops")return r.nextValueConnector&&i.push(new V.FlowElementConnector("nextValueConnector",r.nextValueConnector,{})),r.noMoreValuesConnector&&i.push(new V.FlowElementConnector("noMoreValuesConnector",r.noMoreValuesConnector,{})),i;if(e==="actionCalls")return r.connector&&i.push(new V.FlowElementConnector("connector",r.connector,{})),r.faultConnector&&i.push(new V.FlowElementConnector("faultConnector",r.faultConnector,{})),i;if(e==="waits"){if(r.defaultConnector&&i.push(new V.FlowElementConnector("defaultConnector",r.defaultConnector,{})),r.faultConnector&&i.push(new V.FlowElementConnector("faultConnector",r.faultConnector,{})),Array.isArray(r.waitEvents))for(let a of r.waitEvents)a.connector&&i.push(new V.FlowElementConnector("connector",a.connector,{childName:a.name,childOf:"waitEvents"}));return i}else return e==="recordCreates"?(r.connector&&i.push(new V.FlowElementConnector("connector",r.connector,{})),r.faultConnector&&i.push(new V.FlowElementConnector("faultConnector",r.faultConnector,{})),i):e==="recordDeletes"?(r.connector&&i.push(new V.FlowElementConnector("connector",r.connector,{})),r.faultConnector&&i.push(new V.FlowElementConnector("faultConnector",r.faultConnector,{})),i):e==="recordLookups"?(r.connector&&i.push(new V.FlowElementConnector("connector",r.connector,{})),r.faultConnector&&i.push(new V.FlowElementConnector("faultConnector",r.faultConnector,{})),i):e==="recordUpdates"?(r.connector&&i.push(new V.FlowElementConnector("connector",r.connector,{})),r.faultConnector&&i.push(new V.FlowElementConnector("faultConnector",r.faultConnector,{})),i):e==="subflows"?r.connector?[new V.FlowElementConnector("connector",r.connector,{})]:[]:e==="screens"?r.connector?[new V.FlowElementConnector("connector",r.connector,{})]:[]:r.connector?[new V.FlowElementConnector("connector",r.connector,{})]:[]}}constructor(e,r,i){let l=r==="start"?"flowstart":e;super(_a.MetaType.NODE,r,l,i),U(this,"connectors",[]),U(this,"locationX",void 0),U(this,"locationY",void 0),U(this,"label",void 0),U(this,"description",void 0),U(this,"actionType",void 0),U(this,"actionName",void 0),U(this,"object",void 0),U(this,"inputReference",void 0),U(this,"outputReference",void 0),U(this,"elementSubtype",void 0),U(this,"collectionReference",void 0),U(this,"flowName",void 0),U(this,"rules",void 0),U(this,"defaultConnectorLabel",void 0),U(this,"iterationOrder",void 0),U(this,"fields",void 0),U(this,"allowPause",void 0),U(this,"showFooter",void 0),U(this,"faultConnector",void 0),this.label=i.label,this.description=i.description,this.locationX=i.locationX,this.locationY=i.locationY,this.extractTypeSpecificProperties(r,i),this.connectors=this.getConnectors(r,i),this.faultConnector=this.connectors.find(a=>a.type==="faultConnector")}};U(kn,"iconConfig",Ft.DEFAULT_ICONS)});var Ge=P(Mt=>{"use strict";Object.defineProperty(Mt,"__esModule",{value:!0});Object.defineProperty(Mt,"FlowResource",{enumerable:!0,get:function(){return Ca}});var xa=de(),Pa=oe(),Ca=class extends Pa.FlowElement{constructor(e,r,i){super(xa.MetaType.RESOURCE,r,e,i)}}});var Lt=P(Dt=>{"use strict";Object.defineProperty(Dt,"__esModule",{value:!0});function Ra(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}Ra(Dt,{get ASCII_VARIABLE_ICONS(){return Na},get DEFAULT_VARIABLE_ICONS(){return Wn},get getDefaultVariableIconConfig(){return Ta}});var Wn={subtypes:{variables:"\u{1F4CA}",constants:"\u{1F512}",formulas:"\u{1F9EE}",choices:"\u{1F4CB}",dynamicChoiceSets:"\u{1F504}"},boolean:{true:"\u2705",false:"\u2B1C"}},Na={subtypes:{variables:"[V]",constants:"[C]",formulas:"[F]",choices:"[CH]",dynamicChoiceSets:"[D]"},boolean:{true:"[X]",false:"[ ]"}};function Ta(){return Wn}});var je=P(qt=>{"use strict";Object.defineProperty(qt,"__esModule",{value:!0});Object.defineProperty(qt,"FlowVariable",{enumerable:!0,get:function(){return Bn}});var Ea=de(),Aa=oe(),Vt=Lt();function ae(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Bn=class fe extends Aa.FlowElement{static setIconConfig(e){fe.iconConfig=e}static useAsciiIcons(){fe.iconConfig=Vt.ASCII_VARIABLE_ICONS}static useDefaultIcons(){fe.iconConfig=Vt.DEFAULT_VARIABLE_ICONS}getIcon(){return fe.iconConfig.subtypes[this.subtype]||"\u{1F4CA}"}getBooleanIcon(e){return e===!0?fe.iconConfig.boolean.true:e===!1?fe.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 | |:---|:---| `;return e+=`| Name | ${this.name} | `,e+=`| Type | ${this.getIcon()} ${this.getTypeLabel()} | @@ -9,66 +15,67 @@ `),this.isOutput!==void 0&&(e+=`| Output | ${this.getBooleanIcon(this.isOutput)} | `),this.value!==void 0&&(e+=`| Value | ${this.formatValue(this.value)} | `),this.description&&(e+=`| Description | ${this.description} | -`),e}formatValue(e){return typeof e=="object"?JSON.stringify(e,null,2):String(e)}};P.iconConfig=se;let j=P;class ge{constructor(e,t,s){this.nodeMap=new Map,this.reachableFromStart=new Set,this.elementsInLoop=new Map,this.faultConnectors=new Map,this.normalConnectors=new Map,this.allConnectors=new Map,this.reverseConnectors=new Map,this.buildNodeMaps(e),this.buildConnectorMaps(e),s?this.addStartNodeConnectors(s):t&&this.addStartEdgeFromReference(t),this.computeLoopBoundaries(),t&&this.computeReachability(t)}addStartNodeConnectors(e){var s,r,n,o;const t="START";if(this.faultConnectors.set(t,new Set),this.normalConnectors.set(t,new Set),this.allConnectors.set(t,new Set),!(!e.connectors||e.connectors.length===0))for(const i of e.connectors){const c=((s=i.connectorTargetReference)==null?void 0:s.targetReference)??i.reference;c&&((r=this.normalConnectors.get(t))==null||r.add(c),(n=this.allConnectors.get(t))==null||n.add(c),this.reverseConnectors.has(c)||this.reverseConnectors.set(c,new Set),(o=this.reverseConnectors.get(c))==null||o.add(t))}}addStartEdgeFromReference(e){var s,r,n;const t="START";this.faultConnectors.set(t,new Set),this.normalConnectors.set(t,new Set),this.allConnectors.set(t,new Set),(s=this.normalConnectors.get(t))==null||s.add(e),(r=this.allConnectors.get(t))==null||r.add(e),this.reverseConnectors.has(e)||this.reverseConnectors.set(e,new Set),(n=this.reverseConnectors.get(e))==null||n.add(t)}buildNodeMaps(e){for(const t of e)this.nodeMap.set(t.name,t)}buildConnectorMaps(e){var t,s,r,n,o;for(const i of e)if(this.faultConnectors.set(i.name,new Set),this.normalConnectors.set(i.name,new Set),this.allConnectors.set(i.name,new Set),!(!i.connectors||i.connectors.length===0))for(const c of i.connectors){const l=((t=c.connectorTargetReference)==null?void 0:t.targetReference)??c.reference;l&&(c.type==="faultConnector"?(s=this.faultConnectors.get(i.name))==null||s.add(l):(r=this.normalConnectors.get(i.name))==null||r.add(l),(n=this.allConnectors.get(i.name))==null||n.add(l),this.reverseConnectors.has(l)||this.reverseConnectors.set(l,new Set),(o=this.reverseConnectors.get(l))==null||o.add(i.name))}}computeReachability(e){new Q().traverseFlow(e,s=>{this.reachableFromStart.add(s.name)},this.nodeMap,this.allConnectors)}computeLoopBoundaries(){var t,s;const e=Array.from(this.nodeMap.values()).filter(r=>r.subtype==="loops");for(const r of e){const n=((s=(t=r.element)==null?void 0:t.noMoreValuesConnector)==null?void 0:s.targetReference)??r.name;new Q().traverseFlow(r.name,i=>{this.elementsInLoop.set(i.name,r.name)},this.nodeMap,this.allConnectors,n)}}isReachable(e){return this.reachableFromStart.has(e)}getReachableElements(){return new Set(this.reachableFromStart)}isInLoop(e){return this.elementsInLoop.has(e)}getContainingLoop(e){return this.elementsInLoop.get(e)}getLoopElements(e){const t=new Set;for(const[s,r]of this.elementsInLoop)r===e&&t.add(s);return t}hasFaultConnector(e){const t=this.faultConnectors.get(e);return t?t.size>0:!1}getFaultTargets(e){return Array.from(this.faultConnectors.get(e)||[])}getNextElements(e){return Array.from(this.normalConnectors.get(e)||[])}getAllNextElements(e){return Array.from(this.allConnectors.get(e)||[])}getPreviousElements(e){return Array.from(this.reverseConnectors.get(e)||[])}getNode(e){return this.nodeMap.get(e)}isPartOfFaultHandling(e){return this.getPreviousElements(e).some(s=>{const r=this.faultConnectors.get(s);return(r==null?void 0:r.has(e))??!1})}getLoopNodes(){return Array.from(this.nodeMap.values()).filter(e=>e.subtype==="loops")}forEachReachable(e){for(const t of this.reachableFromStart){const s=this.nodeMap.get(t);s&&e(s)}}toMermaid(e={}){let t="";const s=this.generateMermaidDiagram(e);return e.includeMarkdownDocs?t=this.generateFullMarkdownDoc(s,e):t=`\`\`\`mermaid -${s} -\`\`\``,t}generateMermaidDiagram(e){let t=`flowchart TB -`;t+=this.generateStartNode(e.flowMetadata)+` +`),e}formatValue(e){return typeof e=="object"?JSON.stringify(e,null,2):String(e)}constructor(e,r,i){super(Ea.MetaType.VARIABLE,r,e,i),ae(this,"dataType",void 0),ae(this,"isCollection",void 0),ae(this,"isInput",void 0),ae(this,"isOutput",void 0),ae(this,"objectType",void 0),ae(this,"description",void 0),ae(this,"value",void 0),this.dataType=i.dataType,this.isCollection=i.isCollection,this.isInput=i.isInput,this.isOutput=i.isOutput,this.objectType=i.objectType,this.description=i.description,r==="constants"?this.value=i.value:r==="formulas"&&(this.value=i.expression)}};ae(Bn,"iconConfig",Vt.DEFAULT_VARIABLE_ICONS)});var kt=P(Ut=>{"use strict";Object.defineProperty(Ut,"__esModule",{value:!0});Object.defineProperty(Ut,"FlowGraph",{enumerable:!0,get:function(){return Sa}});var $t=We();function le(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Sa=class{addStartNodeConnectors(e){let r="START";if(this.faultConnectors.set(r,new Set),this.normalConnectors.set(r,new Set),this.allConnectors.set(r,new Set),!(!e.connectors||e.connectors.length===0))for(let y of e.connectors){var i,l,a,d,v;let _=(v=(i=y.connectorTargetReference)===null||i===void 0?void 0:i.targetReference)!==null&&v!==void 0?v:y.reference;_&&((l=this.normalConnectors.get(r))===null||l===void 0||l.add(_),(a=this.allConnectors.get(r))===null||a===void 0||a.add(_),this.reverseConnectors.has(_)||this.reverseConnectors.set(_,new Set),(d=this.reverseConnectors.get(_))===null||d===void 0||d.add(r))}}addStartEdgeFromReference(e){var r,i,l;let a="START";this.faultConnectors.set(a,new Set),this.normalConnectors.set(a,new Set),this.allConnectors.set(a,new Set),(r=this.normalConnectors.get(a))===null||r===void 0||r.add(e),(i=this.allConnectors.get(a))===null||i===void 0||i.add(e),this.reverseConnectors.has(e)||this.reverseConnectors.set(e,new Set),(l=this.reverseConnectors.get(e))===null||l===void 0||l.add(a)}buildNodeMaps(e){for(let r of e)this.nodeMap.set(r.name,r)}buildConnectorMaps(e){for(let y of e)if(this.faultConnectors.set(y.name,new Set),this.normalConnectors.set(y.name,new Set),this.allConnectors.set(y.name,new Set),!(!y.connectors||y.connectors.length===0))for(let _ of y.connectors){var r,i,l,a;let b=(a=(r=_.connectorTargetReference)===null||r===void 0?void 0:r.targetReference)!==null&&a!==void 0?a:_.reference;if(b){if(_.type==="faultConnector"){var d;(d=this.faultConnectors.get(y.name))===null||d===void 0||d.add(b)}else{var v;(v=this.normalConnectors.get(y.name))===null||v===void 0||v.add(b)}(i=this.allConnectors.get(y.name))===null||i===void 0||i.add(b),this.reverseConnectors.has(b)||this.reverseConnectors.set(b,new Set),(l=this.reverseConnectors.get(b))===null||l===void 0||l.add(y.name)}}}computeReachability(e){new $t.Compiler().traverseFlow(e,i=>{this.reachableFromStart.add(i.name)},this.nodeMap,this.allConnectors)}computeNormalReachability(e){new $t.Compiler().traverseFlow(e,i=>{this.normalReachableFromStart.add(i.name)},this.nodeMap,this.normalConnectors)}computeLoopBoundaries(){let e=Array.from(this.nodeMap.values()).filter(a=>a.subtype==="loops");for(let a of e){var r,i,l;let d=(l=(i=a.element)===null||i===void 0||(r=i.noMoreValuesConnector)===null||r===void 0?void 0:r.targetReference)!==null&&l!==void 0?l:a.name;new $t.Compiler().traverseFlow(a.name,y=>{this.elementsInLoop.set(y.name,a.name)},this.nodeMap,this.allConnectors,d)}}isReachable(e){return this.reachableFromStart.has(e)}getReachableElements(){return new Set(this.reachableFromStart)}isInLoop(e){return this.elementsInLoop.has(e)}getContainingLoop(e){return this.elementsInLoop.get(e)}getLoopElements(e){let r=new Set;for(let[i,l]of this.elementsInLoop)l===e&&r.add(i);return r}hasFaultConnector(e){let r=this.faultConnectors.get(e);return r?r.size>0:!1}getFaultTargets(e){return Array.from(this.faultConnectors.get(e)||[])}getNextElements(e){return Array.from(this.normalConnectors.get(e)||[])}getAllNextElements(e){return Array.from(this.allConnectors.get(e)||[])}getPreviousElements(e){return Array.from(this.reverseConnectors.get(e)||[])}getNode(e){return this.nodeMap.get(e)}isPartOfFaultHandling(e){return this.reachableFromStart.has(e)&&!this.normalReachableFromStart.has(e)}getLoopNodes(){return Array.from(this.nodeMap.values()).filter(e=>e.subtype==="loops")}forEachReachable(e){for(let r of this.reachableFromStart){let i=this.nodeMap.get(r);i&&e(i)}}toMermaid(e={}){let r="",i=this.generateMermaidDiagram(e);return e.includeMarkdownDocs?r=this.generateFullMarkdownDoc(i,e):r=`\`\`\`mermaid +${i} +\`\`\``,r}generateMermaidDiagram(e){let r=`flowchart TB +`;r+=this.generateStartNode(e.flowMetadata)+` -`;for(const[s,r]of this.nodeMap){const n=r.getIcon(),o=r.getTypeLabel(),i=e.includeDetails?r.getSummary():"";let c=`${n} ${o}
${r.label||r.name}`;i&&(c+=`
${i}`);const l=this.getNodeShape(r.subtype);t+=` ${s}${l[0]}"${c}"${l[1]}:::${r.subtype} -`}return t+=` -`,t+=this.generateEdges()+` -`,t+=this.generateLoopSubgraphs()+` -`,t+=this.generateMermaidStyles(),t}generateStartNode(e){if(!e)return'START(["🚀 START"]):::startClass';let t="🚀 START";if(e.processType==="Flow"?t+="
Screen Flow":e.processType==="AutoLaunchedFlow"?(t+="
AutoLaunched Flow",e.triggerType&&(t+=`
Type: ${this.prettifyValue(e.triggerType)}`)):e.object&&(t+=`
${e.object}`,e.triggerType&&(t+=`
Type: ${this.prettifyValue(e.triggerType)}`)),e.status){const s=e.status==="Active"?"✅":"⚠️";t+=`
${s} ${e.status}`}return`START(["${t}"]):::startClass`}getNodeShape(e){const t={decisions:["{","}"],loops:["{{","}}"],collectionProcessors:["{{","}}"],transforms:["{{","}}"],screens:["([","])"],recordCreates:["[(",")]"],recordDeletes:["[(",")]"],recordLookups:["[(",")]"],recordUpdates:["[(",")]"],subflows:["[[","]]"],assignments:["[\\","/]"],default:["(",")"]};return t[e]||t.default}generateEdges(){let e="";for(const[s,r]of this.allConnectors)for(const n of r)e+=` ${s} --> ${n} -`;for(const[s,r]of this.faultConnectors)for(const n of r)e+=` ${s} -. Fault .-> ${n} -`;const t=this.findEndNodes();for(const s of t)e+=` ${s}(( END )):::endClass -`;return e}findEndNodes(){const e=new Set;for(const[t,s]of this.allConnectors)for(const r of s)this.nodeMap.has(r)||e.add(r);return e}generateLoopSubgraphs(){let e="";for(const t of this.getLoopNodes()){const s=this.getLoopElements(t.name);if(s.size>0){e+=` subgraph "${t.label||t.name} Loop" -`;for(const r of s)e+=` ${r} +`;for(let[i,l]of this.nodeMap){let a=l.getIcon(),d=l.getTypeLabel(),v=e.includeDetails?l.getSummary():"",y=`${a} ${d}
${l.label||l.name}`;v&&(y+=`
${v}`);let _=this.getNodeShape(l.subtype);r+=` ${i}${_[0]}"${y}"${_[1]}:::${l.subtype} +`}return r+=` +`,r+=this.generateEdges()+` +`,r+=this.generateLoopSubgraphs()+` +`,r+=this.generateMermaidStyles(),r}generateStartNode(e){if(!e)return'START(["\u{1F680} START"]):::startClass';let r="\u{1F680} START";if(e.processType==="Flow"?r+="
Screen Flow":e.processType==="AutoLaunchedFlow"?(r+="
AutoLaunched Flow",e.triggerType&&(r+=`
Type: ${this.prettifyValue(e.triggerType)}`)):e.object&&(r+=`
${e.object}`,e.triggerType&&(r+=`
Type: ${this.prettifyValue(e.triggerType)}`)),e.status){let i=e.status==="Active"?"\u2705":"\u26A0\uFE0F";r+=`
${i} ${e.status}`}return`START(["${r}"]):::startClass`}getNodeShape(e){let r={decisions:["{","}"],loops:["{{","}}"],collectionProcessors:["{{","}}"],transforms:["{{","}}"],screens:["([","])"],recordCreates:["[(",")]"],recordDeletes:["[(",")]"],recordLookups:["[(",")]"],recordUpdates:["[(",")]"],subflows:["[[","]]"],assignments:["[\\","/]"],default:["(",")"]};return r[e]||r.default}generateEdges(){let e="";for(let[i,l]of this.allConnectors)for(let a of l)e+=` ${i} --> ${a} +`;for(let[i,l]of this.faultConnectors)for(let a of l)e+=` ${i} -. Fault .-> ${a} +`;let r=this.findEndNodes();for(let i of r)e+=` ${i}(( END )):::endClass +`;return e}findEndNodes(){let e=new Set;for(let[r,i]of this.allConnectors)for(let l of i)this.nodeMap.has(l)||e.add(l);return e}generateLoopSubgraphs(){let e="";for(let r of this.getLoopNodes()){let i=this.getLoopElements(r.name);if(i.size>0){e+=` subgraph "${r.label||r.name} Loop" +`;for(let l of i)e+=` ${l} `;e+=` end -`}}return e}generateMermaidStyles(){const e={actionCalls:{fill:"#D4E4FC",color:"black"},assignments:{fill:"#FBEED7",color:"black"},collectionProcessors:{fill:"#F0E3FA",color:"black"},customErrors:{fill:"#FFE9E9",color:"black"},decisions:{fill:"#FDEAF6",color:"black"},loops:{fill:"#FDEAF6",color:"black"},recordCreates:{fill:"#FFF8C9",color:"black"},recordDeletes:{fill:"#FFF8C9",color:"black"},recordLookups:{fill:"#EDEAFF",color:"black"},recordUpdates:{fill:"#FFF8C9",color:"black"},screens:{fill:"#DFF6FF",color:"black"},subflows:{fill:"#D4E4FC",color:"black"},transforms:{fill:"#FDEAF6",color:"black"},startClass:{fill:"#D9F2E6",color:"black"},endClass:{fill:"#F9BABA",color:"black"}};let t="";for(const[s,r]of Object.entries(e))t+=` classDef ${s} fill:${r.fill},color:${r.color},stroke:#333,stroke-width:2px -`;return t}generateNodeDetailsMarkdown(e){let t=`## Flow Nodes Details +`}}return e}generateMermaidStyles(){let e={actionCalls:{fill:"#D4E4FC",color:"black"},assignments:{fill:"#FBEED7",color:"black"},collectionProcessors:{fill:"#F0E3FA",color:"black"},customErrors:{fill:"#FFE9E9",color:"black"},decisions:{fill:"#FDEAF6",color:"black"},loops:{fill:"#FDEAF6",color:"black"},recordCreates:{fill:"#FFF8C9",color:"black"},recordDeletes:{fill:"#FFF8C9",color:"black"},recordLookups:{fill:"#EDEAFF",color:"black"},recordUpdates:{fill:"#FFF8C9",color:"black"},screens:{fill:"#DFF6FF",color:"black"},subflows:{fill:"#D4E4FC",color:"black"},transforms:{fill:"#FDEAF6",color:"black"},startClass:{fill:"#D9F2E6",color:"black"},endClass:{fill:"#F9BABA",color:"black"}},r="";for(let[i,l]of Object.entries(e))r+=` classDef ${i} fill:${l.fill},color:${l.color},stroke:#333,stroke-width:2px +`;return r}generateNodeDetailsMarkdown(e){let r=`## Flow Nodes Details -`;e&&(t+=`
NODE DETAILS (expand to view) +`;e&&(r+=`
NODE DETAILS (expand to view) -`);for(const[s,r]of this.nodeMap)t+=`### ${s} +`);for(let[i,l]of this.nodeMap)r+=`### ${i} -`,t+=this.nodeToMarkdownTable(r),t+=` -`;return e&&(t+=`
+`,r+=this.nodeToMarkdownTable(l),r+=` +`;return e&&(r+=`
-`),t}nodeToMarkdownTable(e){let t=`| Property | Value | +`),r}nodeToMarkdownTable(e){let r=`| Property | Value | |:---|:---| -`;if(e.label&&(t+=`| Label | ${e.label} | -`),t+=`| Type | ${e.getTypeLabel()} | -`,e.actionType&&(t+=`| Action Type | ${this.prettifyValue(e.actionType)} | -`),e.actionName&&(t+=`| Action Name | ${e.actionName} | -`),e.object&&(t+=`| Object | ${e.object} | -`),e.flowName&&(t+=`| Subflow | ${e.flowName} | -`),e.collectionReference&&(t+=`| Collection | ${e.collectionReference} | -`),e.elementSubtype&&(t+=`| Subtype | ${this.prettifyValue(e.elementSubtype)} | -`),e.rules&&e.rules.length>0){t+=`| Rules | ${e.rules.length} | -`;for(const s of e.rules){const r=Array.isArray(s.conditions)?s.conditions:s.conditions?[s.conditions]:[];t+=`| ↳ ${s.label||s.name} | ${r.length} condition(s) | -`}}return e.fields&&e.fields.length>0&&(t+=`| Fields | ${e.fields.length} | -`),e.description&&(t+=`| Description | ${e.description} | -`),e.faultConnector&&(t+=`| Has Fault Handler | ✅ | -`),t}prettifyValue(e){return e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()).trim()}generateFullMarkdownDoc(e,t){let s="";return s+=`## Flow Diagram +`;if(e.label&&(r+=`| Label | ${e.label} | +`),r+=`| Type | ${e.getTypeLabel()} | +`,e.actionType&&(r+=`| Action Type | ${this.prettifyValue(e.actionType)} | +`),e.actionName&&(r+=`| Action Name | ${e.actionName} | +`),e.object&&(r+=`| Object | ${e.object} | +`),e.flowName&&(r+=`| Subflow | ${e.flowName} | +`),e.collectionReference&&(r+=`| Collection | ${e.collectionReference} | +`),e.elementSubtype&&(r+=`| Subtype | ${this.prettifyValue(e.elementSubtype)} | +`),e.rules&&e.rules.length>0){r+=`| Rules | ${e.rules.length} | +`;for(let i of e.rules){let l=Array.isArray(i.conditions)?i.conditions:i.conditions?[i.conditions]:[];r+=`| \u21B3 ${i.label||i.name} | ${l.length} condition(s) | +`}}return e.fields&&e.fields.length>0&&(r+=`| Fields | ${e.fields.length} | +`),e.description&&(r+=`| Description | ${e.description} | +`),e.faultConnector&&(r+=`| Has Fault Handler | \u2705 | +`),r}prettifyValue(e){return e.replace(/([A-Z])/g," $1").replace(/^./,r=>r.toUpperCase()).trim()}generateFullMarkdownDoc(e,r){let i="";return i+=`## Flow Diagram -`,s+="```mermaid\n",s+=e,s+="\n```\n\n",t.includeDetails&&(s+=this.generateNodeDetailsMarkdown(t.collapsedDetails)),s}toPlantUML(){let e=`@startuml +`,i+="```mermaid\n",i+=e,i+="\n```\n\n",r.includeDetails&&(i+=this.generateNodeDetailsMarkdown(r.collapsedDetails)),i}toPlantUML(){let e=`@startuml skinparam activityBackgroundColor #D4E4FC -`;for(const[t,s]of this.nodeMap)e+=`activity "${s.subtype}: ${t}" as ${t} -`;for(const[t,s]of this.allConnectors)for(const r of s)e+=`${t} --> ${r} -`;for(const t of this.getLoopNodes()){e+=`partition "${t.name} Loop" { -`;const s=this.getLoopElements(t.name);for(const r of s)e+=` ${r} +`;for(let[r,i]of this.nodeMap)e+=`activity "${i.subtype}: ${r}" as ${r} +`;for(let[r,i]of this.allConnectors)for(let l of i)e+=`${r} --> ${l} +`;for(let r of this.getLoopNodes()){e+=`partition "${r.name} Loop" { +`;let i=this.getLoopElements(r.name);for(let l of i)e+=` ${l} `;e+=`} -`}return e+="@enduml",e}}const E=class E{constructor(e,t){if(this.elements=[],this.label="",this.name="unnamed",this.processType="AutoLaunchedFlow",this.type="",this.status="",e){this.uri=e,typeof Z<"u"&&typeof Z.cwd=="function"&&(this.fsPath=z.resolve(e));let s=z.basename(z.basename(e),z.extname(e));s.includes(".")&&(s=s.split(".")[0]),this.name=s||"unnamed"}t&&(typeof t=="object"&&t!==null&&"Flow"in t?this.xmldata=t.Flow:this.xmldata=t,this.preProcessNodes())}get graph(){if(!this._graph){const e=this.elements.filter(t=>t instanceof x);this.startReference||(this.startReference=this.findStart()),this._graph=new ge(e,this.startReference,this.startNode)}return this._graph}static from(e){if(e instanceof E)return e;const t=Object.create(E.prototype);return Object.assign(t,e),t.toXMLString||(t.toXMLString=()=>""),t}preProcessNodes(){if(!this.xmldata)return;this.label=this.xmldata.label||"",this.interviewLabel=this.xmldata.interviewLabel,this.processType=this.xmldata.processType||"AutoLaunchedFlow",this.type=this.processType,this.processMetadataValues=this.xmldata.processMetadataValues,this.startElementReference=this.xmldata.startElementReference,this.status=this.xmldata.status||"Draft",this.triggerOrder=this.xmldata.triggerOrder;const e=[];for(const s in this.xmldata){if(s.startsWith("@_")||s==="@xmlns")continue;const r=this.xmldata[s];if(s==="start"){Array.isArray(r)&&r.length>0?this.startNode=new x(r[0].name||"start","start",r[0]):Array.isArray(r)||(this.startNode=new x(r.name||"start","start",r));continue}E.ATTRIBUTE_TAGS.includes(s)?this.processNodeType(r,s,e,Me):E.VARIABLE_TAGS.includes(s)?this.processNodeType(r,s,e,j):E.NODE_TAGS.includes(s)?this.processNodeType(r,s,e,x):E.RESOURCE_TAGS.includes(s)&&this.processNodeType(r,s,e,te)}this.elements=e,this.startReference=this.findStart();const t=e.filter(s=>s instanceof x);this._graph=new ge(t,this.startReference,this.startNode)}visualize(e="mermaid",t={}){var s,r,n,o,i;if(e==="mermaid")return this.graph.toMermaid({...t,flowMetadata:{label:this.label,processType:this.processType,status:this.status,description:(s=this.xmldata)==null?void 0:s.description,triggerType:(n=(r=this.startNode)==null?void 0:r.element)==null?void 0:n.triggerType,object:(i=(o=this.startNode)==null?void 0:o.element)==null?void 0:i.object}});if(e==="plantuml")return this.graph.toPlantUML();throw new Error("Unsupported format")}processNodeType(e,t,s,r){if(Array.isArray(e))for(const n of e)s.push(new r(n.name,t,n));else s.push(new r(e.name,t,e))}findStart(){var e,t;if(this.startElementReference)return this.startElementReference;if(this.startNode&&this.startNode.connectors&&this.startNode.connectors.length>0){const s=this.startNode.connectors[0];if(s.reference)return s.reference}if((e=this.startNode)!=null&&e.element){const s=this.startNode.element.scheduledPaths;if(s){const r=Array.isArray(s)?s:[s];if(r.length>0&&((t=r[0])!=null&&t.connector)){const n=r[0].connector.targetReference;if(n)return n}}}return""}toXMLString(){try{return this.generateDoc()}catch(e){const t=e instanceof Error?e.message:String(e);return console.warn(`Unable to write xml, caught an error: ${t}`),""}}generateDoc(){const e="http://soap.sforce.com/2006/04/metadata",t={attributeNamePrefix:"@_",format:!0,ignoreAttributes:!1,suppressBooleanAttributes:!1,suppressEmptyNode:!1},s=new O.XMLBuilder(t),r={...this.xmldata};r["@_xmlns"]||(r["@_xmlns"]=e),r["@_xmlns:xsi"]||(r["@_xmlns:xsi"]="http://www.w3.org/2001/XMLSchema-instance");const n={Flow:r};return s.build(n)}};E.ATTRIBUTE_TAGS=["description","apiVersion","processMetadataValues","processType","interviewLabel","label","status","runInMode","startElementReference","isTemplate","fullName","timeZoneSidKey","isAdditionalPermissionRequiredToRun","migratedFromWorkflowRuleName","triggerOrder","environments","segment"],E.NODE_TAGS=["actionCalls","apexPluginCalls","assignments","collectionProcessors","decisions","loops","orchestratedStages","recordCreates","recordDeletes","recordLookups","recordUpdates","recordRollbacks","screens","steps","subflows","waits","transforms","customErrors"],E.RESOURCE_TAGS=["textTemplates","stages"],E.VARIABLE_TAGS=["choices","constants","dynamicChoiceSets","formulas","variables"];let _=E;class A extends B{constructor(e,t,s){super(N.ATTRIBUTE,t,e),this.expression=s}}const k=class k{};k.autolaunchedType="AutoLaunchedFlow",k.backEndTypes=[k.autolaunchedType,"CustomEvent","InvocableProcess","Orchestrator","EvaluationFlow","ActionCadenceAutolaunchedFlow"],k.processBuilder=["Workflow"],k.surveyTypes=["Survey"],k.unsupportedTypes=["CheckoutFlow","FSCLending","FSCLending","LoyaltyManagementFlow"],k.visualTypes=["Flow","IndividualObjectLinkingFlow","LoginFlow","RoutingFlow","Appointments","ActionCadenceStepFlow","ContactRequestFlow","ContactRequestFlow","CustomerLifecycle","FieldServiceMobile","FieldServiceWeb","SurveyEnrich"],k.allTypes=function(){return[...this.backEndTypes,...this.visualTypes,...this.surveyTypes]};let h=k;class re{constructor(e,t,s){this.uri=e,this.flow=t,s&&(this.errorMessage=s)}}class v{constructor(e,t){this.docRefs=[],this.name=e.name,this.supportedTypes=e.supportedTypes,this.label=e.label,this.description=e.description,this.uri=`https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner/tree/main/src/main/rules/${e.name}.ts`,this.docRefs=e.docRefs;const s=this.check;if(typeof s=="function"){const r=s.toString();this.isConfigurable=/options[.\?]/.test(r)}else this.isConfigurable=!1;this.severity=(t==null?void 0:t.severity)??"error",this.suppressionElement=e.suppressionElement}execute(e,t,s=[]){if(s.includes("*"))return new q(this,[]);const r=new Set(s);let n=this.check(e,t,r);return n=n.filter(o=>!r.has(o.name)),new q(this,n)}isSuppressed(e,t){return t.has(e)}getStartNode(e){return e.startNode}getStartReference(e){return e.startReference||void 0}findStartIndex(e,t){const s=this.getStartReference(e);return s?t.findIndex(r=>r.name===s):-1}getStartProperty(e,t){var s,r;if((s=e.startNode)!=null&&s.element)return(r=e.startNode.element)==null?void 0:r[t]}}class q{constructor(e,t,s){this.details=[],this.ruleDefinition=e,this.ruleName=e.name,this.severity=e.severity?e.severity:"error",this.occurs=!1,this.details=t,t.length>0&&(this.occurs=!0),s&&(this.errorMessage=s)}}class ye{constructor(e,t){this.flow=e,this.ruleResults=t}}class y{constructor(e){var t;if(this.name=e.name,this.metaType=e.metaType,this.type=e.subtype,this.lineNumber=1,this.columnNumber=1,e.metaType===N.VARIABLE){const s=e;this.details={dataType:s.dataType}}else if(e.metaType===N.NODE){const s=e;this.details={connectsTo:(t=s.connectors)==null?void 0:t.map(r=>r.reference),locationX:s.locationX,locationY:s.locationY}}else if(e.metaType===N.ATTRIBUTE){const s=e;this.details={expression:s.expression}}}}function Pe(a,e){if(!e||a.length===0)return;const t=e.split(` -`),s=_.ATTRIBUTE_TAGS;for(const r of a){if(r.metaType!==N.ATTRIBUTE){for(let n=0;n${r.name}`)){r.lineNumber=n+1,r.columnNumber=t[n].indexOf(r.name)+1;break}}if(r.metaType===N.ATTRIBUTE){const n=r.type;if(s.includes(n)){for(let o=0;o`)){r.lineNumber=o+1,r.columnNumber=t[o].indexOf(`<${n}>`)+1;break}}}}}function _e(a,e,t){return a[t]=e.map(s=>s.element),a}function $e(a){let e={};for(const t of a){const s=t.subtype,r=a.filter(n=>s===n.subtype);e=_e(e,r,s)}return e}function Ue(a){const e=[];for(const t of a){if(!t.ruleResults||t.ruleResults.length===0)continue;const s=t.ruleResults.filter(o=>o.ruleName==="UnusedVariable"&&o.occurs||o.ruleName==="UnconnectedElement"&&o.occurs);if(s.length===0)continue;const r=Oe(t.flow,s);r.elements&&r.elements.length>0&&(t.flow=r,e.push(t))}return e}function Oe(a,e){var c,l,u;const t=e.find(d=>d.ruleName==="UnusedVariable"),s=new Set(((c=t==null?void 0:t.details)==null?void 0:c.map(d=>d.name))??[]),r=e.find(d=>d.ruleName==="UnconnectedElement"),n=new Set(((l=r==null?void 0:r.details)==null?void 0:l.map(d=>d.name))??[]),o=((u=a.elements)==null?void 0:u.filter(d=>{switch(d.metaType){case"attribute":case"resource":return!0;case"node":{const f=d;return!n.has(f.name)}case"variable":{const f=d;return!s.has(f.name)}default:return!1}}))??[],i=$e(o);return new _(a.fsPath,i)}class ne extends v{constructor(e,t){super(e,t)}check(e,t,s){const r=e.graph.getLoopNodes();return r.length?this.findStatementsInLoops(e,r).filter(i=>!s.has(i.name)).map(i=>new y(i)):[]}findLoopElements(e){return e.graph.getLoopNodes()}findLoopEnd(e){var t,s;return((s=(t=e.element)==null?void 0:t.noMoreValuesConnector)==null?void 0:s.targetReference)??e.name}findStatementsInLoops(e,t){const s=[],r=this.getStatementTypes();for(const n of t){const o=e.graph.getLoopElements(n.name);for(const i of o){const c=e.graph.getNode(i);c&&r.includes(c.subtype)&&s.push(c)}}return s}}class Ve extends ne{constructor(){super({description:"To prevent exceeding Apex governor limits, it is advisable to consolidate and bulkify your apex calls, utilize a single action call containing a collection variable at the end of the loop.",docRefs:[{label:"Invocable Method Considerations",path:"https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm"}],label:"Action Call In Loop",name:"ActionCallsInLoop",supportedTypes:h.backEndTypes},{severity:"error"})}getStatementTypes(){return["actionCalls","apexPluginCalls"]}}class Be extends v{constructor(){super({name:"APIVersion",label:"Outdated API Version",description:"Introducing newer API components may lead to unexpected issues with older versions of Flows, as they might not align with the underlying mechanics. Starting from API version 50.0, the 'Api Version' attribute has been readily available on the Flow Object. To ensure smooth operation and reduce discrepancies between API versions, it is strongly advised to regularly update and maintain them.",supportedTypes:h.allTypes(),docRefs:[]})}check(e,t,s){let r=null;if(e.xmldata.apiVersion&&(r=+e.xmldata.apiVersion),!r)return[new y(new A("API Version <49","apiVersion","<49"))];if(t!=null&&t.expression){const n=t.expression.match(/^\s*(>=|<=|>|<|===|!==)\s*(\d+)\s*$/);if(!n)return[new y(new A("Invalid API rule expression","apiVersion",t.expression))];const[,o,i]=n,c=parseFloat(i);let l=!0;switch(o){case">":l=r>c;break;case"<":l=r=":l=r>=c;break;case"<=":l=r<=c;break;case"===":l=r===c;break;case"!==":l=r!==c;break}if(!l)return[new y(new A(`${r}`,"apiVersion",t.expression))]}return[]}}class je extends v{constructor(){super({name:"AutoLayout",label:"Auto-Layout Mode",description:"With Canvas Mode set to Auto-Layout, Elements are spaced, connected, and aligned automatically, keeping your Flow neatly organized thus saving you time.",supportedTypes:h.allTypes(),docRefs:[]},{severity:"note"})}check(e,t){var n;if(!e.processMetadataValues)return[];const s=e.xmldata.processMetadataValues.find(o=>o.name==="CanvasMode");return(s==null?void 0:s.value)&&typeof s.value=="object"&&s.value.stringValue==="AUTO_LAYOUT_CANVAS"?[]:[new y(new A(((n=s==null?void 0:s.value)==null?void 0:n.stringValue)??"undefined","CanvasMode","!== AUTO_LAYOUT_CANVAS"))]}}class ze extends v{constructor(){super({name:"CopyAPIName",label:"Copy API Name",description:"Maintaining multiple elements with a similar name, like 'Copy_X_Of_Element,' can diminish the overall readability of your Flow. When copying and pasting these elements, it's crucial to remember to update the API name of the newly created copy.",supportedTypes:h.allTypes(),docRefs:[]})}check(e){return e.elements.filter(r=>r instanceof x).filter(r=>/Copy_[0-9]+_of_[A-Za-z0-9]+/.test(r.name)).map(r=>new y(r))}}class qe extends v{constructor(){super({name:"CyclomaticComplexity",label:"Cyclomatic Complexity",description:"The number of loops and decision rules, plus the number of decisions. Use a combination of 1) subflows and 2) breaking flows into multiple concise trigger ordered flows, to reduce the cyclomatic complexity within a single flow, ensuring maintainability and simplicity.",supportedTypes:h.backEndTypes,docRefs:[{label:"Cyclomatic complexity is a software metric used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program's source code.",path:"https://en.wikipedia.org/wiki/Cyclomatic_complexity"}]},{severity:"note"}),this.defaultThreshold=25,this.cyclomaticComplexityUnit=0}check(e,t){var i,c;const s=(t==null?void 0:t.threshold)||this.defaultThreshold;let r=1;const n=(i=e==null?void 0:e.elements)==null?void 0:i.filter(l=>l.subtype==="decisions"),o=(c=e==null?void 0:e.elements)==null?void 0:c.filter(l=>l.subtype==="loops");for(const l of n||[]){const u=l.element.rules;r+=Array.isArray(u)?u.length+1:1}return r+=(o==null?void 0:o.length)??0,this.cyclomaticComplexityUnit=r,r>s?[new y(new A(`${r}`,"CyclomaticComplexity",`>${s}`))]:[]}}class We extends ne{constructor(){super({description:"To prevent exceeding Apex governor limits, it is advisable to consolidate all your database operations, including record creation, updates, or deletions, at the conclusion of the flow.",docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"}],label:"DML Statement In A Loop",name:"DMLStatementInLoop",supportedTypes:h.backEndTypes},{severity:"error"})}getStatementTypes(){return["recordDeletes","recordUpdates","recordCreates"]}}class He extends v{constructor(){super({name:"DuplicateDMLOperation",label:"Duplicate DML Operation",description:"When the flow executes database changes between screens, users must not be allowed to navigate back, or duplicate DML operations may occur.",supportedTypes:h.visualTypes,docRefs:[]})}check(e,t,s){const r=e.graph,n=e.startReference;if(!n)return[];const o=[],i=new Set,c=[{name:n,seenDML:!1}];for(;c.length>0;){const{name:l,seenDML:u}=c.pop(),d=`${l}:${u}`;if(i.has(d))continue;i.add(d);const f=r.getNode(l);if(!f)continue;let b=u||this.isDML(f);b&&f.subtype==="screens"&&f.element.allowBack==="true"&&f.element.showFooter==="true"&&!s.has(f.name)&&o.push(new y(f)),b&&f.subtype==="screens"&&f.element.allowBack!=="true"&&(b=!1);for(const m of r.getNextElements(l))c.push({name:m,seenDML:b})}return o}isDML(e){return e.subtype==="recordCreates"||e.subtype==="recordUpdates"||e.subtype==="recordDeletes"}}class Ge extends v{constructor(){super({description:"Descriptions play a vital role in documentation. We highly recommend including details about where they are used and their intended purpose.",docRefs:[],label:"Missing Flow Description",name:"FlowDescription",supportedTypes:[...h.backEndTypes,...h.visualTypes]},{severity:"error"})}check(e,t,s){var r;return(r=e.xmldata)!=null&&r.description?[]:[new y(new A("undefined","description","!==null"))]}}class Xe extends v{constructor(){super({description:"The readability of a flow is of utmost importance. Establishing a naming convention for the Flow Name significantly enhances findability, searchability, and maintains overall consistency. It is advisable to include at least a domain and a brief description of the actions carried out in the flow, for instance, 'Service_OrderFulfillment'.",docRefs:[{label:"Naming your Flows is more critical than ever. By Stephen Church",path:"https://www.linkedin.com/posts/stephen-n-church_naming-your-flows-this-is-more-critical-activity-7099733198175158274-1sPx"}],label:"Flow Naming Convention",name:"FlowName",supportedTypes:h.allTypes()},{severity:"error"})}check(e,t,s){const r=(t==null?void 0:t.expression)??"[A-Za-z0-9]+_[A-Za-z0-9]+",n=e.name??"";return new RegExp(r).test(n)?[]:[new y(new A(n,"name",r))]}}class Qe extends v{constructor(){super({description:"Following the principle of least privilege (PoLP), avoid using Get Records with 'Automatically store all fields' unless necessary.",docRefs:[{label:"SOQL and SOSL | Best Practices for Deployments with Large Data Volumes",path:"https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/ldv_deployments_best_practices_soql_and_sosl.htm"},{label:"Indexes | Best Practices",path:"https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/ldv_deployments_infrastructure_indexes.htm"}],label:"Get Record All Fields",name:"GetRecordAllFields",supportedTypes:h.allTypes()},{severity:"warning"})}check(e,t,s){var o;return(((o=e.elements)==null?void 0:o.filter(i=>i.subtype==="recordLookups"))??[]).filter(i=>{const c=i.element,l=typeof c=="object"&&"storeOutputAutomatically"in c&&c.storeOutputAutomatically,u=typeof c=="object"&&Array.isArray(c.queriedFields)&&c.queriedFields.length>0;return l&&!u}).map(i=>new y(i))}}class Ye extends v{constructor(){super({name:"HardcodedId",label:"Hardcoded Id",description:"Avoid hard-coding IDs as they are org-specific. Instead, pass them into variables at the start of the flow. You can achieve this by utilizing merge fields in URL parameters or employing a Get Records element.",supportedTypes:h.allTypes(),docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"},{label:"Don't hard code Record Type IDs in Flow. By Stephen Church.",path:"https://www.linkedin.com/feed/update/urn:li:activity:6947530300012826624/"}]},{severity:"error"})}check(e,t,s){const r=/\b[a-zA-Z0-9]{5}0[a-zA-Z0-9]{9}(?:[a-zA-Z0-9]{3})?\b/g;return e.elements.filter(n=>r.test(JSON.stringify(n))).map(n=>new y(n))}}class Je extends v{constructor(){super({description:"Avoid hard-coding URLs as they are org-specific. Instead, use a $API formula (preferred) or you can use an environment-specific such as custom labels, custom metadata, or custom settings.",docRefs:[{label:"The Ultimate Guide to Salesforce Flow Best Practices",path:"https://admin.salesforce.com/blog/2021/the-ultimate-guide-to-flow-best-practices-and-standards"},{label:"Why You Should Avoid Hard Coding and Three Alternative Solutions",path:"https://admin.salesforce.com/blog/2021/why-you-should-avoid-hard-coding-and-three-alternative-solutions"}],label:"Hardcoded Url",name:"HardcodedUrl",supportedTypes:h.allTypes()},{severity:"error"})}check(e,t,s){if(!e.elements||e.elements.length===0)return[];const r=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}force\.com/g;return e.elements.filter(n=>r.test(JSON.stringify(n))).map(n=>new y(n))}}class Ze extends v{constructor(){super({name:"InactiveFlow",label:"Inactive Flow",description:"Like cleaning out your closet: deleting unused flows is essential. Inactive flows can still cause trouble, like accidentally deleting records during testing, or being activated as subflows within parent flows.",supportedTypes:h.allTypes(),docRefs:[]})}check(e,t,s){return e.status!=="Active"?[new y(new A(e.status,"status","!= Active"))]:[]}}class Ke extends v{constructor(){super({description:"At times, a flow may fail to execute a configured operation as intended. By default, the flow displays an error message to the user and notifies the admin who created the flow via email. However, you can customize this behavior by incorporating a Fault Path. This rule checks DML operations, actions (Send Email, Quick Actions), and Invocable Apex Actions for proper error handling.",docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"}],label:"Missing Fault Path",name:"MissingFaultPath",supportedTypes:[...h.backEndTypes,...h.visualTypes]}),this.applicableElements=["recordLookups","recordDeletes","recordUpdates","recordCreates","waits","actionCalls","apexPluginCalls"]}isValidSubtype(e){var t;if(!this.applicableElements.includes(e.subtype))return!1;if(e.subtype==="waits"){const s=(t=e.element)==null?void 0:t.elementSubtype;return!["WaitDuration","WaitDate"].includes(s)}return!0}check(e,t,s){var c;const r=[],n=e.elements.filter(l=>{const u=l;return this.isValidSubtype(u)}).map(l=>l.name),o=this.isRecordBeforeSaveFlow(e),i=l=>{var u;if(!((u=l==null?void 0:l.connectors)!=null&&u.find(d=>d.type==="faultConnector"))&&n.includes(l.name)){if(o&&l.subtype==="recordUpdates")return;this.isPartOfFaultHandlingFlow(l,e)||s.has(l.name)||r.push(new y(l))}};return(c=e.graph)==null||c.forEachReachable(i),r}isRecordBeforeSaveFlow(e){var t,s;return!!((t=e.startNode)!=null&&t.element&&((s=e.startNode.element)==null?void 0:s.triggerType)==="RecordBeforeSave")}isPartOfFaultHandlingFlow(e,t){var s;return((s=t.graph)==null?void 0:s.isPartOfFaultHandling(e.name))||!1}}class et extends v{constructor(){super({description:"When a Get Records operation doesn't find any data, it returns null. To ensure data validation, utilize a decision element on the operation result variable to check for a non-null result.",docRefs:[],label:"Missing Null Handler",name:"MissingNullHandler",supportedTypes:[...h.backEndTypes,...h.visualTypes]})}check(e,t,s){var c,l;const r=["recordLookups"],n=e.elements.filter(u=>u.metaType==="node"&&r.includes(u.subtype)),o=e.elements.filter(u=>u.metaType==="node"&&u.subtype==="decisions"),i=[];for(const u of n){if(s.has(u.name))continue;const d=u.name;if(!(String(u.element.assignNullValuesIfNoRecordsFound).toLowerCase()==="true")||!!u.element.faultConnector||((c=u.connectors)==null?void 0:c.some(R=>R.type==="faultConnector")))continue;const m=[];if(u.element.storeOutputAutomatically)m.push(d);else if(u.element.outputReference)m.push(u.element.outputReference);else if(u.element.outputAssignments){const R=u.element.outputAssignments;for(const C of R)m.push(C.assignToReference)}if(!e.elements.some(R=>{if(R.name===u.name)return!1;const C=JSON.stringify(R.element);return m.some(I=>C.includes(`"${I}"`)||C.includes(`"${I}.`))}))continue;let S=!1;for(const R of o){let C=R.element.rules;Array.isArray(C)||(C=[C]);for(const I of C){let G=I.conditions;Array.isArray(G)||(G=[G]);for(const X of G){let Te=!1,Ce=!1,Se=!1;if(X.leftValueReference){const vt=X.leftValueReference;m.some(Tt=>vt.startsWith(Tt))&&(Te=!0)}X.operator==="IsNull"&&(Ce=!0);const Ae=(l=X.rightValue)==null?void 0:l.booleanValue;if(Ae!=null&&String(Ae).toLowerCase()==="false"&&(Se=!0),Te&&Ce&&Se){S=!0;break}}if(S)break}if(S)break}S||i.push(u)}return i.map(u=>new y(u))}}class tt extends v{constructor(){super({name:"ProcessBuilder",label:"No Process Builder",description:"Salesforce is transitioning away from Workflow Rules and Process Builder in favor of Flow. Ensure you're prepared for this transition by migrating your organization's automation to Flow. Refer to official documentation for more information on the transition process and tools available.",supportedTypes:h.processBuilder,docRefs:[{label:"Process Builder Retirement",path:"https://help.salesforce.com/s/articleView?id=000389396&type=1"}]})}check(e,t,s){return[new y(new A("Workflow","processType","== Workflow"))]}}class st extends v{constructor(){super({description:"After updates are meant to be used for record modifications that are not the same record that triggered the flow. Using after updates on the same record can lead to recursion and unexpected behavior. Consider using before save flows for same record updates.",docRefs:[{label:"Learn about same record field updates",path:"https://architect.salesforce.com/decision-guides/trigger-automation#Same_Record_Field_Updates"}],label:"Recursive After Update",name:"RecursiveAfterUpdate",supportedTypes:[...h.backEndTypes]},{severity:"warning"}),this.qualifiedRecordTriggerTypes=new Set(["Create","CreateAndUpdate","Update"])}check(e,t,s){var f,b,m;const r=[],n=this.getStartProperty(e,"triggerType"),o=this.getStartProperty(e,"recordTriggerType"),i=n==="RecordAfterSave",c=this.qualifiedRecordTriggerTypes.has(o);if(!i||!c)return r;const l=(f=e.elements)==null?void 0:f.filter(p=>p.subtype==="recordUpdates");if(l==null||typeof l[Symbol.iterator]!="function")return r;for(const p of l)typeof p.element=="object"&&"inputReference"in p.element&&p.element.inputReference==="$Record"&&(s.has(p.name)||r.push(new y(p)));const u=this.getStartProperty(e,"object"),d=(m=(b=e.elements)==null?void 0:b.filter(p=>p.subtype==="recordLookups"&&typeof p.element=="object"&&"object"in p.element&&u===p.element.object))==null?void 0:m.map(p=>p.name);if(d==null||typeof d[Symbol.iterator]!="function")return r;for(const p of l)typeof p.element=="object"&&"inputReference"in p.element&&d.includes(p.element.inputReference)&&(s.has(p.name)||r.push(new y(p)));return r}}class rt extends v{constructor(){super({name:"SameRecordFieldUpdates",label:"Same Record Field Updates",description:"Before-save same-record field updates allows you to update the record using variable assignments to `$Record`. This is significantly faster than doing another DML on the same-record that triggered the flow",supportedTypes:[...h.backEndTypes],docRefs:[{label:"Learn about same record field updates",path:"https://architect.salesforce.com/decision-guides/trigger-automation#Same_Record_Field_Updates"}]},{severity:"warning"}),this.qualifiedRecordTriggerTypes=new Set(["Create","Update","CreateAndUpdate"])}check(e,t,s){var u;const r=[],n=this.getStartProperty(e,"triggerType"),o=this.getStartProperty(e,"recordTriggerType"),i=n==="RecordBeforeSave",c=this.qualifiedRecordTriggerTypes.has(o);if(!i||!c)return r;const l=(u=e.elements)==null?void 0:u.filter(d=>d.subtype==="recordUpdates");if(!l)return r;for(const d of l)typeof d.element=="object"&&"inputReference"in d.element&&d.element.inputReference==="$Record"&&r.push(new y(d));return r}}class nt extends ne{constructor(){super({description:"To prevent exceeding Apex governor limits, it is advisable to consolidate all your SOQL queries at the conclusion of the flow.",docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"}],label:"SOQL Query In A Loop",name:"SOQLQueryInLoop",supportedTypes:h.backEndTypes},{severity:"error"})}getStatementTypes(){return["recordLookups"]}}class ot extends v{constructor(){super({name:"TriggerOrder",label:"Trigger Order",description:"With flow trigger ordering, introduced in Spring '22, admins can now assign a priority value to their flows and guarantee their execution order. This priority value is not an absolute value, so the values need not be sequentially numbered as 1, 2, 3, and so on.",supportedTypes:[h.autolaunchedType],docRefs:[{label:"Learn more about flow ordering orchestration",path:"https://architect.salesforce.com/decision-guides/trigger-automation#Ordering___Orchestration"}]},{severity:"note"})}check(e,t,s){return this.getStartProperty(e,"object")?e.triggerOrder?[]:[new y(new A("TriggerOrder","TriggerOrder","10, 20, 30 ..."))]:[]}}class it extends v{constructor(){super({description:"To maintain the efficiency and manageability of your Flow, it's best to avoid including unconnected elements that are not in use.",docRefs:[],label:"Unconnected Element",name:"UnconnectedElement",supportedTypes:[...h.backEndTypes,...h.visualTypes]})}check(e,t,s){var i;const r=((i=e.graph)==null?void 0:i.getReachableElements())||new Set;return e.elements.filter(c=>c instanceof x).filter(c=>!r.has(c.name)&&!s.has(c.name)).map(c=>new y(c))}}class at extends v{constructor(){super({name:"UnsafeRunningContext",label:"Unsafe Running Context",description:"This flow is configured to run in System Mode without Sharing. This system context grants all running users the permission to view and edit all data in your org. Running a flow in System Mode without Sharing can lead to unsafe data access.",supportedTypes:[...h.backEndTypes,...h.visualTypes],docRefs:[{label:"Learn about data safety when running flows in system context in Salesforce Help",path:"https://help.salesforce.com/s/articleView?id=sf.flow_distribute_context_data_safety_system_context.htm&type=5"}]},{severity:"error"})}check(e,t,s){if(!("runInMode"in e.xmldata))return[];const r=e.xmldata.runInMode,n="SystemModeWithoutSharing";return r===n?[new y(new A(r,"runInMode",`== ${n}`))]:[]}}class ct extends v{constructor(){super({name:"UnusedVariable",label:"Unused Variable",description:"To maintain the efficiency and manageability of your Flow, it's advisable to avoid including unconnected variables that are not in use.",supportedTypes:[...h.backEndTypes,...h.visualTypes],docRefs:[]})}check(e,t,s){const r=e.elements.filter(o=>o instanceof j),n=[];for(const o of r){const i=o.name;if([...JSON.stringify(e.elements.filter(f=>f instanceof x)).matchAll(new RegExp(i,"gi"))].map(f=>f.index).length>0||[...JSON.stringify(e.elements.filter(f=>f instanceof te)).matchAll(new RegExp(i,"gi"))].map(f=>f.index).length>0)continue;const u=[...JSON.stringify(o).matchAll(new RegExp(o.name,"gi"))].map(f=>f.index);[...JSON.stringify(e.elements.filter(f=>f instanceof j)).matchAll(new RegExp(i,"gi"))].map(f=>f.index).length===u.length&&n.push(o)}return n.map(o=>new y(o))}}class lt extends v{constructor(){super({description:"Every element must have a meaningful description",docRefs:[],label:"Missing Metadata Description",name:"MissingMetadataDescription",supportedTypes:h.allTypes()},{severity:"error"})}check(e,t,s){const r=[];return e.elements.filter(n=>{if(n.metaType!=="attribute"&&!n.element.description&&n.subtype!=="start")return n}).forEach(n=>r.push(new y(n))),r}}class ut extends v{constructor(){super({name:"MissingFilterRecordTrigger",label:"Missing Record Trigger Filter",description:"Detects record-triggered flows that lack filters on changed fields or entry conditions, leading to unnecessary executions on every record change. This can degrade system performance, hit governor limits faster, and increase resource consumption in high-volume orgs.",supportedTypes:[h.autolaunchedType],docRefs:[]})}check(e,t,s){var u,d;const r=[],n=this.getStartProperty(e,"triggerType");if(!n||!["RecordAfterSave","RecordBeforeSave"].includes(n))return r;const i=!!this.getStartProperty(e,"filters"),l=!!((d=(u=e.xmldata)==null?void 0:u.start)==null?void 0:d.scheduledPaths);return!i&&!l&&r.push(new y(new A(n,"triggerType","autolaunched && triggerType"))),r}}class dt extends v{constructor(){super({name:"TransformInsteadOfLoop",label:"Transform Instead of Loop",description:"Detects Loop elements that directly connect to Assignment elements. This pattern can often be replaced with the Transform element, which is on average 10x more performant according to Salesforce documentation.",supportedTypes:h.allTypes(),docRefs:[{label:"Transform Multiple Records - Trailhead",path:"https://trailhead.salesforce.com/content/learn/modules/multirecord-elements-and-transforms-in-flows/transform-multiple-records"}]},{severity:"note"})}check(e,t,s){const r=[];if(this.getStartProperty(e,"triggerType")==="RecordBeforeSave")return r;const i=e.graph.getLoopNodes();for(const c of i){const l=e.graph.getNextElements(c.name);for(const u of l){const d=e.graph.getNode(u);if((d==null?void 0:d.subtype)==="assignments"){r.push(new y(c));break}}}return r}}class ft extends v{constructor(){super({name:"RecordIdAsString",label:"Record ID as String Instead of Record",description:"Detects flows using a String variable named 'recordId' as input when they could receive the entire record object instead. Since recent Salesforce releases, record pages and quick actions can pass the complete record, eliminating the need for an additional Get Records query and improving performance.",supportedTypes:[...h.visualTypes,h.autolaunchedType],docRefs:[{label:"Screen Flow Distribution",path:"https://help.salesforce.com/s/articleView?id=sf.flow_distribute_screen.htm"}]},{severity:"error"})}check(e,t,s){var c;const r=[],n=this.getStartProperty(e,"triggerType");if(n==="RecordAfterSave"||n==="RecordBeforeDelete"||n==="RecordBeforeSave")return r;const i=(c=e.elements)==null?void 0:c.filter(l=>l.subtype==="variables");for(const l of i){const u=l.element;(u.isInput===!0||u.isInput==="true")&&l.name.toLowerCase()==="recordid"&&u.dataType==="String"&&r.push(new y(l))}return r}}const be={ActionCallsInLoop:Ve,APIVersion:Be,AutoLayout:je,CopyAPIName:ze,CyclomaticComplexity:qe,DMLStatementInLoop:We,DuplicateDMLOperation:He,FlowDescription:Ge,FlowName:Xe,GetRecordAllFields:Qe,HardcodedId:Ye,HardcodedUrl:Je,InactiveFlow:Ze,MissingFaultPath:Ke,MissingNullHandler:et,ProcessBuilder:tt,RecursiveAfterUpdate:st,SameRecordFieldUpdates:rt,SOQLQueryInLoop:nt,TriggerOrder:ot,UnconnectedElement:it,UnsafeRunningContext:at,UnusedVariable:ct},oe={MissingMetadataDescription:lt,MissingFilterRecordTrigger:ut,TransformInsteadOfLoop:dt,RecordIdAsString:ft};class we{constructor(e,t=!1){return t&&oe.hasOwnProperty(e)?new oe[e]:new be[e]}}function ie(a,e){const t=[],s=(e==null?void 0:e.betaMode)===!0||(e==null?void 0:e.betamode)===!0;if(((e==null?void 0:e.ruleMode)||"merged")==="isolated"&&a&&a.size>0){for(const o of a.keys())try{const i=a.get(o);if(i&&i.enabled===!1)continue;const c=new we(o,s),l=i==null?void 0:i.severity;l&&(l==="error"||l==="warning"||l==="note")&&(c.severity=l),t.push(c)}catch(i){console.log(i.message)}return t}const n=new Set;for(const o in be)n.add(o);if(s)for(const o in oe)n.add(o);for(const o of n)try{const i=a==null?void 0:a.get(o);if(i&&i.enabled===!1)continue;const c=new we(o,s),l=i==null?void 0:i.severity;l&&(l==="error"||l==="warning"||l==="note")&&(c.severity=l),t.push(c)}catch(i){console.log(i.message)}return t}function pt(a,e){if(a&&a.length>0){const t=new Map(a.map(s=>[s,{severity:"error"}]));return ie(t,e)}return ie(void 0,e)}var ae,ve;function ht(){if(ve)return ae;ve=1;var a=null;return ae=a,ae}var mt=ht();async function gt(a){const e=[],t=new O.XMLParser({attributeNamePrefix:"@_",ignoreAttributes:!1,ignoreNameSpace:!1,parseTagValue:!1,textNodeName:"#text"});for(const s of a)try{const r=z.normalize(s),n=await mt.promises.readFile(r,"utf8"),i=t.parse(n).Flow;e.push(new re(s,new _(s,i)))}catch(r){e.push(new re(s,void 0,r.message??r.toString()))}return e}var H=(a=>(a.ENRICHED="enriched",a.SIMPLE="simple",a))(H||{});function yt(a,e){const t=[];for(const r of a)!r.errorMessage&&r.flow&&t.push(r.flow);return bt(t,e)}function bt(a,e){var c,l,u;const t=[],s=e==null?void 0:e.detailLevel,r=typeof s=="string"&&s.toLowerCase()==="simple"?H.SIMPLE:H.ENRICHED;let n;if(e!=null&&e.rules&&Object.keys(e.rules).length>0){n=new Map;for(const[d,f]of Object.entries(e.rules))n.set(d,f)}const o=ie(n,e),i=new Map;for(const d of a){const f=d instanceof _?d:_.from(d),b=[];for(const m of o)try{if(!m.supportedTypes.includes(f.type)){b.push(new q(m,[]));continue}let p;(c=e==null?void 0:e.rules)!=null&&c[m.name]&&(p=e.rules[m.name]);const S=(u=(l=e==null?void 0:e.exceptions)==null?void 0:l[f.name])==null?void 0:u[m.name],R=S!=null&&S.includes("*")?["*"]:S??[],C=p&&Object.keys(p).length>0?m.execute(f,p,R):m.execute(f,void 0,R);if(C.severity!==m.severity&&(C.severity=m.severity),C.details.length>0){let I=i.get(f.name);I||(I=f.toXMLString(),i.set(f.name,I)),I&&Pe(C.details,I)}b.push(C)}catch(p){const S=`Something went wrong while executing ${m.name} in the Flow: ${f.name} with error ${p}`;b.push(new q(m,[],S))}t.push(new ye(f,b)),i.delete(f.name)}return i.clear(),r===H.SIMPLE&&t.forEach(d=>{d.ruleResults.forEach(f=>{f.details.forEach(b=>{delete b.details})})}),t}function wt(a,e={includeDetails:!0,includeMarkdownDocs:!0,collapsedDetails:!0}){const t=a.filter(n=>n.flow).map(n=>n.flow);let s=`# Flow Documentation +`}return e+="@enduml",e}constructor(e,r,i){le(this,"nodeMap",new Map),le(this,"reachableFromStart",new Set),le(this,"normalReachableFromStart",new Set),le(this,"elementsInLoop",new Map),le(this,"faultConnectors",new Map),le(this,"normalConnectors",new Map),le(this,"allConnectors",new Map),le(this,"reverseConnectors",new Map),this.buildNodeMaps(e),this.buildConnectorMaps(e),i?this.addStartNodeConnectors(i):r&&this.addStartEdgeFromReference(r),this.computeLoopBoundaries(),r&&(this.computeReachability(r),this.computeNormalReachability(r))}}});var Ae=P(Wt=>{"use strict";Object.defineProperty(Wt,"__esModule",{value:!0});Object.defineProperty(Wt,"Flow",{enumerable:!0,get:function(){return Ee}});var Fa=Ct(),ze=La(Be()),Ia=qn(),Te=He(),Ma=Ge(),Da=je(),Hn=kt();function q(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jn(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(jn=function(i){return i?r:e})(t)}function La(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=jn(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}function Gn(t){for(var e=1;er instanceof Te.FlowNode);this.startReference||(this.startReference=this.findStart()),this._graph=new Hn.FlowGraph(e,this.startReference,this.startNode)}return this._graph}static from(e){if(e instanceof he)return e;let r=Object.create(he.prototype);return Object.assign(r,e),r.toXMLString||(r.toXMLString=()=>""),r}preProcessNodes(){if(!this.xmldata)return;this.label=this.xmldata.label||"",this.interviewLabel=this.xmldata.interviewLabel,this.processType=this.xmldata.processType||"AutoLaunchedFlow",this.type=this.processType,this.processMetadataValues=this.xmldata.processMetadataValues,this.startElementReference=this.xmldata.startElementReference,this.status=this.xmldata.status||"Draft",this.triggerOrder=this.xmldata.triggerOrder;let e=[];for(let i in this.xmldata){if(i.startsWith("@_")||i==="@xmlns")continue;let l=this.xmldata[i];if(i==="start"){Array.isArray(l)&&l.length>0?this.startNode=new Te.FlowNode(l[0].name||"start","start",l[0]):Array.isArray(l)||(this.startNode=new Te.FlowNode(l.name||"start","start",l));continue}he.ATTRIBUTE_TAGS.includes(i)?this.processNodeType(l,i,e,Ia.FlowMetadata):he.VARIABLE_TAGS.includes(i)?this.processNodeType(l,i,e,Da.FlowVariable):he.NODE_TAGS.includes(i)?this.processNodeType(l,i,e,Te.FlowNode):he.RESOURCE_TAGS.includes(i)&&this.processNodeType(l,i,e,Ma.FlowResource)}this.elements=e,this.startReference=this.findStart();let r=e.filter(i=>i instanceof Te.FlowNode);this._graph=new Hn.FlowGraph(r,this.startReference,this.startNode)}visualize(e="mermaid",r={}){if(e==="mermaid"){var i,l,a,d,v;return this.graph.toMermaid(qa(Gn({},r),{flowMetadata:{label:this.label,processType:this.processType,status:this.status,description:(i=this.xmldata)===null||i===void 0?void 0:i.description,triggerType:(a=this.startNode)===null||a===void 0||(l=a.element)===null||l===void 0?void 0:l.triggerType,object:(v=this.startNode)===null||v===void 0||(d=v.element)===null||d===void 0?void 0:d.object}}))}else if(e==="plantuml")return this.graph.toPlantUML();throw new Error("Unsupported format")}processNodeType(e,r,i,l){if(Array.isArray(e))for(let a of e)i.push(new l(a.name,r,a));else i.push(new l(e.name,r,e))}findStart(){var e;if(this.startElementReference)return this.startElementReference;if(this.startNode&&this.startNode.connectors&&this.startNode.connectors.length>0){let i=this.startNode.connectors[0];if(i.reference)return i.reference}if(!((e=this.startNode)===null||e===void 0)&&e.element){let i=this.startNode.element.scheduledPaths;if(i){var r;let l=Array.isArray(i)?i:[i];if(l.length>0&&(!((r=l[0])===null||r===void 0)&&r.connector)){let a=l[0].connector.targetReference;if(a)return a}}}return""}toXMLString(){try{return this.generateDoc()}catch(e){let r=e instanceof Error?e.message:String(e);return console.warn(`Unable to write xml, caught an error: ${r}`),""}}generateDoc(){let e="http://soap.sforce.com/2006/04/metadata",r={attributeNamePrefix:"@_",format:!0,ignoreAttributes:!1,suppressBooleanAttributes:!1,suppressEmptyNode:!1},i=new Fa.XMLBuilder(r),l=Gn({},this.xmldata);l["@_xmlns"]||(l["@_xmlns"]=e),!l["@_xmlns:xsi"]&&this.hasXsiAttributes(l)&&(l["@_xmlns:xsi"]="http://www.w3.org/2001/XMLSchema-instance");let a={Flow:l},d=i.build(a),v=` +`;return d.startsWith("{"use strict";Object.defineProperty(Bt,"__esModule",{value:!0});Object.defineProperty(Bt,"FlowAttribute",{enumerable:!0,get:function(){return Wa}});var $a=de(),Ua=oe();function ka(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Wa=class extends Ua.FlowElement{constructor(e,r,i){super($a.MetaType.ATTRIBUTE,r,e),ka(this,"expression",void 0),this.expression=i}}});var Gt=P(Ht=>{"use strict";Object.defineProperty(Ht,"__esModule",{value:!0});Object.defineProperty(Ht,"FlowType",{enumerable:!0,get:function(){return K}});function me(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var K=class{};me(K,"autolaunchedType","AutoLaunchedFlow");me(K,"backEndTypes",[K.autolaunchedType,"CustomEvent","InvocableProcess","Orchestrator","EvaluationFlow","ActionCadenceAutolaunchedFlow"]);me(K,"processBuilder",["Workflow"]);me(K,"surveyTypes",["Survey"]);me(K,"unsupportedTypes",["ActionPlan","UserProvisioningFlow","CheckoutFlow","FSCLending","LoyaltyManagementFlow","JourneyBuilderIntegration"]);me(K,"visualTypes",["Flow","IndividualObjectLinkingFlow","LoginFlow","RoutingFlow","Appointments","ActionCadenceStepFlow","ContactRequestFlow","CustomerLifecycle","FieldServiceMobile","FieldServiceWeb","SurveyEnrich"]);me(K,"allTypes",function(){return[...this.backEndTypes,...this.visualTypes,...this.surveyTypes]})});var Ze=P(zt=>{"use strict";Object.defineProperty(zt,"__esModule",{value:!0});Object.defineProperty(zt,"ParsedFlow",{enumerable:!0,get:function(){return Ba}});function jt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ba=class{constructor(e,r,i){jt(this,"uri",void 0),jt(this,"flow",void 0),jt(this,"errorMessage",void 0),this.uri=e,this.flow=r,i&&(this.errorMessage=i)}}});var D=P(Zt=>{"use strict";Object.defineProperty(Zt,"__esModule",{value:!0});Object.defineProperty(Zt,"RuleCommon",{enumerable:!0,get:function(){return Ga}});var Xt=Ha(S());function Z(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function zn(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(zn=function(i){return i?r:e})(t)}function Ha(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=zn(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Ga=class{execute(e,r,i=[]){if(i.includes("*"))return new Xt.RuleResult(this,[]);if(i.includes(this.ruleId)||i.includes(this.name))return new Xt.RuleResult(this,[]);let l=new Set(i),a=this.check(e,r,l);return a=a.filter(d=>!l.has(d.name)),new Xt.RuleResult(this,a)}isSuppressed(e,r){return r.has(e)}getStartNode(e){return e.startNode}getStartReference(e){return e.startReference||void 0}findStartIndex(e,r){let i=this.getStartReference(e);return i?r.findIndex(l=>l.name===i):-1}getStartProperty(e,r){var i;if(!((i=e.startNode)===null||i===void 0)&&i.element){var l;return(l=e.startNode.element)===null||l===void 0?void 0:l[r]}}constructor(e,r){Z(this,"category",void 0),Z(this,"description",void 0),Z(this,"summary",void 0),Z(this,"docRefs",[]),Z(this,"isConfigurable",void 0),Z(this,"configurableOptions",void 0),Z(this,"isFixable",void 0),Z(this,"label",void 0),Z(this,"name",void 0),Z(this,"severity",void 0),Z(this,"supportedTypes",void 0),Z(this,"uri",void 0),Z(this,"ruleId",void 0),this.category=e.category,this.ruleId=e.ruleId,this.name=e.name,this.supportedTypes=e.supportedTypes,this.label=e.label,this.description=e.description,this.summary=e.summary,this.uri=`https://github.com/Lightning-Flow-Scanner/lightning-flow-scanner/tree/main/src/main/rules/${e.name}.ts`,this.docRefs=e.docRefs,this.configurableOptions=e.configurableOptions,this.isConfigurable=!!(e.configurableOptions&&e.configurableOptions.length>0);var i;this.isFixable=(i=e.isFixable)!==null&&i!==void 0?i:!1;var l;this.severity=(l=r?.severity)!==null&&l!==void 0?l:"warning"}}});var Qt=P(Yt=>{"use strict";Object.defineProperty(Yt,"__esModule",{value:!0});Object.defineProperty(Yt,"RuleResult",{enumerable:!0,get:function(){return ja}});function ee(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ja=class{constructor(e,r,i){ee(this,"occurs",void 0),ee(this,"ruleName",void 0),ee(this,"ruleId",void 0),ee(this,"ruleDefinition",void 0),ee(this,"severity",void 0),ee(this,"details",[]),ee(this,"errorMessage",void 0),ee(this,"message",void 0),ee(this,"messageUrl",void 0),this.ruleDefinition=e,this.ruleName=e.name,this.ruleId=e.ruleId,this.severity=e.severity?e.severity:"warning",this.occurs=!1,this.details=r,r.length>0&&(this.occurs=!0),i&&(this.errorMessage=i)}}});var Kt=P(Jt=>{"use strict";Object.defineProperty(Jt,"__esModule",{value:!0});Object.defineProperty(Jt,"ScanResult",{enumerable:!0,get:function(){return za}});function Xn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var za=class{constructor(e,r){Xn(this,"flow",void 0),Xn(this,"ruleResults",void 0),this.flow=e,this.ruleResults=r}}});var Fe=P(er=>{"use strict";Object.defineProperty(er,"__esModule",{value:!0});function Xa(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}Xa(er,{get Violation(){return Ya},get enrichViolationsWithLineNumbers(){return Qa}});var Se=de(),Za=Ae();function Pe(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ya=class{constructor(e){if(Pe(this,"columnNumber",void 0),Pe(this,"details",void 0),Pe(this,"lineNumber",void 0),Pe(this,"metaType",void 0),Pe(this,"name",void 0),Pe(this,"type",void 0),this.name=e.name,this.metaType=e.metaType,this.type=e.subtype,this.lineNumber=1,this.columnNumber=1,e.metaType===Se.MetaType.VARIABLE){let i=e;this.details={dataType:i.dataType}}else if(e.metaType===Se.MetaType.NODE){var r;let i=e;this.details={connectsTo:(r=i.connectors)===null||r===void 0?void 0:r.map(l=>l.reference),locationX:i.locationX,locationY:i.locationY}}else if(e.metaType===Se.MetaType.ATTRIBUTE){let i=e;this.details={expression:i.expression}}}};function Qa(t,e){if(!e||t.length===0)return;let r=e.split(` +`),i=Za.Flow.ATTRIBUTE_TAGS;for(let l of t){if(l.metaType!==Se.MetaType.ATTRIBUTE){for(let a=0;a${l.name}`)){l.lineNumber=a+1,l.columnNumber=r[a].indexOf(l.name)+1;break}}if(l.metaType===Se.MetaType.ATTRIBUTE){let a=l.type;if(i.includes(a)){for(let d=0;d`)){l.lineNumber=d+1,l.columnNumber=r[d].indexOf(`<${a}>`)+1;break}}}}}});var S=P(tr=>{"use strict";Object.defineProperty(tr,"__esModule",{value:!0});function Ja(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}Ja(tr,{get Compiler(){return Ka.Compiler},get Flow(){return el.Flow},get FlowAttribute(){return tl.FlowAttribute},get FlowElement(){return rl.FlowElement},get FlowGraph(){return nl.FlowGraph},get FlowNode(){return il.FlowNode},get FlowResource(){return ol.FlowResource},get FlowType(){return sl.FlowType},get FlowVariable(){return al.FlowVariable},get ParsedFlow(){return ll.ParsedFlow},get RuleCommon(){return cl.RuleCommon},get RuleResult(){return ul.RuleResult},get ScanResult(){return dl.ScanResult},get Violation(){return pl.Violation}});var Ka=We(),el=Ae(),tl=Xe(),rl=oe(),nl=kt(),il=He(),ol=Ge(),sl=Gt(),al=je(),ll=Ze(),cl=D(),ul=Qt(),dl=Kt(),pl=Fe()});var Jn=P(nr=>{"use strict";Object.defineProperty(nr,"__esModule",{value:!0});function fl(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}fl(nr,{get FixFlows(){return wl},get fix(){return ml}});var rr=hl(S());function Yn(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Yn=function(i){return i?r:e})(t)}function hl(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Yn(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}function ml(t,e){let r=[];for(let l of t){if(!l.ruleResults||l.ruleResults.length===0)continue;let a=l.ruleResults.filter(_=>_.ruleName==="UnusedVariable"&&_.occurs||_.ruleName==="UnconnectedElement"&&_.occurs||_.ruleName==="AutoLayout"&&_.occurs||_.ruleName==="APIVersion"&&_.occurs);if(a.length===0)continue;if(a.find(_=>_.ruleName==="AutoLayout")&&gl(l.flow),a.find(_=>_.ruleName==="APIVersion")){var i;let _=(i=e?.get("invalid-api-version"))!==null&&i!==void 0?i:e?.get("APIVersion");vl(l.flow,_)}let y=a.filter(_=>_.ruleName!=="AutoLayout");y.length>0&&Qn(l.flow,y),r.push(l)}return r}function gl(t){if(!t.xmldata)return;t.xmldata.processMetadataValues?Array.isArray(t.xmldata.processMetadataValues)||(t.xmldata.processMetadataValues=[t.xmldata.processMetadataValues]):t.xmldata.processMetadataValues=[];let e=t.xmldata.processMetadataValues.findIndex(i=>i.name==="CanvasMode"),r={name:"CanvasMode",value:{stringValue:"AUTO_LAYOUT_CANVAS"}};e>=0?t.xmldata.processMetadataValues[e]=r:t.xmldata.processMetadataValues.push(r),t.processMetadataValues=t.xmldata.processMetadataValues}function yl(t){if(!t)return 50;let e=t.match(/^\s*(>=|<=|>|<|===|!==)\s*(\d+)\s*$/);if(!e)return;let[,r,i]=e,l=parseInt(i,10);switch(r){case">=":case"===":return l;case">":return l+1;default:return}}function vl(t,e){if(!t.xmldata)return;let r=yl(e?.expression);r!==void 0&&(t.xmldata.apiVersion=r.toString())}function Qn(t,e){var r,i;if(!t.xmldata)return;let l=e.find(b=>b.ruleName==="UnusedVariable");var a;let d=new Set((a=l==null||(r=l.details)===null||r===void 0?void 0:r.map(b=>b.name))!==null&&a!==void 0?a:[]),v=e.find(b=>b.ruleName==="UnconnectedElement");var y;let _=new Set((y=v==null||(i=v.details)===null||i===void 0?void 0:i.map(b=>b.name))!==null&&y!==void 0?y:[]);if(d.size>0)for(let b of rr.Flow.VARIABLE_TAGS)Zn(t.xmldata,b,d);if(_.size>0)for(let b of rr.Flow.NODE_TAGS)Zn(t.xmldata,b,_);t.preProcessNodes()}function Zn(t,e,r){let i=t[e];if(i)if(Array.isArray(i)){let l=i.filter(a=>!r.has(a?.name));l.length===0?delete t[e]:l.length===1?t[e]=l[0]:t[e]=l}else typeof i=="object"&&i!==null&&r.has(i.name)&&delete t[e]}function wl(t,e){let r=JSON.parse(JSON.stringify(t.xmldata)),i=new rr.Flow(t.fsPath,r);return Qn(i,e),i}});var Ye=P(ir=>{"use strict";Object.defineProperty(ir,"__esModule",{value:!0});Object.defineProperty(ir,"LoopRuleCommon",{enumerable:!0,get:function(){return Ol}});var bl=S(),_l=D(),Ol=class extends _l.RuleCommon{check(e,r,i){let l=e.graph.getLoopNodes();return l.length?this.findStatementsInLoops(e,l).filter(v=>!i.has(v.name)).map(v=>new bl.Violation(v)):[]}findLoopElements(e){return e.graph.getLoopNodes()}findLoopEnd(e){var r,i,l;return(l=(i=e.element)===null||i===void 0||(r=i.noMoreValuesConnector)===null||r===void 0?void 0:r.targetReference)!==null&&l!==void 0?l:e.name}findStatementsInLoops(e,r){let i=[],l=this.getStatementTypes();for(let a of r){let d=e.graph.getLoopElements(a.name);for(let v of d){let y=e.graph.getNode(v);y&&l.includes(y.subtype)&&i.push(y)}}return i}constructor(e,r){super(e,r)}}});var Kn=P(or=>{"use strict";Object.defineProperty(or,"__esModule",{value:!0});Object.defineProperty(or,"ActionCallsInLoop",{enumerable:!0,get:function(){return Cl}});var xl=S(),Pl=Ye(),Cl=class extends Pl.LoopRuleCommon{getStatementTypes(){return["actionCalls","apexPluginCalls"]}constructor(){super({ruleId:"action-call-in-loop",category:"suggestion",description:"Repeatedly invoking Apex actions inside a loop can exhaust governor limits and lead to performance issues. Where possible, bulkify your logic by moving the action call outside the loop and passing a collection variable instead.",summary:"Action calls inside loop risk governor limits",docRefs:[{label:"Action Call In A Loop",path:"https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm"}],label:"Action Call In A Loop",name:"ActionCallsInLoop",supportedTypes:xl.FlowType.backEndTypes},{severity:"warning"})}}});var ti=P(sr=>{"use strict";Object.defineProperty(sr,"__esModule",{value:!0});Object.defineProperty(sr,"APIVersion",{enumerable:!0,get:function(){return Tl}});var te=Nl(S()),Rl=D();function ei(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ei=function(i){return i?r:e})(t)}function Nl(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=ei(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Tl=class extends Rl.RuleCommon{check(e,r,i){let l=null;if(e.xmldata.apiVersion&&(l=+e.xmldata.apiVersion),r?.expression){if(!l)return[new te.Violation(new te.FlowAttribute("apiVersion<50","apiVersion","<50"))];let a=r.expression.match(/^\s*(>=|<=|>|<|===|!==)\s*(\d+)\s*$/);if(!a)return[new te.Violation(new te.FlowAttribute("Invalid API rule expression","apiVersion",r.expression))];let[,d,v]=a,y=parseFloat(v),_=!0;switch(d){case">":_=l>y;break;case"<":_=l=":_=l>=y;break;case"<=":_=l<=y;break;case"===":_=l===y;break;case"!==":_=l!==y;break}if(!_)return[new te.Violation(new te.FlowAttribute(`${l}`,"apiVersion",r.expression))]}else if(!l||l<50)return[new te.Violation(new te.FlowAttribute(l?`${l}`:"apiVersion<50","apiVersion","<50"))];return[]}constructor(){super({ruleId:"invalid-api-version",category:"suggestion",name:"APIVersion",label:"Invalid API Version",description:"Flows running on outdated API versions may behave inconsistently when newer platform features or components are used. From API version 50.0 onward, the API Version attribute explicitly controls Flow runtime behavior. Keeping Flows aligned with a supported API version helps prevent compatibility issues and ensures predictable execution.",summary:"Outdated API versions risk compatibility issues",supportedTypes:te.FlowType.allTypes(),docRefs:[],configurableOptions:[{name:"expression",type:"expression",description:"Comparison expression for API version (e.g., `>= 58`, `< 50`, `=== 60`)",defaultValue:">= 50"}],isFixable:!0})}}});var ni=P(lr=>{"use strict";Object.defineProperty(lr,"__esModule",{value:!0});Object.defineProperty(lr,"AutoLayout",{enumerable:!0,get:function(){return Sl}});var ar=Al(S()),El=D();function ri(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ri=function(i){return i?r:e})(t)}function Al(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=ri(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Sl=class extends El.RuleCommon{check(e,r){var i;if(!e.processMetadataValues)return[];let l=e.xmldata.processMetadataValues.find(v=>v.name==="CanvasMode");if(l?.value&&typeof l.value=="object"&&l.value.stringValue==="AUTO_LAYOUT_CANVAS")return[];var d;return[new ar.Violation(new ar.FlowAttribute((d=l==null||(i=l.value)===null||i===void 0?void 0:i.stringValue)!==null&&d!==void 0?d:"undefined","CanvasMode","!== AUTO_LAYOUT_CANVAS"))]}constructor(){super({ruleId:"missing-auto-layout",category:"layout",name:"AutoLayout",label:"Missing Auto Layout",description:"Auto-Layout automatically arranges and aligns Flow elements, keeping the canvas organized and easier to maintain. Enabling it saves time and improves readability.",summary:"Auto-Layout improves canvas organization and readability",supportedTypes:ar.FlowType.allTypes(),docRefs:[],isFixable:!0},{severity:"note"})}}});var oi=P(cr=>{"use strict";Object.defineProperty(cr,"__esModule",{value:!0});Object.defineProperty(cr,"CognitiveComplexity",{enumerable:!0,get:function(){return Dl}});var Qe=Ml(S()),Fl=D();function Il(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ii(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ii=function(i){return i?r:e})(t)}function Ml(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=ii(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Dl=class extends Fl.RuleCommon{check(e,r){var i;let l=(i=r?.threshold)!==null&&i!==void 0?i:this.defaultThreshold,a=this.calculateCognitiveComplexity(e);return a>l?[new Qe.Violation(new Qe.FlowAttribute(`${a}`,"CognitiveComplexity",`>${l}`))]:[]}calculateCognitiveComplexity(e){let r=0,i=e.graph,l=e.elements.filter(x=>x.subtype==="loops"),a=e.elements.filter(x=>x.subtype==="decisions"),d=new Map;for(let x of e.elements){if(!(x instanceof Qe.FlowNode))continue;let C=0;if(i.isInLoop(x.name)){C++;let A=i.getContainingLoop(x.name);A&&A!==x.name&&(C+=this.countParentLoops(A,i,l))}d.set(x.name,C)}for(let x of l){var v;let C=(v=d.get(x.name))!==null&&v!==void 0?v:0;r+=1+C}for(let x of a){var y,_;let C=(_=d.get(x.name))!==null&&_!==void 0?_:0;var b;let A=(b=(y=x.rules)===null||y===void 0?void 0:y.length)!==null&&b!==void 0?b:0;r+=1+C,A>1&&(r+=A-1)}return r}countParentLoops(e,r,i){let l=0;for(let a of i){if(a.name===e)continue;r.getLoopElements(a.name).has(e)&&l++}return l}constructor(){super({ruleId:"cognitive-complexity",category:"suggestion",name:"CognitiveComplexity",label:"Cognitive Complexity",description:"Flows with deeply nested loops and decisions are hard to understand. Unlike cyclomatic complexity which counts paths, cognitive complexity penalizes nesting depth. Consider extracting nested logic into subflows.",summary:"Deeply nested logic harms readability",supportedTypes:Qe.FlowType.backEndTypes,docRefs:[{label:"Cognitive Complexity is a measure of how difficult code is to understand, as opposed to Cyclomatic Complexity which measures testability.",path:"https://www.sonarsource.com/docs/CognitiveComplexity.pdf"}],configurableOptions:[{name:"threshold",type:"number",description:"Maximum cognitive complexity score before triggering a violation",defaultValue:15}]},{severity:"note"}),Il(this,"defaultThreshold",15)}}});var ai=P(dr=>{"use strict";Object.defineProperty(dr,"__esModule",{value:!0});Object.defineProperty(dr,"CopyAPIName",{enumerable:!0,get:function(){return ql}});var ur=Vl(S()),Ll=D();function si(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(si=function(i){return i?r:e})(t)}function Vl(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=si(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var ql=class extends Ll.RuleCommon{check(e){return e.elements.filter(l=>l instanceof ur.FlowNode).filter(l=>/Copy_[0-9]+_of_[A-Za-z0-9]+/.test(l.name)).map(l=>new ur.Violation(l))}constructor(){super({ruleId:"unclear-api-naming",category:"layout",name:"CopyAPIName",label:"Unclear API Name",description:"Elements with unclear or duplicated API names, like Copy_X_Of_Element, reduce Flow readability. Make sure to update the API name when copying elements to keep your Flow organized.",summary:"Duplicated API names reduce Flow readability",supportedTypes:ur.FlowType.allTypes(),docRefs:[]})}}});var ui=P(fr=>{"use strict";Object.defineProperty(fr,"__esModule",{value:!0});Object.defineProperty(fr,"CyclomaticComplexity",{enumerable:!0,get:function(){return kl}});var pr=Ul(S()),$l=D();function li(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ci(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ci=function(i){return i?r:e})(t)}function Ul(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=ci(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var kl=class extends $l.RuleCommon{check(e,r){var i,l,a;let d=(a=r?.threshold)!==null&&a!==void 0?a:this.defaultThreshold,v=1,y=e==null||(i=e.elements)===null||i===void 0?void 0:i.filter(x=>x.subtype==="decisions"),_=e==null||(l=e.elements)===null||l===void 0?void 0:l.filter(x=>x.subtype==="loops");for(let x of y||[]){let C=x.element.rules;v+=Array.isArray(C)?C.length+1:1}var b;return v+=(b=_?.length)!==null&&b!==void 0?b:0,this.cyclomaticComplexityUnit=v,v>d?[new pr.Violation(new pr.FlowAttribute(`${v}`,"CyclomaticComplexity",`>${d}`))]:[]}constructor(){super({ruleId:"excessive-cyclomatic-complexity",category:"suggestion",name:"CyclomaticComplexity",label:"Excessive Cyclomatic Complexity",description:"High numbers of loops and decision elements increase a Flow's cyclomatic complexity. To maintain simplicity and readability, consider using subflows or splitting a Flow into smaller, ordered Flows.",summary:"Too many loops and decisions harm readability",supportedTypes:pr.FlowType.backEndTypes,docRefs:[{label:"Cyclomatic complexity is a software metric used to indicate the complexity of a program. It is a quantitative measure of the number of linearly independent paths through a program's source code.",path:"https://en.wikipedia.org/wiki/Cyclomatic_complexity"}],configurableOptions:[{name:"threshold",type:"number",description:"Maximum cyclomatic complexity score before triggering a violation",defaultValue:25}]},{severity:"note"}),li(this,"defaultThreshold",25),li(this,"cyclomaticComplexityUnit",0)}}});var di=P(hr=>{"use strict";Object.defineProperty(hr,"__esModule",{value:!0});Object.defineProperty(hr,"DMLStatementInLoop",{enumerable:!0,get:function(){return Hl}});var Wl=S(),Bl=Ye(),Hl=class extends Bl.LoopRuleCommon{getStatementTypes(){return["recordDeletes","recordUpdates","recordCreates"]}constructor(){super({ruleId:"dml-in-loop",category:"problem",description:"Executing DML operations (insert, update, delete) inside a loop is a high-risk anti-pattern that frequently causes governor limit exceptions. All database operations should be collected and executed once, outside the loop.",summary:"DML operations inside loop risk governor limits",docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"}],label:"DML Statement In A Loop",name:"DMLStatementInLoop",supportedTypes:Wl.FlowType.backEndTypes},{severity:"error"})}}});var hi=P(mr=>{"use strict";Object.defineProperty(mr,"__esModule",{value:!0});Object.defineProperty(mr,"DuplicateDMLOperation",{enumerable:!0,get:function(){return zl}});var pi=jl(S()),Gl=D();function fi(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(fi=function(i){return i?r:e})(t)}function jl(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=fi(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var zl=class extends Gl.RuleCommon{check(e,r,i){let l=e.graph,a=e.startReference;if(!a)return[];let d=[],v=new Set,y=[{name:a,seenDML:!1}];for(;y.length>0;){let{name:_,seenDML:b}=y.pop(),x=`${_}:${b}`;if(v.has(x))continue;v.add(x);let C=l.getNode(_);if(!C)continue;let A=b||this.isDML(C);A&&C.subtype==="screens"&&C.element.allowBack==="true"&&C.element.showFooter==="true"&&!i.has(C.name)&&d.push(new pi.Violation(C)),A&&C.subtype==="screens"&&C.element.allowBack!=="true"&&(A=!1);for(let k of l.getNextElements(_))y.push({name:k,seenDML:A})}return d}isDML(e){return e.subtype==="recordCreates"||e.subtype==="recordUpdates"||e.subtype==="recordDeletes"}constructor(){super({ruleId:"duplicate-dml",category:"problem",name:"DuplicateDMLOperation",label:"Duplicate DML Operation",description:"When a Flow performs database operations across multiple screens, users navigating backward can cause the same actions to run multiple times. To prevent unintended changes, either restrict backward navigation or redesign the Flow so database operations execute in a single, forward-moving step.",summary:"DML across screens may execute multiple times",supportedTypes:pi.FlowType.visualTypes,docRefs:[]})}}});var gi=P(gr=>{"use strict";Object.defineProperty(gr,"__esModule",{value:!0});Object.defineProperty(gr,"FlowDescription",{enumerable:!0,get:function(){return Yl}});var Je=Zl(S()),Xl=D();function mi(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(mi=function(i){return i?r:e})(t)}function Zl(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=mi(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Yl=class extends Xl.RuleCommon{check(e,r,i){var l;return!((l=e.xmldata)===null||l===void 0)&&l.description?[]:[new Je.Violation(new Je.FlowAttribute("undefined","description","!==null"))]}constructor(){super({ruleId:"missing-flow-description",category:"layout",description:"Flow descriptions are essential for documentation and maintainability. Include a description for each Flow, explaining its purpose and where it's used.",summary:"Flow descriptions improve documentation and maintainability",docRefs:[],label:"Missing Flow Description",name:"FlowDescription",supportedTypes:[...Je.FlowType.backEndTypes,...Je.FlowType.visualTypes]},{severity:"error"})}}});var vi=P(yi=>{"use strict";Object.defineProperty(yi,"__esModule",{value:!0})});var bi=P(wi=>{"use strict";Object.defineProperty(wi,"__esModule",{value:!0})});var Ce=P(yr=>{"use strict";Object.defineProperty(yr,"__esModule",{value:!0});Object.defineProperty(yr,"RegexRule",{enumerable:!0,get:function(){return Kl}});function J(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _i(t){for(var e=1;e{var v,y;return Jl(_i({},d),{severity:l,message:(v=r?.message)!==null&&v!==void 0?v:d.message,messageUrl:(y=r?.messageUrl)!==null&&y!==void 0?y:d.messageUrl})})}createViolation(e,r){var i,l;return _i({file:(l=(i=e.filePath)===null||i===void 0?void 0:i.replace(/\\/g,"/"))!==null&&l!==void 0?l:e.fileName,fileName:e.fileName,metadataType:e.metadataType,ruleId:this.ruleId,ruleName:this.name,severity:this.severity,message:this.description,lineNumber:1,columnNumber:1,name:e.name,type:"name",metaType:"attribute"},r)}constructor(e){J(this,"ruleId",void 0),J(this,"name",void 0),J(this,"label",void 0),J(this,"description",void 0),J(this,"summary",void 0),J(this,"supportedTypes",void 0),J(this,"docRefs",void 0),J(this,"isConfigurable",void 0),J(this,"severity",void 0),this.ruleId=e.ruleId,this.name=e.name,this.label=e.label,this.description=e.description,this.summary=e.summary,this.severity=e.severity,this.supportedTypes=e.supportedTypes;var r;this.docRefs=(r=e.docRefs)!==null&&r!==void 0?r:[],this.isConfigurable=e.isConfigurable}}});var Pi=P(vr=>{"use strict";Object.defineProperty(vr,"__esModule",{value:!0});Object.defineProperty(vr,"NamingConvention",{enumerable:!0,get:function(){return Oi}});var ec=Ce();function tc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Oi=class xi extends ec.RegexRule{check(e,r){var i;let l=(i=r?.expression)!==null&&i!==void 0?i:xi.DEFAULT_PATTERN;var a;let d=(a=e.name)!==null&&a!==void 0?a:"";return new RegExp(l).test(d)?[]:[this.createViolation(e,{name:d,type:"name",metaType:"attribute",expression:l,message:this.description})]}constructor(){super({ruleId:"naming-convention",name:"NamingConvention",label:"Naming Convention",description:"Using clear and consistent names improves readability, discoverability, and maintainability. A good naming convention helps team members quickly understand a file's purpose\u2014for example, including a domain and brief description like Service_OrderFulfillment.",summary:"Consistent naming improves discoverability and maintainability",severity:"error",supportedTypes:["*"],docRefs:[{label:"Naming your Flows is more critical than ever",path:"https://www.linkedin.com/posts/stephen-n-church_naming-your-flows-this-is-more-critical-activity-7099733198175158274-1sPx"}],isConfigurable:!0})}};tc(Oi,"DEFAULT_PATTERN","[A-Za-z0-9]+_[A-Za-z0-9]+")});var br=P(wr=>{"use strict";Object.defineProperty(wr,"__esModule",{value:!0});Object.defineProperty(wr,"stripDescriptionContent",{enumerable:!0,get:function(){return rc}});function rc(t){let e=t.replace(/[\s\S]*?<\/description>/gi,"");return e=e.replace(/"description"\s*:\s*"(?:[^"\\]|\\.)*"/g,""),e}});var Ni=P(Or=>{"use strict";Object.defineProperty(Or,"__esModule",{value:!0});Object.defineProperty(Or,"HardcodedId",{enumerable:!0,get:function(){return Ri}});var nc=Ce(),Ci=br();function ic(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ri=class _r extends nc.RegexRule{check(e,r){let i=[];if(e.elements&&e.elements.length>0)for(let l of e.elements){let a=typeof l.content=="string"?l.content:JSON.stringify(l.content),d=(0,Ci.stripDescriptionContent)(a),v=new RegExp(_r.SALESFORCE_ID_PATTERN),y=d.match(v);y&&i.push(this.createViolation(e,{name:l.name,type:l.type,metaType:"element",matchedText:y[0],message:this.description}))}else{let l=(0,Ci.stripDescriptionContent)(e.content),a=new RegExp(_r.SALESFORCE_ID_PATTERN),d=l.match(a);if(d)for(let v of d)i.push(this.createViolation(e,{name:e.name,type:"content",metaType:"content",matchedText:v,message:this.description}))}return i}constructor(){super({ruleId:"hardcoded-id",name:"HardcodedId",label:"Hardcoded Salesforce Id",description:"Avoid hard-coding record IDs, as they are unique to a specific org and will not work in other environments. Instead, store IDs in variables\u2014such as merge-field URL parameters or a Get Records element\u2014to make the Flow portable, maintainable, and flexible.",summary:"Hardcoded IDs break portability across environments",severity:"error",supportedTypes:["*"],docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"},{label:"Don't hard code Record Type IDs in Flow",path:"https://www.linkedin.com/feed/update/urn:li:activity:6947530300012826624/"}],isConfigurable:!1})}};ic(Ri,"SALESFORCE_ID_PATTERN",/\b[a-zA-Z0-9]{5}0[a-zA-Z0-9]{9}(?:[a-zA-Z0-9]{3})?\b/g)});var Ai=P(Pr=>{"use strict";Object.defineProperty(Pr,"__esModule",{value:!0});Object.defineProperty(Pr,"HardcodedUrl",{enumerable:!0,get:function(){return Ei}});var oc=Ce(),Ti=br();function sc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ei=class xr extends oc.RegexRule{check(e,r){let i=[];if(e.elements&&e.elements.length>0)for(let l of e.elements){let a=typeof l.content=="string"?l.content:JSON.stringify(l.content),d=(0,Ti.stripDescriptionContent)(a),v=new RegExp(xr.FORCE_URL_PATTERN),y=d.match(v);y&&i.push(this.createViolation(e,{name:l.name,type:l.type,metaType:"element",matchedText:y[0],message:this.description}))}else{let l=(0,Ti.stripDescriptionContent)(e.content),a=new RegExp(xr.FORCE_URL_PATTERN),d=l.match(a);if(d)for(let v of d)i.push(this.createViolation(e,{name:e.name,type:"content",metaType:"content",matchedText:v,message:this.description}))}return i}constructor(){super({ruleId:"hardcoded-url",name:"HardcodedUrl",label:"Hardcoded Salesforce Url",description:"Avoid hard-coding URLs, as they may change between environments or over time. Instead, store URLs in variables or custom settings to make the Flow adaptable, maintainable, and environment-independent.",summary:"Hardcoded URLs break across different environments",severity:"error",supportedTypes:["*"],docRefs:[{label:"The Ultimate Guide to Salesforce Flow Best Practices",path:"https://admin.salesforce.com/blog/2021/the-ultimate-guide-to-flow-best-practices-and-standards"},{label:"Why You Should Avoid Hard Coding and Three Alternative Solutions",path:"https://admin.salesforce.com/blog/2021/why-you-should-avoid-hard-coding-and-three-alternative-solutions"}],isConfigurable:!1})}};sc(Ei,"FORCE_URL_PATTERN",/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}force\.com/g)});var Ii=P(Cr=>{"use strict";Object.defineProperty(Cr,"__esModule",{value:!0});Object.defineProperty(Cr,"HardcodedSecret",{enumerable:!0,get:function(){return Si}});var ac=Ce();function lc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Si=class Fi extends ac.RegexRule{check(e,r){let i=[];if(e.elements&&e.elements.length>0)for(let l of e.elements){let a=typeof l.content=="string"?l.content:JSON.stringify(l.content),d=this.findSecrets(a);for(let v of d)i.push(this.createViolation(e,{name:l.name,type:l.type,metaType:"element",matchedText:this.maskSecret(v.matchedText),message:v.description}))}else{let l=this.findSecrets(e.content);for(let a of l)i.push(this.createViolation(e,{name:e.name,type:"content",metaType:"content",matchedText:this.maskSecret(a.matchedText),message:a.description}))}return i}findSecrets(e){let r=[],i=new Set;for(let l of Fi.SECRET_PATTERNS){let a=new RegExp(l.pattern.source,l.pattern.flags),d=e.match(a);if(d)for(let v of d)i.has(v)||(i.add(v),r.push({matchedText:v,description:l.description}))}return r}maskSecret(e){return e.length<=12?e.substring(0,4)+"****":e.substring(0,4)+"****"+e.substring(e.length-4)}constructor(){super({ruleId:"hardcoded-secret",name:"HardcodedSecret",label:"Hardcoded Secret",description:"Avoid hardcoding secrets, API keys, tokens, or credentials in metadata files. These should be stored securely in Named Credentials, Custom Settings, Custom Metadata, or external secret management systems.",summary:"Hardcoded secrets pose security risks",severity:"error",supportedTypes:["*"],docRefs:[{label:"Salesforce Named Credentials",path:"https://help.salesforce.com/s/articleView?id=sf.named_credentials_about.htm"},{label:"OWASP Secrets Management",path:"https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html"}],isConfigurable:!1})}};lc(Si,"SECRET_PATTERNS",[{name:"Azure Storage Account Key",pattern:/AccountKey=[A-Za-z0-9+/]{88}==/g,description:"Azure Storage account key detected"},{name:"Azure Connection String",pattern:/DefaultEndpointsProtocol=https;AccountName=[^;]+;AccountKey=[^;]+/g,description:"Azure connection string detected"},{name:"GCP Service Account Key",pattern:/"type"\s*:\s*"service_account"[\s\S]{0,500}"private_key"/g,description:"GCP service account JSON key detected"},{name:"Stripe API Key",pattern:/(sk|pk|rk)_(test|live)_[0-9a-zA-Z]{24,}/g,description:"Stripe API key detected"},{name:"AWS Access Key ID",pattern:/\bAKIA[0-9A-Z]{16}\b/g,description:"AWS access key ID detected"},{name:"AWS Secret Access Key",pattern:/aws[_-]?secret[_-]?access[_-]?key\s*[:=]\s*["'][A-Za-z0-9/+=]{40}["']/gi,description:"AWS secret access key detected"},{name:"Salesforce Session ID",pattern:/\b00D[a-zA-Z0-9]{15}![a-zA-Z0-9.]{80,}/g,description:"Salesforce session ID detected"},{name:"Salesforce Refresh Token",pattern:/\b5Aep[a-zA-Z0-9._]{80,}/g,description:"Salesforce refresh token detected"},{name:"Hardcoded OAuth Token",pattern:/(authorization|auth)\s*[:=]\s*["']Bearer\s+[A-Za-z0-9\-_\.]{20,}["']/gi,description:"Hardcoded OAuth bearer token detected"},{name:"Bearer Token",pattern:/Bearer\s+[a-zA-Z0-9_\-.]{20,}/gi,description:"Bearer token detected"},{name:"Basic Auth",pattern:/Basic\s+[a-zA-Z0-9+/=]{20,}/gi,description:"Basic authentication credentials detected"},{name:"Private Key",pattern:/-----BEGIN\s+(RSA\s+)?PRIVATE\s+KEY-----/g,description:"Private key detected"},{name:"Certificate",pattern:/-----BEGIN\s+CERTIFICATE-----/g,description:"Certificate detected"},{name:"JWT Secret",pattern:/jwt[_-]?secret\s*[:=]\s*["'][^"']{8,}["']/gi,description:"Hardcoded JWT secret detected"},{name:"GitHub Token",pattern:/gh[puo]_[A-Za-z0-9_]{36,}/g,description:"GitHub token detected"},{name:"Slack Token",pattern:/xox[baprs]-[a-zA-Z0-9-]{10,}/g,description:"Slack token detected"},{name:"Slack Webhook",pattern:/hooks\.slack\.com\/services\/[A-Z0-9]{9,}\/[A-Z0-9]{9,}\/[A-Za-z0-9]{20,}/g,description:"Slack webhook URL detected"},{name:"Google API Key",pattern:/AIza[0-9A-Za-z_-]{35}/g,description:"Google API key detected"},{name:"Twilio API Key",pattern:/SK[a-fA-F0-9]{32}/g,description:"Twilio API key detected"},{name:"SendGrid API Key",pattern:/SG\.[a-zA-Z0-9_-]{22}\.[a-zA-Z0-9_-]{43}/g,description:"SendGrid API key detected"},{name:"Mailchimp API Key",pattern:/[a-f0-9]{32}-us[0-9]{1,2}/g,description:"Mailchimp API key detected"},{name:"Password Assignment",pattern:/(password|passwd|pwd|secret)\s*[:=]\s*["'][^"'\s]{8,}["']/gi,description:"Hardcoded password or secret assignment detected"},{name:"OpenAI API Key",pattern:/sk-[A-Za-z0-9]{48,}/g,description:"OpenAI API key detected"},{name:"Anthropic API Key",pattern:/sk-ant-[A-Za-z0-9_-]{20,}/g,description:"Anthropic API key detected"}])});var Nr=P(Rr=>{"use strict";Object.defineProperty(Rr,"__esModule",{value:!0});Object.defineProperty(Rr,"regexRuleRegistry",{enumerable:!0,get:function(){return dc}});function Mi(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var cc=class{register(e,r,i){let l={ruleId:e,ruleClass:r,legacyName:i};this.rules.set(e,l),this.legacyNameMap.set(i,e)}get(e){let r=this.rules.get(e);if(!r){let i=this.legacyNameMap.get(e);i&&(r=this.rules.get(i))}return r}getAllRuleIds(){return Array.from(this.rules.keys())}has(e){return this.get(e)!==void 0}createInstance(e){let r=this.get(e);if(!r)throw new Error(`Regex rule not found: ${e}`);return new r.ruleClass}getRules(e){let r=[];for(let d of this.getAllRuleIds()){var i,l;let v=this.createInstance(d);var a;let y=(a=e==null||(i=e.rules)===null||i===void 0?void 0:i[v.ruleId])!==null&&a!==void 0?a:e==null||(l=e.rules)===null||l===void 0?void 0:l[v.name];y?.enabled!==!1&&(y?.severity&&(v.severity=y.severity),r.push(v))}return r}getRulesByIds(e){let r=[];for(let i of e)this.has(i)&&r.push(this.createInstance(i));return r}constructor(){Mi(this,"rules",new Map),Mi(this,"legacyNameMap",new Map)}},uc=new cc,dc=uc});var Li=P(Er=>{"use strict";Object.defineProperty(Er,"__esModule",{value:!0});function pc(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}pc(Er,{get getRegexRuleIds(){return hc},get hasRegexRule(){return mc},get scanFile(){return fc},get scanRegex(){return Di}});var Tr=Nr();function Di(t,e){let r=[],i=Tr.regexRuleRegistry.getRules(e);for(let v of t)for(let y of i){var l,a,d;let _=(d=e==null||(l=e.rules)===null||l===void 0?void 0:l[y.ruleId])!==null&&d!==void 0?d:e==null||(a=e.rules)===null||a===void 0?void 0:a[y.name],b=y.execute(v,_);r.push(...b)}return r}function fc(t,e){return Di([t],e)}function hc(){return Tr.regexRuleRegistry.getAllRuleIds()}function mc(t){return Tr.regexRuleRegistry.has(t)}});var Me=P(Sr=>{"use strict";Object.defineProperty(Sr,"__esModule",{value:!0});function gc(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}gc(Sr,{get HardcodedId(){return Ui.HardcodedId},get HardcodedSecret(){return Wi.HardcodedSecret},get HardcodedUrl(){return ki.HardcodedUrl},get MetadataElement(){return Vi.MetadataElement},get MetadataFile(){return Vi.MetadataFile},get NamingConvention(){return $i.NamingConvention},get RegexRule(){return qi.RegexRule},get RegexRuleConfig(){return Ar.RegexRuleConfig},get RegexRuleInfo(){return qi.RegexRuleInfo},get RegexScanConfig(){return Ar.RegexScanConfig},get RegexViolation(){return Ar.RegexViolation},get getRegexRuleIds(){return Ke.getRegexRuleIds},get hasRegexRule(){return Ke.hasRegexRule},get regexRuleRegistry(){return Ie.regexRuleRegistry},get scanFile(){return Ke.scanFile},get scanRegex(){return Ke.scanRegex}});var Vi=vi(),Ar=bi(),qi=Ce(),$i=Pi(),Ui=Ni(),ki=Ai(),Wi=Ii(),Ie=Nr(),Ke=Li();Ie.regexRuleRegistry.register("naming-convention",$i.NamingConvention,"NamingConvention");Ie.regexRuleRegistry.register("hardcoded-id",Ui.HardcodedId,"HardcodedId");Ie.regexRuleRegistry.register("hardcoded-url",ki.HardcodedUrl,"HardcodedUrl");Ie.regexRuleRegistry.register("hardcoded-secret",Wi.HardcodedSecret,"HardcodedSecret")});var De=P(Fr=>{"use strict";Object.defineProperty(Fr,"__esModule",{value:!0});function yc(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}yc(Fr,{get flowElementToMetadataElement(){return _c},get toMetadataElements(){return Bi},get toMetadataFile(){return bc},get toViolation(){return Hi},get toViolations(){return Oc}});var vc=Xe(),wc=Fe();function bc(t){let e="";typeof t.toXMLString=="function"&&(e=t.toXMLString());var r;return{name:t.name,fileName:t.uri?(r=t.uri.split(/[\\/]/).pop())!==null&&r!==void 0?r:`${t.name}.flow-meta.xml`:`${t.name}.flow-meta.xml`,filePath:t.fsPath,metadataType:"Flow",content:e,elements:Bi(t)}}function Bi(t){return!t.elements||t.elements.length===0?[]:t.elements.map(e=>{var r;return{name:e.name,type:e.subtype,content:(r=e.element)!==null&&r!==void 0?r:e}})}function Hi(t){var e;let r=new vc.FlowAttribute(t.name,t.type,(e=t.expression)!==null&&e!==void 0?e:t.matchedText),i=new wc.Violation(r);return i.lineNumber=t.lineNumber,i.columnNumber=t.columnNumber,i}function _c(t){var e;return{name:t.name,type:t.subtype,content:(e=t.element)!==null&&e!==void 0?e:t}}function Oc(t){return t.map(Hi)}});var zi=P(Ir=>{"use strict";Object.defineProperty(Ir,"__esModule",{value:!0});Object.defineProperty(Ir,"FlowName",{enumerable:!0,get:function(){return Tc}});var xc=Nc(S()),Pc=D(),Cc=Me(),Gi=De();function Rc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ji(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ji=function(i){return i?r:e})(t)}function Nc(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=ji(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Tc=class extends Pc.RuleCommon{check(e,r,i){let l=(0,Gi.toMetadataFile)(e),a=this.regexRule.execute(l,{expression:r?.expression});return(0,Gi.toViolations)(a)}constructor(){super({ruleId:"invalid-naming-convention",category:"layout",description:"Using clear and consistent Flow names improves readability, discoverability, and maintainability. A good naming convention helps team members quickly understand a Flow's purpose\u2014for example, including a domain and brief description like Service_OrderFulfillment. Adopt a naming pattern that aligns with your organization's standards.",summary:"Consistent naming improves Flow discoverability and maintainability",docRefs:[{label:"Naming your Flows is more critical than ever. By Stephen Church",path:"https://www.linkedin.com/posts/stephen-n-church_naming-your-flows-this-is-more-critical-activity-7099733198175158274-1sPx"}],label:"Flow Naming Convention",name:"FlowName",supportedTypes:xc.FlowType.allTypes(),configurableOptions:[{name:"expression",type:"expression",description:"Regex pattern for valid Flow names",defaultValue:"[A-Za-z0-9]+_[A-Za-z0-9]+"}]},{severity:"error"}),Rc(this,"regexRule",new Cc.NamingConvention)}}});var Yi=P(Mr=>{"use strict";Object.defineProperty(Mr,"__esModule",{value:!0});Object.defineProperty(Mr,"GetRecordAllFields",{enumerable:!0,get:function(){return Sc}});var Xi=Ac(S()),Ec=D();function Zi(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Zi=function(i){return i?r:e})(t)}function Ac(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Zi(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Sc=class extends Ec.RuleCommon{check(e,r,i){var l,a;return((a=(l=e.elements)===null||l===void 0?void 0:l.filter(y=>y.subtype==="recordLookups"))!==null&&a!==void 0?a:[]).filter(y=>{let _=y.element,b=typeof _=="object"&&"storeOutputAutomatically"in _&&_.storeOutputAutomatically,x=_.queriedFields,C=x&&(Array.isArray(x)&&x.length>0||typeof x=="string");return b&&!C}).map(y=>new Xi.Violation(y))}constructor(){super({ruleId:"get-record-all-fields",category:"suggestion",description:"Avoid using Get Records to retrieve all fields unless necessary. This improves performance, reduces processing time, and limits exposure of unnecessary data.",summary:"Retrieving all fields harms performance and security",docRefs:[{label:"Get Records Stores All Fields",path:"https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/ldv_deployments_best_practices_soql_and_sosl.htm"},{label:"Indexes | Best Practices",path:"https://developer.salesforce.com/docs/atlas.en-us.salesforce_large_data_volumes_bp.meta/salesforce_large_data_volumes_bp/ldv_deployments_infrastructure_indexes.htm"}],label:"Get Record All Fields",name:"GetRecordAllFields",supportedTypes:Xi.FlowType.allTypes()},{severity:"warning"})}}});var Ki=P(Dr=>{"use strict";Object.defineProperty(Dr,"__esModule",{value:!0});Object.defineProperty(Dr,"HardcodedId",{enumerable:!0,get:function(){return Vc}});var Fc=Lc(S()),Ic=D(),Mc=Me(),Qi=De();function Dc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ji(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Ji=function(i){return i?r:e})(t)}function Lc(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Ji(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Vc=class extends Ic.RuleCommon{check(e,r,i){let l=(0,Qi.toMetadataFile)(e),a=this.regexRule.execute(l);return(0,Qi.toViolations)(a)}constructor(){super({ruleId:"hardcoded-id",name:"HardcodedId",category:"problem",label:"Hardcoded Id",description:"Avoid hard-coding record IDs, as they are unique to a specific org and will not work in other environments. Instead, store IDs in variables\u2014such as merge-field URL parameters or a **Get Records** element\u2014to make the Flow portable, maintainable, and flexible.",summary:"Hardcoded IDs break portability across environments",supportedTypes:Fc.FlowType.allTypes(),docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"},{label:"Don't hard code Record Type IDs in Flow. By Stephen Church.",path:"https://www.linkedin.com/feed/update/urn:li:activity:6947530300012826624/"}]},{severity:"error"}),Dc(this,"regexRule",new Mc.HardcodedId)}}});var to=P(Lr=>{"use strict";Object.defineProperty(Lr,"__esModule",{value:!0});Object.defineProperty(Lr,"HardcodedUrl",{enumerable:!0,get:function(){return Wc}});var qc=S(),$c=D(),Uc=Me(),eo=De();function kc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Wc=class extends $c.RuleCommon{check(e,r,i){let l=(0,eo.toMetadataFile)(e),a=this.regexRule.execute(l);return(0,eo.toViolations)(a)}constructor(){super({ruleId:"hardcoded-url",category:"problem",description:"Avoid hard-coding URLs, as they may change between environments or over time. Instead, store URLs in variables or custom settings to make the Flow adaptable, maintainable, and environment-independent.",summary:"Hardcoded URLs break across different environments",docRefs:[{label:"The Ultimate Guide to Salesforce Flow Best Practices",path:"https://admin.salesforce.com/blog/2021/the-ultimate-guide-to-flow-best-practices-and-standards"},{label:"Why You Should Avoid Hard Coding and Three Alternative Solutions",path:"https://admin.salesforce.com/blog/2021/why-you-should-avoid-hard-coding-and-three-alternative-solutions"}],label:"Hardcoded Url",name:"HardcodedUrl",supportedTypes:qc.FlowType.allTypes()},{severity:"error"}),kc(this,"regexRule",new Uc.HardcodedUrl)}}});var io=P(Vr=>{"use strict";Object.defineProperty(Vr,"__esModule",{value:!0});Object.defineProperty(Vr,"HardcodedSecret",{enumerable:!0,get:function(){return Xc}});var Bc=zc(S()),Hc=D(),Gc=Me(),ro=De();function jc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function no(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(no=function(i){return i?r:e})(t)}function zc(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=no(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Xc=class extends Hc.RuleCommon{check(e,r,i){let l=(0,ro.toMetadataFile)(e),a=this.regexRule.execute(l);return(0,ro.toViolations)(a)}constructor(){super({ruleId:"hardcoded-secret",name:"HardcodedSecret",category:"problem",label:"Hardcoded Secret",description:"Avoid hardcoding secrets, API keys, tokens, or credentials in Flows. These should be stored securely in Named Credentials, Custom Settings, Custom Metadata, or external secret management systems.",summary:"Hardcoded secrets pose security risks",supportedTypes:Bc.FlowType.allTypes(),docRefs:[{label:"Salesforce Named Credentials",path:"https://help.salesforce.com/s/articleView?id=sf.named_credentials_about.htm"},{label:"OWASP Secrets Management Cheat Sheet",path:"https://cheatsheetseries.owasp.org/cheatsheets/Secrets_Management_Cheat_Sheet.html"}]},{severity:"error"}),jc(this,"regexRule",new Gc.HardcodedSecret)}}});var so=P($r=>{"use strict";Object.defineProperty($r,"__esModule",{value:!0});Object.defineProperty($r,"InactiveFlow",{enumerable:!0,get:function(){return Qc}});var qr=Yc(S()),Zc=D();function oo(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(oo=function(i){return i?r:e})(t)}function Yc(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=oo(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Qc=class extends Zc.RuleCommon{check(e,r,i){return e.status!=="Active"?[new qr.Violation(new qr.FlowAttribute(e.status,"status","!= Active"))]:[]}constructor(){super({ruleId:"inactive-flow",category:"suggestion",name:"InactiveFlow",label:"Inactive Flow",description:"Inactive Flows should be deleted or archived to reduce risk. Even when inactive, they can cause unintended record changes during testing or be activated as subflows. Keeping only active, relevant Flows improves safety and maintainability.",summary:"Inactive Flows should be deleted or archived",supportedTypes:qr.FlowType.allTypes(),docRefs:[]})}}});var lo=P(kr=>{"use strict";Object.defineProperty(kr,"__esModule",{value:!0});Object.defineProperty(kr,"MissingFaultPath",{enumerable:!0,get:function(){return tu}});var Ur=eu(S()),Jc=D();function Kc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ao(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ao=function(i){return i?r:e})(t)}function eu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=ao(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var tu=class extends Jc.RuleCommon{isValidSubtype(e){if(!this.applicableElements.includes(e.subtype))return!1;if(e.subtype==="waits"){var r;let i=(r=e.element)===null||r===void 0?void 0:r.elementSubtype;return!["WaitDuration","WaitDate"].includes(i)}return!0}check(e,r,i){var l;let a=[],d=e.elements.filter(_=>{let b=_;return this.isValidSubtype(b)}).map(_=>_.name),v=this.isRecordBeforeSaveFlow(e),y=_=>{var b;if(!(!(_==null||(b=_.connectors)===null||b===void 0)&&b.find(x=>x.type==="faultConnector"))&&d.includes(_.name)){if(v&&_.subtype==="recordUpdates")return;this.isPartOfFaultHandlingFlow(_,e)||i.has(_.name)||a.push(new Ur.Violation(_))}};return(l=e.graph)===null||l===void 0||l.forEachReachable(y),a}isRecordBeforeSaveFlow(e){var r;if(!((r=e.startNode)===null||r===void 0)&&r.element){var i;if(((i=e.startNode.element)===null||i===void 0?void 0:i.triggerType)==="RecordBeforeSave")return!0}return!1}isPartOfFaultHandlingFlow(e,r){var i;return((i=r.graph)===null||i===void 0?void 0:i.isPartOfFaultHandling(e.name))||!1}constructor(){super({ruleId:"missing-fault-path",category:"problem",description:"Elements that can fail should include a Fault Path to handle errors gracefully. Without it, failures show generic errors to users. Fault Paths improve reliability and user experience.",summary:"Fault Paths enable graceful error handling",docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"}],label:"Missing Fault Path",name:"MissingFaultPath",supportedTypes:[...Ur.FlowType.backEndTypes,...Ur.FlowType.visualTypes]}),Kc(this,"applicableElements",["recordLookups","recordDeletes","recordUpdates","recordCreates","waits","actionCalls","apexPluginCalls"])}}});var uo=P(Br=>{"use strict";Object.defineProperty(Br,"__esModule",{value:!0});Object.defineProperty(Br,"MissingNullHandler",{enumerable:!0,get:function(){return iu}});var Wr=nu(S()),ru=D();function co(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(co=function(i){return i?r:e})(t)}function nu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=co(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var iu=class extends ru.RuleCommon{check(e,r,i){let l=["recordLookups"],a=e.elements.filter(b=>b.metaType==="node"&&l.includes(b.subtype)),d=e.elements.filter(b=>b.metaType==="node"&&b.subtype==="decisions"),v=[];for(let b of a){var y;if(i.has(b.name))continue;let x=b.name,C=String(b.element.assignNullValuesIfNoRecordsFound).toLowerCase()==="true",A=!!b.element.faultConnector||((y=b.connectors)===null||y===void 0?void 0:y.some(B=>B.type==="faultConnector"));if(!C&&A)continue;let k=[];if(b.element.storeOutputAutomatically)k.push(x);else if(b.element.outputReference)k.push(b.element.outputReference);else if(b.element.outputAssignments){let B=b.element.outputAssignments;for(let Q of B)k.push(Q.assignToReference)}if(!e.elements.some(B=>{if(B.name===b.name)return!1;let Q=JSON.stringify(B.element);return k.some(L=>Q.includes(`"${L}"`)||Q.includes(`"${L}.`))})||!C)continue;let re=!1;for(let B of d){let Q=B.element.rules;Array.isArray(Q)||(Q=[Q]);for(let L of Q){let ye=L.conditions;Array.isArray(ye)||(ye=[ye]);for(let ve of ye){var _;let W=!1,ne=!1,Re=!1;if(ve.leftValueReference){let it=ve.leftValueReference;k.some($e=>it.startsWith($e))&&(W=!0)}ve.operator==="IsNull"&&(ne=!0);let qe=(_=ve.rightValue)===null||_===void 0?void 0:_.booleanValue;if(qe!=null&&String(qe).toLowerCase()==="false"&&(Re=!0),W&&ne&&Re){re=!0;break}}if(re)break}if(re)break}re||v.push(b)}return v.map(b=>new Wr.Violation(b))}constructor(){super({ruleId:"missing-null-handler",category:"problem",description:"Get Records operations return null when no data is found. Without handling these null values, Flows can fail or produce unintended results. Adding a null check improves reliability and ensures the Flow behaves as expected.",summary:"Null checks prevent failures from missing records",docRefs:[],label:"Missing Null Handler",name:"MissingNullHandler",supportedTypes:[...Wr.FlowType.backEndTypes,...Wr.FlowType.visualTypes]})}}});var fo=P(Gr=>{"use strict";Object.defineProperty(Gr,"__esModule",{value:!0});Object.defineProperty(Gr,"ProcessBuilder",{enumerable:!0,get:function(){return au}});var Hr=su(S()),ou=D();function po(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(po=function(i){return i?r:e})(t)}function su(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=po(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var au=class extends ou.RuleCommon{check(e,r,i){return[new Hr.Violation(new Hr.FlowAttribute("Workflow","processType","== Workflow"))]}constructor(){super({ruleId:"process-builder-usage",category:"problem",name:"ProcessBuilder",label:"Process Builder",description:"Process Builder is retired. Continuing to use it increases maintenance overhead and risks future compatibility issues. Migrating automation to Flow reduces risk and improves maintainability.",summary:"Process Builder is retired, migrate to Flow",supportedTypes:Hr.FlowType.processBuilder,docRefs:[{label:"Process Builder Retirement",path:"https://help.salesforce.com/s/articleView?id=000389396&type=1"}]},{severity:"error"})}}});var mo=P(zr=>{"use strict";Object.defineProperty(zr,"__esModule",{value:!0});Object.defineProperty(zr,"RecursiveAfterUpdate",{enumerable:!0,get:function(){return du}});var jr=uu(S()),lu=D();function cu(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ho(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(ho=function(i){return i?r:e})(t)}function uu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=ho(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var du=class extends lu.RuleCommon{check(e,r,i){var l,a,d;let v=[],y=this.getStartProperty(e,"triggerType"),_=this.getStartProperty(e,"recordTriggerType"),b=y==="RecordAfterSave",x=this.qualifiedRecordTriggerTypes.has(_);if(!b||!x)return v;let C=(l=e.elements)===null||l===void 0?void 0:l.filter(F=>F.subtype==="recordUpdates");if(C==null||typeof C[Symbol.iterator]!="function")return v;for(let F of C)typeof F.element=="object"&&"inputReference"in F.element&&F.element.inputReference==="$Record"&&(i.has(F.name)||v.push(new jr.Violation(F)));let A=this.getStartProperty(e,"object"),k=(d=e.elements)===null||d===void 0||(a=d.filter(F=>F.subtype==="recordLookups"&&typeof F.element=="object"&&"object"in F.element&&A===F.element.object))===null||a===void 0?void 0:a.map(F=>F.name);if(k==null||typeof k[Symbol.iterator]!="function")return v;for(let F of C)typeof F.element=="object"&&"inputReference"in F.element&&k.includes(F.element.inputReference)&&(i.has(F.name)||v.push(new jr.Violation(F)));return v}constructor(){super({ruleId:"recursive-record-update",category:"problem",description:"After-save Flows that update the same record can trigger recursion, causing unintended behavior or performance issues. Avoid updating the triggering record in after-save Flows; use before-save Flows instead to prevent recursion.",summary:"After-save updates to same record trigger recursion",docRefs:[{label:"Learn about same record field updates",path:"https://architect.salesforce.com/decision-guides/trigger-automation#Same_Record_Field_Updates"}],label:"Recursive After Update",name:"RecursiveAfterUpdate",supportedTypes:[...jr.FlowType.backEndTypes]},{severity:"warning"}),cu(this,"qualifiedRecordTriggerTypes",new Set(["Create","CreateAndUpdate","Update"]))}}});var vo=P(Xr=>{"use strict";Object.defineProperty(Xr,"__esModule",{value:!0});Object.defineProperty(Xr,"SameRecordFieldUpdates",{enumerable:!0,get:function(){return mu}});var go=hu(S()),pu=D();function fu(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function yo(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(yo=function(i){return i?r:e})(t)}function hu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=yo(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var mu=class extends pu.RuleCommon{check(e,r,i){var l;let a=[],d=this.getStartProperty(e,"triggerType"),v=this.getStartProperty(e,"recordTriggerType"),y=d==="RecordBeforeSave",_=this.qualifiedRecordTriggerTypes.has(v);if(!y||!_)return a;let b=(l=e.elements)===null||l===void 0?void 0:l.filter(x=>x.subtype==="recordUpdates");if(!b)return a;for(let x of b)typeof x.element=="object"&&"inputReference"in x.element&&x.element.inputReference==="$Record"&&a.push(new go.Violation(x));return a}constructor(){super({ruleId:"same-record-field-updates",category:"suggestion",name:"SameRecordFieldUpdates",label:"Same Record Field Updates",description:"Before-save Flows can safely update the triggering record directly via $Record, applying changes efficiently without extra DML operations. Using before-save updates improves performance",summary:"Before-save Flows can update $Record directly",supportedTypes:[...go.FlowType.backEndTypes],docRefs:[{label:"Learn about same record field updates",path:"https://architect.salesforce.com/decision-guides/trigger-automation#Same_Record_Field_Updates"}]},{severity:"warning"}),fu(this,"qualifiedRecordTriggerTypes",new Set(["Create","Update","CreateAndUpdate"]))}}});var wo=P(Zr=>{"use strict";Object.defineProperty(Zr,"__esModule",{value:!0});Object.defineProperty(Zr,"SOQLQueryInLoop",{enumerable:!0,get:function(){return vu}});var gu=S(),yu=Ye(),vu=class extends yu.LoopRuleCommon{getStatementTypes(){return["recordLookups"]}constructor(){super({ruleId:"soql-in-loop",category:"problem",description:"Running SOQL queries inside a loop can rapidly exceed query limits and severely degrade performance. Queries should be executed once, with results reused throughout the loop.",summary:"SOQL queries inside loop risk governor limits",docRefs:[{label:"Flow Best Practices",path:"https://help.salesforce.com/s/articleView?id=sf.flow_prep_bestpractices.htm&type=5"}],label:"SOQL Query In A Loop",name:"SOQLQueryInLoop",supportedTypes:gu.FlowType.backEndTypes},{severity:"error"})}}});var _o=P(Qr=>{"use strict";Object.defineProperty(Qr,"__esModule",{value:!0});Object.defineProperty(Qr,"TriggerOrder",{enumerable:!0,get:function(){return _u}});var Yr=bu(S()),wu=D();function bo(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(bo=function(i){return i?r:e})(t)}function bu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=bo(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var _u=class extends wu.RuleCommon{check(e,r,i){return this.getStartProperty(e,"object")?e.triggerOrder?[]:[new Yr.Violation(new Yr.FlowAttribute("TriggerOrder","TriggerOrder","10, 20, 30 ..."))]:[]}constructor(){super({ruleId:"unspecified-trigger-order",category:"suggestion",name:"TriggerOrder",label:"Missing Trigger Order",description:"Record-triggered Flows without a specified Trigger Order may execute in an unpredictable sequence. Setting a Trigger Order ensures your Flows run in the intended order.",summary:"Trigger Order ensures predictable execution sequence",supportedTypes:[Yr.FlowType.autolaunchedType],docRefs:[{label:"Learn more about flow ordering orchestration",path:"https://architect.salesforce.com/decision-guides/trigger-automation#Ordering___Orchestration"}]},{severity:"note"})}}});var xo=P(Jr=>{"use strict";Object.defineProperty(Jr,"__esModule",{value:!0});Object.defineProperty(Jr,"UnconnectedElement",{enumerable:!0,get:function(){return Pu}});var et=xu(S()),Ou=D();function Oo(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Oo=function(i){return i?r:e})(t)}function xu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Oo(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Pu=class extends Ou.RuleCommon{check(e,r,i){var l;let a=((l=e.graph)===null||l===void 0?void 0:l.getReachableElements())||new Set;return e.elements.filter(y=>y instanceof et.FlowNode).filter(y=>!a.has(y.name)&&!i.has(y.name)).map(y=>new et.Violation(y))}constructor(){super({ruleId:"unreachable-element",category:"layout",description:"Unconnected elements never execute and add unnecessary clutter. Remove or connect unused Flow elements to keep Flows clean and efficient.",summary:"Unconnected elements add clutter without executing",docRefs:[],label:"Unreachable Element",name:"UnconnectedElement",supportedTypes:[...et.FlowType.backEndTypes,...et.FlowType.visualTypes],isFixable:!0})}}});var Co=P(Kr=>{"use strict";Object.defineProperty(Kr,"__esModule",{value:!0});Object.defineProperty(Kr,"UnsafeRunningContext",{enumerable:!0,get:function(){return Nu}});var tt=Ru(S()),Cu=D();function Po(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Po=function(i){return i?r:e})(t)}function Ru(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Po(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Nu=class extends Cu.RuleCommon{check(e,r,i){if(!("runInMode"in e.xmldata))return[];let l=e.xmldata.runInMode,a="SystemModeWithoutSharing";return l===a?[new tt.Violation(new tt.FlowAttribute(l,"runInMode",`== ${a}`))]:[]}constructor(){super({ruleId:"unsafe-running-context",category:"problem",name:"UnsafeRunningContext",label:"Unsafe Running Context",description:"Flows configured to run in System Mode without Sharing grant access to all data, bypassing user permissions. Avoid this setting to prevent security risks and protect sensitive data.",summary:"System mode without sharing creates security risks",supportedTypes:[...tt.FlowType.backEndTypes,...tt.FlowType.visualTypes],docRefs:[{label:"Learn about data safety when running flows in system context in Salesforce Help",path:"https://help.salesforce.com/s/articleView?id=sf.flow_distribute_context_data_safety_system_context.htm&type=5"}]},{severity:"error"})}}});var No=P(en=>{"use strict";Object.defineProperty(en,"__esModule",{value:!0});Object.defineProperty(en,"UnusedVariable",{enumerable:!0,get:function(){return Au}});var ge=Eu(S()),Tu=D();function Ro(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Ro=function(i){return i?r:e})(t)}function Eu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Ro(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Au=class extends Tu.RuleCommon{check(e,r,i){let l=e.elements.filter(d=>d instanceof ge.FlowVariable),a=[];for(let d of l){let v=d.name;if([...JSON.stringify(e.elements.filter(C=>C instanceof ge.FlowNode)).matchAll(new RegExp(v,"gi"))].map(C=>C.index).length>0||[...JSON.stringify(e.elements.filter(C=>C instanceof ge.FlowResource)).matchAll(new RegExp(v,"gi"))].map(C=>C.index).length>0)continue;let b=[...JSON.stringify(d).matchAll(new RegExp(d.name,"gi"))].map(C=>C.index);[...JSON.stringify(e.elements.filter(C=>C instanceof ge.FlowVariable)).matchAll(new RegExp(v,"gi"))].map(C=>C.index).length===b.length&&a.push(d)}return a.map(d=>new ge.Violation(d))}constructor(){super({ruleId:"unused-variable",category:"layout",name:"UnusedVariable",label:"Unused Variable",description:"Unused variables are never referenced and add unnecessary clutter. Remove them to keep Flows efficient and easy to maintain.",summary:"Unused variables add clutter and hurt maintainability",supportedTypes:[...ge.FlowType.backEndTypes,...ge.FlowType.visualTypes],docRefs:[],isFixable:!0})}}});var Ao=P(tn=>{"use strict";Object.defineProperty(tn,"__esModule",{value:!0});Object.defineProperty(tn,"MissingMetadataDescription",{enumerable:!0,get:function(){return Iu}});var To=Fu(S()),Su=D();function Eo(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Eo=function(i){return i?r:e})(t)}function Fu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Eo(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Iu=class extends Su.RuleCommon{check(e,r,i){let l=[];return e.elements.filter(a=>{if(a.metaType!=="attribute"&&!a.element.description&&a.subtype!=="start")return a}).forEach(a=>l.push(new To.Violation(a))),l}constructor(){super({ruleId:"missing-metadata-description",category:"layout",description:"Elements and metadata without a description reduce clarity and maintainability. Adding descriptions improves readability and makes your automation easier to understand.",summary:"Element descriptions improve clarity and maintainability",docRefs:[],label:"Missing Metadata Description",name:"MissingMetadataDescription",supportedTypes:To.FlowType.allTypes()},{severity:"warning"})}}});var Fo=P(nn=>{"use strict";Object.defineProperty(nn,"__esModule",{value:!0});Object.defineProperty(nn,"MissingRecordTriggerFilter",{enumerable:!0,get:function(){return Lu}});var rn=Du(S()),Mu=D();function So(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(So=function(i){return i?r:e})(t)}function Du(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=So(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Lu=class extends Mu.RuleCommon{check(e,r,i){var l,a;let d=[],v=this.getStartProperty(e,"triggerType");if(!v||!["RecordAfterSave","RecordBeforeSave"].includes(v))return d;let y=this.getStartProperty(e,"filters"),_=this.getStartProperty(e,"filterFormula"),b=!!y,x=!!_,A=!!((a=e.xmldata)===null||a===void 0||(l=a.start)===null||l===void 0?void 0:l.scheduledPaths);return!b&&!x&&!A&&d.push(new rn.Violation(new rn.FlowAttribute(v,"triggerType","autolaunched && triggerType"))),d}constructor(){super({ruleId:"missing-record-trigger-filter",category:"suggestion",name:"MissingRecordTriggerFilter",label:"Missing Filter Record Trigger",description:"Record-triggered Flows without filters on changed fields or entry conditions execute on every record change. Adding filters ensures the Flow runs only when needed, improving performance.",summary:"Filters ensure Flows run only when needed",supportedTypes:[rn.FlowType.autolaunchedType],docRefs:[]},{severity:"warning"})}}});var Mo=P(sn=>{"use strict";Object.defineProperty(sn,"__esModule",{value:!0});Object.defineProperty(sn,"MissingStartReference",{enumerable:!0,get:function(){return $u}});var on=qu(S()),Vu=D();function Io(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Io=function(i){return i?r:e})(t)}function qu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Io(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var $u=class extends Vu.RuleCommon{check(e,r,i){let l=[];return e.startNode||l.push(new on.Violation(new on.FlowAttribute("undefined","startNode","startNode"))),l}constructor(){super({ruleId:"missing-start-reference",category:"system",name:"MissingStartReference",label:"Missing Start Reference",description:"When a flow has no start reference.",summary:"Ensure flow has a start reference node",supportedTypes:on.FlowType.allTypes(),docRefs:[]},{severity:"error"})}}});var Vo=P(an=>{"use strict";Object.defineProperty(an,"__esModule",{value:!0});Object.defineProperty(an,"TransformInsteadOfLoop",{enumerable:!0,get:function(){return Wu}});var Do=ku(S()),Uu=D();function Lo(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Lo=function(i){return i?r:e})(t)}function ku(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Lo(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Wu=class extends Uu.RuleCommon{check(e,r,i){let l=[];if(this.getStartProperty(e,"triggerType")==="RecordBeforeSave")return l;let v=e.graph.getLoopNodes();for(let y of v){let _=e.graph.getNextElements(y.name);for(let b of _){let x=e.graph.getNode(b);if(x?.subtype==="assignments"){l.push(new Do.Violation(y));break}}}return l}constructor(){super({ruleId:"transform-instead-of-loop",category:"suggestion",name:"TransformInsteadOfLoop",label:"Transform Instead of Loop",description:"Loop elements that perform direct Assignments on each item can slow down Flows. Using Transform elements allows bulk operations on collections, improving performance and reducing complexity.",summary:"Transform elements enable faster bulk operations",supportedTypes:Do.FlowType.allTypes(),docRefs:[{label:"Transform Multiple Records - Trailhead",path:"https://trailhead.salesforce.com/content/learn/modules/multirecord-elements-and-transforms-in-flows/transform-multiple-records"}]},{severity:"note"})}}});var $o=P(cn=>{"use strict";Object.defineProperty(cn,"__esModule",{value:!0});Object.defineProperty(cn,"RecordIdAsString",{enumerable:!0,get:function(){return Gu}});var ln=Hu(S()),Bu=D();function qo(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(qo=function(i){return i?r:e})(t)}function Hu(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=qo(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}var Gu=class extends Bu.RuleCommon{check(e,r,i){var l;let a=[],d=this.getStartProperty(e,"triggerType");if(d==="RecordAfterSave"||d==="RecordBeforeDelete"||d==="RecordBeforeSave")return a;let y=(l=e.elements)===null||l===void 0?void 0:l.filter(_=>_.subtype==="variables");for(let _ of y){let b=_.element;(b.isInput===!0||b.isInput==="true")&&_.name.toLowerCase()==="recordid"&&b.dataType==="String"&&a.push(new ln.Violation(_))}return a}constructor(){super({ruleId:"record-id-as-string",category:"suggestion",name:"RecordIdAsString",label:"Record ID as String",description:"Flows that use a String variable for a record ID instead of receiving the full record introduce unnecessary complexity and additional Get Records queries. Using the complete record simplifies the Flow and improves performance.",summary:"String record IDs add complexity and queries",supportedTypes:[...ln.FlowType.visualTypes,ln.FlowType.autolaunchedType],docRefs:[{label:"Screen Flow Distribution",path:"https://help.salesforce.com/s/articleView?id=sf.flow_distribute_screen.htm"}]},{severity:"note"})}}});var Uo=P(dn=>{"use strict";Object.defineProperty(dn,"__esModule",{value:!0});Object.defineProperty(dn,"ruleRegistry",{enumerable:!0,get:function(){return Rd}});var ju=Kn(),zu=ti(),Xu=ni(),Zu=oi(),Yu=ai(),Qu=ui(),Ju=di(),Ku=hi(),ed=gi(),td=zi(),rd=Yi(),nd=Ki(),id=to(),od=io(),sd=so(),ad=lo(),ld=uo(),cd=fo(),ud=mo(),dd=vo(),pd=wo(),fd=_o(),hd=xo(),md=Co(),gd=No(),yd=Ao(),vd=Fo(),wd=Mo(),bd=Vo(),_d=$o();function un(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Od(t){for(var e=1;ee||!r.isBeta).map(r=>r.ruleId)}has(e){return this.get(e)!==void 0}createInstance(e){let r=this.get(e);if(!r)throw new Error(`Rule not found: ${e}`);return new r.ruleClass}getRules(e,r){let i=r?.betaMode===!0||r?.betamode===!0,l=r?.ruleMode||"merged",a=[];if(l==="isolated"&&e&&e.size>0){for(let y of e.keys()){let _=this.get(y);if(!_)continue;let b=e.get(y);if(b?.enabled===!1)continue;let x=this.createInstance(_.ruleId);b?.severity&&(x.severity=b.severity),a.push(x)}return a}let d=this.getAllRuleIds(i);for(let y of d){let _=this.createInstance(y);var v;let b=(v=e?.get(_.ruleId))!==null&&v!==void 0?v:e?.get(_.name);b?.enabled!==!1&&(b?.severity&&(_.severity=b.severity),a.push(_))}return a}getRulesByNames(e,r){if(!e||e.length===0)return this.getRules(void 0,r);let i=new Map;for(let l of e){let a=this.get(l);a&&i.set(a.ruleId,{enabled:!0})}return this.getRules(i,Pd(Od({},r),{ruleMode:"isolated"}))}constructor(){un(this,"rules",new Map),un(this,"legacyNameMap",new Map)}},M=new Cd;M.register("action-call-in-loop",ju.ActionCallsInLoop,"ActionCallsInLoop");M.register("invalid-api-version",zu.APIVersion,"APIVersion");M.register("missing-auto-layout",Xu.AutoLayout,"AutoLayout");M.register("unclear-api-naming",Yu.CopyAPIName,"CopyAPIName");M.register("cognitive-complexity",Zu.CognitiveComplexity,"CognitiveComplexity",!0);M.register("excessive-cyclomatic-complexity",Qu.CyclomaticComplexity,"CyclomaticComplexity");M.register("dml-in-loop",Ju.DMLStatementInLoop,"DMLStatementInLoop");M.register("duplicate-dml",Ku.DuplicateDMLOperation,"DuplicateDMLOperation");M.register("missing-flow-description",ed.FlowDescription,"FlowDescription");M.register("invalid-naming-convention",td.FlowName,"FlowName");M.register("get-record-all-fields",rd.GetRecordAllFields,"GetRecordAllFields");M.register("hardcoded-id",nd.HardcodedId,"HardcodedId");M.register("hardcoded-url",id.HardcodedUrl,"HardcodedUrl");M.register("inactive-flow",sd.InactiveFlow,"InactiveFlow");M.register("missing-fault-path",ad.MissingFaultPath,"MissingFaultPath");M.register("missing-null-handler",ld.MissingNullHandler,"MissingNullHandler");M.register("process-builder-usage",cd.ProcessBuilder,"ProcessBuilder");M.register("recursive-record-update",ud.RecursiveAfterUpdate,"RecursiveAfterUpdate");M.register("same-record-field-updates",dd.SameRecordFieldUpdates,"SameRecordFieldUpdates");M.register("soql-in-loop",pd.SOQLQueryInLoop,"SOQLQueryInLoop");M.register("unspecified-trigger-order",fd.TriggerOrder,"TriggerOrder");M.register("unreachable-element",hd.UnconnectedElement,"UnconnectedElement");M.register("unsafe-running-context",md.UnsafeRunningContext,"UnsafeRunningContext");M.register("unused-variable",gd.UnusedVariable,"UnusedVariable");M.register("missing-metadata-description",yd.MissingMetadataDescription,"MissingMetadataDescription",!0);M.register("missing-record-trigger-filter",vd.MissingRecordTriggerFilter,"MissingFilterRecordTrigger",!0);M.register("missing-start-reference",wd.MissingStartReference,"MissingStartReference",!0);M.register("transform-instead-of-loop",bd.TransformInsteadOfLoop,"TransformInsteadOfLoop",!0);M.register("record-id-as-string",_d.RecordIdAsString,"RecordIdAsString",!0);M.register("hardcoded-secret",od.HardcodedSecret,"HardcodedSecret",!0);var Rd=M});var fn=P(pn=>{"use strict";Object.defineProperty(pn,"__esModule",{value:!0});function Nd(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}Nd(pn,{get GetRuleDefinitions(){return Td},get getRules(){return Ed}});var Le=Uo();function Td(t,e){let r=e?.betaMode===!0||e?.betamode===!0,i=e?.systemRules!==!1,l=e?.categories,a=e?.ruleMode||"merged",d=[],v=Le.ruleRegistry.getAllRuleIds(r);if(a==="isolated"&&t&&t.size>0){for(let _ of t.keys()){let b=Le.ruleRegistry.get(_);if(!b)continue;let x=t.get(_);if(x?.enabled===!1)continue;let C=Le.ruleRegistry.createInstance(b.ruleId);C.category==="system"&&!i||ko(C.category,l,i)&&(x?.severity&&(C.severity=x.severity),d.push(C))}return d}for(let _ of v){let b=Le.ruleRegistry.createInstance(_);if(b.category==="system"&&!i||!ko(b.category,l,i))continue;var y;let x=(y=t?.get(b.ruleId))!==null&&y!==void 0?y:t?.get(b.name);x?.enabled!==!1&&(x?.severity&&(b.severity=x.severity),d.push(b))}return d}function ko(t,e,r){return t==="system"?r:!e||e.length===0?!0:e.map(l=>l.toLowerCase()).includes(t?.toLowerCase())}function Ed(t,e){return Le.ruleRegistry.getRulesByNames(t,e)}});var Go=P(hn=>{"use strict";Object.defineProperty(hn,"__esModule",{value:!0});Object.defineProperty(hn,"parse",{enumerable:!0,get:function(){return Ld}});var Ad=Ct(),Sd=Be(),Fd=Dd(Be()),Id=Ae(),Wo=Ze();function Bo(t,e,r,i,l,a,d){try{var v=t[a](d),y=v.value}catch(_){r(_);return}v.done?e(y):Promise.resolve(y).then(i,l)}function Md(t){return function(){var e=this,r=arguments;return new Promise(function(i,l){var a=t.apply(e,r);function d(y){Bo(a,i,l,d,v,"next",y)}function v(y){Bo(a,i,l,d,v,"throw",y)}d(void 0)})}}function Ho(t){if(typeof WeakMap!="function")return null;var e=new WeakMap,r=new WeakMap;return(Ho=function(i){return i?r:e})(t)}function Dd(t,e){if(!e&&t&&t.__esModule)return t;if(t===null||typeof t!="object"&&typeof t!="function")return{default:t};var r=Ho(e);if(r&&r.has(t))return r.get(t);var i={__proto__:null},l=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in t)if(a!=="default"&&Object.prototype.hasOwnProperty.call(t,a)){var d=l?Object.getOwnPropertyDescriptor(t,a):null;d&&(d.get||d.set)?Object.defineProperty(i,a,d):i[a]=t[a]}return i.default=t,r&&r.set(t,i),i}function Ld(t){return Md(function*(){let e=[],r=new Ad.XMLParser({attributeNamePrefix:"@_",ignoreAttributes:!1,ignoreNameSpace:!1,parseTagValue:!1,textNodeName:"#text"});for(let l of t)try{let a=Fd.normalize(l),d=yield Sd.promises.readFile(a,"utf8"),y=r.parse(d).Flow;e.push(new Wo.ParsedFlow(l,new Id.Flow(l,y)))}catch(a){var i;e.push(new Wo.ParsedFlow(l,void 0,(i=a.message)!==null&&i!==void 0?i:a.toString()))}return e})()}});var zo=P(mn=>{"use strict";Object.defineProperty(mn,"__esModule",{value:!0});function Vd(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}Vd(mn,{get getRuleDocumentationUrl(){return qd},get labelToAnchor(){return jo}});function jo(t){return t.toLowerCase().replace(/\s+/g,"-").replace(/[^a-z0-9-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")}function qd(t,e){return e||`https://flow-scanner.github.io/lightning-flow-scanner/#${jo(t)}`}});var Yo=P(gn=>{"use strict";Object.defineProperty(gn,"__esModule",{value:!0});function $d(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}$d(gn,{get ScanFlows(){return Zo},get scan(){return Hd}});var Ve=S(),rt=_t(),Ud=Fe(),kd=fn(),Wd=zo();function Xo(t,e){if(e)return e[t.ruleId]||e[t.name]}function Bd(t,e,r){if(!r?.[e])return[];let i=r[e],l=i[t.ruleId]||i[t.name];return l?.includes("*")?["*"]:l??[]}function Hd(t,e){let r=[],i=e?.ignoreFlows||[];for(let a of t)if(!a.errorMessage&&a.flow){if(i.length>0&&i.includes(a.flow.name))continue;r.push(a.flow)}return Zo(r,e)}function Zo(t,e){let r=[],i=e?.detailLevel,l=typeof i=="string"&&i.toLowerCase()==="simple"?rt.DetailLevel.SIMPLE:rt.DetailLevel.ENRICHED,a;if(e?.rules&&Object.keys(e.rules).length>0){a=new Map;for(let[_,b]of Object.entries(e.rules))a.set(_,b)}let d=(0,kd.GetRuleDefinitions)(a,e),v=new Map;for(let _ of t){let b=_ instanceof Ve.Flow?_:Ve.Flow.from(_),x=[];for(let C of d)try{if(!C.supportedTypes.includes(b.type)){x.push(new Ve.RuleResult(C,[]));continue}let A=Xo(C,e?.rules),k=Bd(C,b.name,e?.exceptions),F=A&&Object.keys(A).length>0?C.execute(b,A,k):C.execute(b,void 0,k);A&&typeof A=="object"&&"message"in A&&typeof A.message=="string"?F.message=A.message:F.message=F.ruleDefinition.summary||F.ruleDefinition.description;let re=A&&typeof A=="object"&&"messageUrl"in A&&typeof A.messageUrl=="string"?A.messageUrl:void 0;if(F.messageUrl=(0,Wd.getRuleDocumentationUrl)(F.ruleDefinition.label,re),F.details.length>0){let B=v.get(b.name);B||(B=b.toXMLString(),v.set(b.name,B)),B&&(0,Ud.enrichViolationsWithLineNumbers)(F.details,B)}x.push(F)}catch(A){let k=`Something went wrong while executing ${C.name} in the Flow: ${b.name} with error ${A}`;x.push(new Ve.RuleResult(C,[],k))}r.push(new Ve.ScanResult(b,x)),v.delete(b.name)}v.clear(),l===rt.DetailLevel.SIMPLE&&r.forEach(_=>{_.ruleResults.forEach(b=>{b.details.forEach(x=>{delete x.details})})});let y=e?.threshold;if(y&&y!=="never")for(let _ of r)_.ruleResults=_.ruleResults.filter(b=>{let x=Xo(b.ruleDefinition,e?.rules),C=x?.severity||b.severity||"warning";return(0,rt.meetsThreshold)(C,y)});return r}});var Qo=P(yn=>{"use strict";Object.defineProperty(yn,"__esModule",{value:!0});Object.defineProperty(yn,"exportDiagram",{enumerable:!0,get:function(){return Gd}});function Gd(t,e={includeDetails:!0,includeMarkdownDocs:!0,collapsedDetails:!0}){let r=t.filter(a=>a.flow).map(a=>a.flow),i=`# Flow Documentation -`;t.length===0&&(s+=`No valid flows found. +`;r.length===0&&(i+=`No valid flows found. -`);for(const n of t){s+=`## ${n.name} +`);for(let a of r){i+=`## ${a.name} -`;const o={includeDetails:e.includeDetails,includeMarkdownDocs:e.includeMarkdownDocs,collapsedDetails:e.collapsedDetails};s+=n.visualize("mermaid",o)+` +`;let d={includeDetails:e.includeDetails,includeMarkdownDocs:e.includeMarkdownDocs,collapsedDetails:e.collapsedDetails};i+=a.visualize("mermaid",d)+` -`}const r=a.filter(n=>n.errorMessage);if(r.length>0){s+=`## Parse Errors +`}let l=t.filter(a=>a.errorMessage);if(l.length>0){i+=`## Parse Errors -`;for(const n of r)s+=`- ${n.uri}: ${n.errorMessage} -`;s+=` -`}return s}g.ASCII_ICONS=he,g.ASCII_VARIABLE_ICONS=me,g.Compiler=Q,g.DEFAULT_ICONS=ee,g.DEFAULT_VARIABLE_ICONS=se,g.Flow=_,g.FlowAttribute=A,g.FlowElement=B,g.FlowNode=x,g.FlowResource=te,g.FlowType=h,g.FlowVariable=j,g.ParsedFlow=re,g.RuleResult=q,g.ScanResult=ye,g.Violation=y,g.exportDetails=Re,g.exportDiagram=wt,g.exportSarif=Ee,g.fix=Ue,g.getRules=pt,g.parse=gt,g.scan=yt,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"})})); +`;for(let a of l)i+=`- ${a.uri}: ${a.errorMessage} +`;i+=` +`}return i}});var pp=P(vn=>{Object.defineProperty(vn,"__esModule",{value:!0});function jd(t,e){for(var r in e)Object.defineProperty(t,r,{enumerable:!0,get:Object.getOwnPropertyDescriptor(e,r).get})}jd(vn,{get ASCII_ICONS(){return Jo.ASCII_ICONS},get ASCII_VARIABLE_ICONS(){return Ko.ASCII_VARIABLE_ICONS},get Compiler(){return zd.Compiler},get DEFAULT_ICONS(){return Jo.DEFAULT_ICONS},get DEFAULT_VARIABLE_ICONS(){return Ko.DEFAULT_VARIABLE_ICONS},get Flow(){return ep.Flow},get FlowAttribute(){return tp.FlowAttribute},get FlowElement(){return rp.FlowElement},get FlowNode(){return np.FlowNode},get FlowResource(){return ip.FlowResource},get FlowType(){return op.FlowType},get FlowVariable(){return sp.FlowVariable},get ParsedFlow(){return ap.ParsedFlow},get RuleResult(){return lp.RuleResult},get SEVERITY_ORDER(){return nt.SEVERITY_ORDER},get ScanResult(){return cp.ScanResult},get Violation(){return up.Violation},get countThresholdViolations(){return nt.countThresholdViolations},get exportDetails(){return Xd.exportDetails},get exportDiagram(){return dp.exportDiagram},get exportSarif(){return Zd.exportSarif},get filterByThreshold(){return nt.filterByThreshold},get fix(){return Yd.fix},get getRules(){return Qd.getRules},get meetsThreshold(){return nt.meetsThreshold},get parse(){return Jd.parse},get scan(){return Kd.scan}});var nt=_t(),zd=We(),Xd=In(),Zd=Dn(),Yd=Jn(),Qd=fn(),Jd=Go(),Kd=Yo(),ep=Ae(),tp=Xe(),rp=oe(),np=He(),ip=Ge(),op=Gt(),sp=je(),ap=Ze(),lp=Qt(),cp=Kt(),up=Fe(),Jo=St(),Ko=Lt(),dp=Qo()});return pp();})();