/*
 * Copyright 2026, Jaime Terrats.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
import { lines } from './shared.js';
const PDF_BASE_URL = 'https://resources.docs.salesforce.com/latest/latest/en-us/sfdc/pdf';
const SFXD_BASE = 'https://wiki.sfxd.org/books/salesforce-releases/page';
const AGENTFORCE_ATLAS = 'https://developer.salesforce.com/docs/atlas.en-us.agentforce.meta/agentforce';
const AI_ATLAS = 'https://developer.salesforce.com/docs/atlas.en-us.ai.meta/ai';
const EINSTEIN_ATLAS = 'https://developer.salesforce.com/docs/atlas.en-us.einstein_platform.meta/einstein_platform';
export const WEB_REFERENCES = [
    // Agentforce — Atlas HTML docs (no PDF available; SPA content rendered via JS)
    {
        title: 'Agentforce Developer Guide — Overview',
        url: 'https://developer.salesforce.com/docs/ai/agentforce/overview',
        scope: 'Agentforce developer portal — entry point for all agent development guides',
        profileIds: ['ai', 'ta', 'developer'],
    },
    {
        title: 'Agentforce — Introduction',
        url: `${AGENTFORCE_ATLAS}/agentforce_intro.htm`,
        scope: 'What is Agentforce, agent anatomy, supported channels, licensing',
        profileIds: ['ai', 'ta'],
    },
    {
        title: 'Agentforce — Create an Agent',
        url: `${AGENTFORCE_ATLAS}/agentforce_create_agent.htm`,
        scope: 'Agent Builder UI walkthrough, system prompt, instructions, tone',
        profileIds: ['ai', 'developer'],
    },
    {
        title: 'Agentforce — Topics',
        url: `${AGENTFORCE_ATLAS}/agentforce_topics.htm`,
        scope: 'Topic design, classification, routing, topic instructions, context variables',
        profileIds: ['ai', 'developer'],
    },
    {
        title: 'Agentforce — Actions',
        url: `${AGENTFORCE_ATLAS}/agentforce_actions.htm`,
        scope: 'Standard actions, Apex actions, Flow actions, Prompt Template actions, external actions',
        profileIds: ['ai', 'developer'],
    },
    {
        title: 'Agentforce — Testing',
        url: `${AGENTFORCE_ATLAS}/agentforce_testing.htm`,
        scope: 'Testing Center, test case authoring, topic match %, action accuracy, regression suites',
        profileIds: ['ai', 'developer'],
    },
    {
        title: 'Agentforce — Deploy',
        url: `${AGENTFORCE_ATLAS}/agentforce_deploy.htm`,
        scope: 'Deployment checklist, activation, channel publishing, monitoring post-launch',
        profileIds: ['ai', 'devops'],
    },
    {
        title: 'Agentforce — Metadata API Types',
        url: `${AGENTFORCE_ATLAS}/agentforce_metadata.htm`,
        scope: 'GenAiApplication, GenAiPlanner, GenAiPlugin, Bot metadata types for DX source tracking',
        profileIds: ['ai', 'developer', 'devops'],
    },
    {
        title: 'Agentforce — Apex Integration',
        url: `${AGENTFORCE_ATLAS}/agentforce_apex.htm`,
        scope: 'Invocable Apex for agent actions, @InvocableMethod, input/output types, bulkification',
        profileIds: ['ai', 'developer'],
    },
    // Einstein AI / Prompt Builder — Atlas HTML docs
    {
        title: 'Einstein AI Developer Guide — Prompt Builder',
        url: `${AI_ATLAS}/ai_prompt_builder.htm`,
        scope: 'Prompt Builder UI, prompt template types (Sales Email, Field Generation, Flex), grounding',
        profileIds: ['ai', 'developer'],
    },
    {
        title: 'Einstein AI Developer Guide — Apex AI Platform',
        url: `${AI_ATLAS}/ai_apex.htm`,
        scope: 'aiplatform.EinsteinLLM Apex class, callout patterns, response parsing, error handling',
        profileIds: ['ai', 'developer'],
    },
    {
        title: 'Einstein AI Developer Guide — Introduction',
        url: `${AI_ATLAS}/ai_intro.htm`,
        scope: 'Einstein AI capabilities overview, trust layer, data masking, zero data retention',
        profileIds: ['ai', 'ta'],
    },
    // Einstein Platform (legacy / broader AI features)
    {
        title: 'Einstein Platform Developer Guide',
        url: `${EINSTEIN_ATLAS}/einstein_platform_intro.htm`,
        scope: 'Einstein Vision, Language, Prediction Builder — legacy AI platform APIs',
        profileIds: ['ai', 'ta'],
    },
    // MuleSoft — hosted on docs.mulesoft.com, not Salesforce CDN
    {
        title: 'MuleSoft Anypoint Platform Documentation',
        url: 'https://docs.mulesoft.com/general/',
        scope: 'Anypoint Studio, Runtime, CloudHub 2.0, API Manager, MQ — top-level docs portal',
        profileIds: ['mulesoft', 'ta'],
    },
    {
        title: 'DataWeave Language Reference',
        url: 'https://docs.mulesoft.com/dataweave/latest/',
        scope: 'DataWeave 2.x syntax, transformations, functions, modules',
        profileIds: ['mulesoft', 'developer'],
    },
    {
        title: 'MuleSoft API-Led Connectivity Whitepaper',
        url: 'https://www.mulesoft.com/resources/api/introduction-to-api-led-connectivity',
        scope: 'System / Process / Experience layer architecture pattern',
        profileIds: ['mulesoft', 'ta'],
    },
    // Marketing Cloud — hosted on developer.salesforce.com and help.salesforce.com
    {
        title: 'Marketing Cloud Developer Documentation',
        url: 'https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/index.html',
        scope: 'REST & SOAP APIs, AMPscript, SSJS, Journey Builder API, transactional messaging',
        profileIds: ['sfmc', 'developer'],
    },
    {
        title: 'Marketing Cloud Personalization (Interaction Studio) Developer Guide',
        url: 'https://developer.salesforce.com/docs/marketing/personalization/guide/personalization-developer-guide.html',
        scope: 'Web SDK, event streams, catalog objects, recipes, Einstein decisions',
        profileIds: ['sfmc', 'developer'],
    },
    {
        title: 'Marketing Cloud Connect Implementation Guide',
        url: 'https://help.salesforce.com/s/articleView?id=sf.mc_co_marketing_cloud_connect.htm',
        scope: 'MC Connect setup, synchronized data extensions, triggered sends from Sales/Service Cloud',
        profileIds: ['sfmc', 'ta'],
    },
    {
        title: 'Service SDK for iOS Developer Guide',
        url: 'https://developer.salesforce.com/docs/atlas.en-us.service_sdk_ios.meta/service_sdk_ios/servicesdk_ios_dev_guide.htm',
        scope: 'Embedded Service SDK for iOS — chat, knowledge, case management in native iOS apps',
        profileIds: ['service', 'developer'],
    },
    {
        title: 'Service SDK for Android Developer Guide',
        url: 'https://developer.salesforce.com/docs/atlas.en-us.service_sdk_android.meta/service_sdk_android/servicesdk_android_dev_guide.htm',
        scope: 'Embedded Service SDK for Android — chat, knowledge, case management in native Android apps',
        profileIds: ['service', 'developer'],
    },
    {
        title: "Spring '26 Abridged Release Notes",
        url: `${SFXD_BASE}/spring-26-abridged`,
        scope: "Community-curated highlights of the Spring '26 Salesforce release",
        profileIds: [],
    },
    {
        title: "Winter '26 Abridged Release Notes",
        url: `${SFXD_BASE}/winter-26-abridged`,
        scope: "Community-curated highlights of the Winter '26 Salesforce release",
        profileIds: [],
    },
    {
        title: "Summer '25 Abridged Release Notes",
        url: `${SFXD_BASE}/summer-25-abridged`,
        scope: "Community-curated highlights of the Summer '25 Salesforce release",
        profileIds: [],
    },
];
export const PDF_REGISTRY = [
    // Cross-cutting (always included)
    {
        product: 'Apex Developer Guide',
        filename: 'salesforce_apex_developer_guide.pdf',
        scope: 'Governor limits, async, sharing, tests, managed packages, Agentforce integration',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Apex Reference Guide',
        filename: 'salesforce_apex_reference_guide.pdf',
        scope: 'Full Apex class/method reference, SOQL aggregate functions, Templates class, ProjectionNode',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Salesforce Object Reference',
        filename: 'object_reference.pdf',
        scope: 'All standard SObjects, fields, relationships',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Metadata API',
        filename: 'api_meta.pdf',
        scope: 'Metadata coverage, deployment, retrieve',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'REST API',
        filename: 'api_rest.pdf',
        scope: 'REST API, SOQL via REST, composite resources',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Streaming API & Platform Events',
        filename: 'api_streaming.pdf',
        scope: 'PushTopics, Generic Streaming, Change Data Capture',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Async Apex & Bulk API',
        filename: 'api_asynch.pdf',
        scope: 'Batch Apex, Queueable, Schedulable, Bulk API',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Salesforce Basics',
        filename: 'basics.pdf',
        scope: 'Reports, dashboards, records, tags, topics, Recycle Bin, Lightning Experience fundamentals',
        verifyUrl: true,
        profileIds: ['admin', 'ba'],
    },
    {
        product: 'Revenue Lifecycle Management Developer Guide',
        filename: 'revenue_lifecycle_management_dev_guide.pdf',
        scope: 'Billing, Payments, Tax Engine, Flow for Billing, Revenue Cloud Apex APIs',
        verifyUrl: true,
        profileIds: ['cpq', 'ta'],
    },
    {
        product: 'SOQL and SOSL Reference',
        filename: 'salesforce_soql_sosl.pdf',
        scope: 'SOQL syntax, SOSL, WITH SNIPPET, WITH SPELL_CORRECTION, aggregate functions, relationship queries',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Developer Limits and Allocations Quick Reference',
        filename: 'salesforce_app_limits_cheatsheet.pdf',
        scope: 'Governor limits cheatsheet — API calls, SOQL rows, heap, CPU, DML statements',
        verifyUrl: true,
        profileIds: [],
    },
    {
        product: 'Salesforce Mobile SDK',
        filename: 'mobile_sdk.pdf',
        scope: 'iOS/Android native SDK, hybrid apps, UIWebView migration, deprecated APIs',
        verifyUrl: true,
        profileIds: ['developer'],
    },
    {
        product: 'Salesforce DX Developer Guide',
        filename: 'sfdx_dev.pdf',
        scope: 'Scratch orgs, source tracking, JWT auth, org authorization, CLI troubleshooting',
        verifyUrl: true,
        profileIds: ['developer', 'devops'],
    },
    {
        product: 'DevOps Center',
        filename: 'devops_center.pdf',
        scope: 'Pipeline stages, work items, merge conflicts, GitHub integration, deployment troubleshooting',
        verifyUrl: true,
        profileIds: ['devops', 'developer'],
    },
    {
        product: 'Data Loader Guide',
        filename: 'salesforce_data_loader.pdf',
        scope: 'CLI data import/export, field mapping, encrypted passwords, configuration files',
        verifyUrl: true,
        profileIds: ['admin', 'developer', 'devops'],
    },
    {
        product: 'Salesforce Security Implementation Guide',
        filename: 'salesforce_security_impl_guide.pdf',
        scope: 'Apex/Visualforce security, XSS, CSRF, SOQL injection, Event Log Files, Threat Detection',
        verifyUrl: true,
        profileIds: ['security', 'ta', 'developer', 'admin'],
    },
    {
        product: 'Salesforce Identity',
        filename: 'identity.pdf',
        scope: 'Connected Apps, OAuth, Mobile Device Tracking, Platform Integration User, custom reports',
        verifyUrl: true,
        profileIds: ['ta', 'developer', 'admin'],
    },
    {
        product: 'CRM Analytics Developer Guide',
        filename: 'analytics.pdf',
        scope: 'CRM Analytics API, Decision Optimization, Einstein Predictions, dataset management',
        verifyUrl: true,
        profileIds: ['crma', 'data360', 'ta'],
    },
    // Profile-specific
    {
        product: 'CG Cloud Retail User Guide',
        filename: 'retail_user.pdf',
        scope: 'Van Sales, Tour Cockpit, Driver Cockpit, Delivery Execution, offline mobile app for Field Reps',
        verifyUrl: true,
        profileIds: ['cgcloud'],
    },
    {
        product: 'CG Cloud Real Time Reporting Developer Guide',
        filename: 'realtime_reporting_and_integration_apis.pdf',
        scope: 'Apex custom RTR datasources, TPM reporting, Fund Amount, Fixed Funds, AMS base classes',
        verifyUrl: true,
        profileIds: ['cgcloud'],
    },
    {
        product: 'CG Cloud Developer Guide (Object Reference)',
        filename: 'retail_api.pdf',
        scope: 'cgcloud__ objects, API end-of-life policy, standard and custom SObjects',
        verifyUrl: true,
        profileIds: ['cgcloud'],
    },
    {
        product: 'CG Cloud Implementation Guide',
        filename: null,
        scope: 'Setup, Modeler, Visit Templates, Promotions — external: Salesforce Help',
        verifyUrl: false,
        profileIds: ['cgcloud'],
    },
    {
        product: 'Field Service Mobile Developer Guide',
        filename: 'field_service_dev.pdf',
        scope: 'Mobile app LWC plug-ins, AR SpaceCapture, Document Builder, deep linking, offline mode',
        verifyUrl: true,
        profileIds: ['fsl'],
    },
    {
        product: 'Salesforce Mobile Offline Development',
        filename: 'mobile_offline.pdf',
        scope: 'LWC Quick Actions for Field Service mobile, iOS/Android emulator setup, debugging, permission sets',
        verifyUrl: true,
        profileIds: ['fsl', 'developer'],
    },
    {
        product: 'Field Service Admin Guide',
        filename: null,
        scope: 'Setup, Service Resources, Scheduling Policies — external: Salesforce Help',
        verifyUrl: false,
        profileIds: ['fsl'],
    },
    {
        product: 'SMB Sales Implementation Guide',
        filename: 'smb_sales_impl_guide.pdf',
        scope: 'Data import, reports, dashboards, rollout best practices for SMB Salesforce implementations',
        verifyUrl: true,
        profileIds: ['admin', 'ba'],
    },
    {
        product: 'High Velocity Sales Implementation Guide',
        filename: 'high_velocity_sales_impl_guide.pdf',
        scope: 'Sales Cadences, Work Queues, Einstein Lead Scoring, Email Tracking, Call Outcomes, Sales Engagement',
        verifyUrl: true,
        profileIds: ['admin', 'ba', 'ta'],
    },
    {
        product: 'Sales Cloud Core',
        filename: 'sales_core.pdf',
        scope: 'Einstein Opportunity Scoring, Einstein Copilot for Sales, LinkedIn Sales Navigator, Partner Portal',
        verifyUrl: true,
        profileIds: ['ta', 'admin', 'ba'],
    },
    {
        product: 'Manufacturing Cloud Admin Guide',
        filename: 'manufacturing_admin.pdf',
        scope: 'CRM Analytics for Manufacturing, Warranty Lifecycle, Order Forecasting, Einstein Discovery',
        verifyUrl: true,
        profileIds: ['manufacturing', 'ta'],
    },
    {
        product: 'Salesforce Industries Developer Guide',
        filename: 'salesforce_industries_dev_guide.pdf',
        scope: 'Virtual Calls, Eligibility Rules, Unified Catalog, Timeline API, IndustriesSettings, Community License access',
        verifyUrl: true,
        profileIds: ['automotive', 'fsc', 'cgcloud', 'omnistudio', 'ta'],
    },
    {
        product: 'Automotive Cloud',
        filename: 'automotive_cloud.pdf',
        scope: 'Action Plans, Telemetry, Flow for Automotive, Service Process Studio, Metadata API types',
        verifyUrl: true,
        profileIds: ['automotive', 'ta'],
    },
    {
        product: 'Financial Services Cloud',
        filename: 'financial_services.pdf',
        scope: 'Wealth Management, Retail Banking, Insurance analytics, AI Product Recommendations, Einstein Discovery',
        verifyUrl: true,
        profileIds: ['fsc', 'ta'],
    },
    {
        product: 'Experience Cloud Implementation Guide',
        filename: 'communities.pdf',
        scope: 'Experience Builder, templates, branding, SEO, member management, moderation, Salesforce CMS',
        verifyUrl: true,
        profileIds: ['experience-cloud', 'admin', 'ta', 'commerce'],
    },
    {
        product: 'Experience Cloud Developer Guide',
        filename: 'communities_dev.pdf',
        scope: 'ExperienceBundle, LWR Sites, Guest User security, CSP/LWS/Lightning Locker, CMS integration',
        verifyUrl: true,
        profileIds: ['developer', 'ta', 'commerce'],
    },
    {
        product: 'CTI (Computer-Telephony Integration) API',
        filename: 'api_cti.pdf',
        scope: 'Softphone API, screen pop, click-to-dial, Call Center settings, Salesforce Classic CTI methods',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Chat Administrator Guide',
        filename: 'chat_administrator.pdf',
        scope: 'Chat deployments, buttons, routing, Omni-Channel migration, pre/post-chat forms, Knowledge integration',
        verifyUrl: true,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'Chat for Support Supervisors',
        filename: 'chat_support_supervisors.pdf',
        scope: 'Agent skill assignment, supervisor tools for Live Agent/Chat',
        verifyUrl: true,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'Chat for Support Agents',
        filename: 'chat_support_agents.pdf',
        scope: 'Agent chat workflow, transcripts, file transfer, Quick Text, conferencing, visitor records',
        verifyUrl: true,
        profileIds: ['service'],
    },
    {
        product: 'Chat Developer Guide',
        filename: 'chat_dev_guide.pdf',
        scope: 'Pre-chat API, post-chat, direct-to-agent routing, custom chat window via Visualforce, findOrCreate API',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Chat REST API',
        filename: 'chat_rest.pdf',
        scope: 'Chat REST endpoints, visitor/agent events, sensitive data rules, queue updates, error responses',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Embedded Service SDK',
        filename: 'embedded_services.pdf',
        scope: 'Embedded chat on websites/Experience Sites, custom branding, embedded flows, appointment management',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Service Cloud Voice Performance Metrics Guide',
        filename: 'voice_performance_metrics_guide.pdf',
        scope: 'Voice Channel KPIs, performance trends, custom Voice reports',
        verifyUrl: true,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'Omni-Channel for Administrators',
        filename: 'service_presence_administrators.pdf',
        scope: 'Queues, Routing Configurations, Presence Statuses, Omni Supervisor setup, agent capacity',
        verifyUrl: true,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'Omni Supervisor Guide',
        filename: 'omnichannel_supervisor.pdf',
        scope: 'Wallboard, Queues Backlog, Skills Backlog, agent work management, Omni Inbox, mobile',
        verifyUrl: true,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'Omni-Channel Developer Guide',
        filename: 'service_presence_developer_guide.pdf',
        scope: 'External Routing API, AgentWork, CDC integration, Lightning Console JS API, Omni-Channel metadata',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Case Feed & Publisher Quick Action Developer Guide',
        filename: 'case_feed_dev_guide.pdf',
        scope: 'Publisher API, Quick Action API, custom Case actions, Visualforce Case page customization',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Service Console API',
        filename: 'api_console.pdf',
        scope: 'Omni-Channel API, agent workload, Live Agent/Chat visitor methods, console events',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Lightning Flow for Service (Guided Engagement) Developer Guide',
        filename: 'salesforce_guided_engagement.pdf',
        scope: 'Flow for Service, guided steps, Open CTI & Chat integration, Action Plans via Apex/SOAP',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Employee Service Experience Implementation Guide',
        filename: 'esx_implementation_guide.pdf',
        scope: 'HR Service Center, Employee Transitions, Onboarding, Employee Management Experience Site',
        verifyUrl: true,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'SOS Video Chat & Screen-Sharing Admin Guide',
        filename: null,
        scope: 'SOS Video Chat, screen-sharing, deployments, queues — external: Salesforce Help (PDF 404)',
        verifyUrl: false,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'Lightning Knowledge Implementation Guide',
        filename: 'lightning_knowledge_guide.pdf',
        scope: 'Knowledge sharing model, Data Categories, multilingual articles, translations, article lifecycle',
        verifyUrl: true,
        profileIds: ['service', 'admin'],
    },
    {
        product: 'Salesforce Knowledge Developer Guide',
        filename: 'salesforce_knowledge_dev_guide.pdf',
        scope: 'PublishingService Apex API, article lifecycle, translations, SOSL WITH SNIPPET, UI API',
        verifyUrl: true,
        profileIds: ['service', 'developer'],
    },
    {
        product: 'Service Cloud Implementation',
        filename: 'support.pdf',
        scope: 'Case, Knowledge, Approvals, HR Service Workspace, Field Service delivery',
        verifyUrl: true,
        profileIds: ['service'],
    },
    {
        product: 'Entitlement Management Implementation Guide',
        filename: 'salesforce_entitlements_implementation_guide.pdf',
        scope: 'Entitlement Processes, Milestones, Service Contracts, SLA enforcement, entitlement versioning',
        verifyUrl: true,
        profileIds: ['service', 'admin', 'ta'],
    },
    {
        product: 'Salesforce CPQ Developer Guide',
        filename: 'cpq_developer_guide.pdf',
        scope: 'CPQ plugins: Quote Calculator, External Configurator, Product Search, Electronic Signature, Document Store',
        verifyUrl: true,
        profileIds: ['cpq', 'developer'],
    },
    {
        product: 'Approval Processes',
        filename: null,
        scope: 'ProcessInstance, Steps, Workitems, Dynamic Approvers — external: Salesforce Help',
        verifyUrl: false,
        profileIds: ['ta', 'ba', 'admin', 'service', 'cpq'],
    },
    {
        product: 'OmniStudio',
        filename: null,
        scope: 'OmniScript, FlexCard, DataRaptor, Integration Procedures — external: Salesforce Help',
        verifyUrl: false,
        profileIds: ['omnistudio'],
    },
    {
        product: 'Salesforce Maps',
        filename: 'salesforce_maps.pdf',
        scope: 'Boundaries, geofencing, route visualization',
        verifyUrl: true,
        profileIds: ['cgcloud', 'fsl'],
    },
    {
        product: 'Document Generation',
        filename: null,
        scope: 'Templates, generation runtime, signing — external: Salesforce Help',
        verifyUrl: false,
        profileIds: ['omnistudio', 'ba', 'developer'],
    },
    {
        product: 'Data Cloud Implementation',
        filename: 'data_cloud.pdf',
        scope: 'DMOs, Identity Resolution, Calculated Insights, Activation',
        verifyUrl: true,
        profileIds: ['data360'],
    },
    {
        product: 'Agentforce & Generative AI',
        filename: 'generative_ai.pdf',
        scope: 'Prompt Builder, Data Libraries, AI features setup',
        verifyUrl: true,
        profileIds: ['ai', 'ta'],
    },
    {
        product: 'MuleSoft Anypoint Platform',
        filename: null,
        scope: 'API-led connectivity, CloudHub 2.0 — external: Anypoint Exchange',
        verifyUrl: false,
        profileIds: ['mulesoft'],
    },
    {
        product: 'Extend Salesforce with Clicks, Not Code',
        filename: 'extend_click_automate.pdf',
        scope: 'Workflow Rules, Process Builder, Approval Processes, time-dependent actions, declarative automation',
        verifyUrl: true,
        profileIds: ['admin', 'ba', 'developer'],
    },
    {
        product: 'Salesforce Flow Builder',
        filename: null,
        scope: 'Record-Triggered, Auto-Launched, Decision element — external: Salesforce Help',
        verifyUrl: false,
        profileIds: ['developer', 'ba', 'admin'],
    },
    {
        product: 'Lightning Web Components',
        filename: null,
        scope: 'LWC development, SLDS, component lifecycle — external: developer.salesforce.com',
        verifyUrl: false,
        profileIds: ['developer', 'ux'],
    },
    {
        product: 'Tooling API',
        filename: 'api_tooling.pdf',
        scope: 'CompileAndTest, SymbolTable, code coverage, debugging metadata',
        verifyUrl: true,
        profileIds: ['developer', 'devops'],
    },
    {
        product: 'Real-Time Event Monitoring',
        filename: 'platform_events.pdf',
        scope: 'Login, Logout, Session Hijacking, Report anomalies, Mobile policy events, EventStream objects',
        verifyUrl: true,
        profileIds: ['developer', 'ta', 'admin'],
    },
];
export function generatePdfRegistry(profiles, version) {
    const activeProfileIds = new Set(profiles.map((p) => p.id));
    const isActive = (profileIds) => profileIds.length === 0 || profileIds.some((id) => activeProfileIds.has(id));
    const filtered = PDF_REGISTRY.filter((entry) => isActive(entry.profileIds));
    const tableRows = filtered
        .map((entry) => {
        const verified = entry.verifyUrl ? '⚠️' : 'N/A';
        if (entry.filename === null) {
            return `| ${entry.product} | *(no PDF — see scope note)* | ${entry.scope} | ${verified} |`;
        }
        const url = `${PDF_BASE_URL}/${entry.filename}`;
        return `| [${entry.product}](${url}) | \`${entry.filename}\` | ${entry.scope} | ${verified} |`;
    })
        .join('\n');
    const filteredWebRefs = WEB_REFERENCES.filter((entry) => isActive(entry.profileIds));
    const webRefRows = filteredWebRefs.map((entry) => `| [${entry.title}](${entry.url}) | ${entry.scope} |`).join('\n');
    return lines(mdcFrontmatter('Salesforce official PDF registry for this workspace', version), '', '# Salesforce Reference Registry', '', `> PDF base URL: \`${PDF_BASE_URL}/{filename}\``, '', '## Usage Protocol', '', '1. Identify the Salesforce product or feature you need to reference.', '2. Look up the product in the Registry table below to find its PDF filename.', '3. WebFetch the PDF URL before asserting platform capabilities or OOTB coverage.', '4. Cite findings as: `<filename>.pdf §<section> p.<page> — "<quote ≤ 30 words>"`.', '5. If the URL returns 404, search `help.salesforce.com` and document the gap in the deliverable.', '', '## PDF Registry', '', '| Product | Filename | Scope | Verified |', '|---------|----------|-------|----------|', tableRows, '', '> ⚠️ = URL confirmed reachable — WebFetch before citing  N/A = no PDF, use external source noted in scope', '', '## Release Notes (SFXD Abridged)', '', '> Source: [SFXD Wiki](https://wiki.sfxd.org/books/salesforce-releases) — community-curated highlights, not official Salesforce documentation.', '> Use for: checking what changed in a recent release before asserting platform behavior.', '', '| Release | Scope |', '|---------|-------|', webRefRows, '', '## 404 Handling', '', 'When a PDF URL returns 404:', '', '1. Search `https://help.salesforce.com` for the feature or product name.', '2. Fall back to `https://developer.salesforce.com` HTML documentation if no PDF is found.', '3. Document the gap explicitly in the deliverable: "PDF unavailable — source: <fallback URL>".', '4. Never assert platform capabilities without citing an authoritative source.');
}
// ─── Internal helpers ──────────────────────────────────────────────────────
function mdcFrontmatter(description, version) {
    return lines('---', `description: ${description}`, 'globs:', 'alwaysApply: true', `pluginVersion: "${version}"`, '---');
}
//# sourceMappingURL=pdf-registry.js.map