// @bun
import*as z from"fs";class E{static needsComposerSupport(){return z.existsSync("composer.json")}static generateComposerSetupSteps(){return`
      - name: Setup PHP and Composer (if needed)
        if: \${{ hashFiles('composer.json') != '' }}
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.4'
          tools: composer
          coverage: none

      - name: Install Composer dependencies (if needed)
        if: \${{ hashFiles('composer.json') != '' }}
        run: composer install --prefer-dist --optimize-autoloader
`}static getStandardSetupSteps(){return`      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: \${{ secrets.GITHUB_TOKEN }}

      - name: Setup Bun
        uses: oven-sh/setup-bun@v2

      - name: Install dependencies
        run: bun install

      - name: Build buddy-bot
        run: bun run build`}static generateWorkflow(j){return`name: ${j.name}

on:
  schedule:
    - cron: '${j.schedule}'
  workflow_dispatch: # Allow manual triggering
    inputs:
      strategy:
        description: 'Update strategy'
        required: false
        default: '${j.strategy||"all"}'
        type: choice
        options:
          - all
          - major
          - minor
          - patch
      dry_run:
        description: 'Dry run (preview only)'
        required: false
        default: false
        type: boolean

env:
  GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}

permissions:
  contents: write
  pull-requests: write
  issues: write
  actions: read
  checks: read
  statuses: read

jobs:
  dependency-updates:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: \${{ secrets.GITHUB_TOKEN }}

      - name: Setup Bun
        uses: oven-sh/setup-bun@v2
\${GitHubActionsTemplate.generateComposerSetupSteps()}
      - name: Install dependencies
        run: bun install

      - name: Build buddy-bot
        run: bun run build

      - name: Run Buddy dependency updates
        run: |
          STRATEGY="\${{ github.event.inputs.strategy || '${j.strategy||"all"}' }}"
          DRY_RUN="\${{ github.event.inputs.dry_run || 'false' }}"

          if [ "$DRY_RUN" = "true" ]; then
            ./buddy update --strategy "$STRATEGY" --dry-run --verbose
          else
            ./buddy update --strategy "$STRATEGY" --verbose
          fi

      - name: Auto-merge updates
        if: \${{ ${j.autoMerge?"true":"false"} }}
        run: |
          echo "Auto-merge is enabled for this workflow"

          # Check if conditions are met for auto-merge
          STRATEGY="\${{ github.event.inputs.strategy || '${j.strategy||"all"}' }}"
          AUTO_MERGE_STRATEGY="${typeof j.autoMerge==="object"?j.autoMerge.strategy||"squash":"squash"}"

          echo "Update strategy: $STRATEGY"
          echo "Auto-merge strategy: $AUTO_MERGE_STRATEGY"

          # Enable auto-merge for created PRs
          # This will be implemented when the PR creation logic is fully integrated
          # For now, this step serves as a placeholder and configuration validation

          if [ "$STRATEGY" = "patch" ]; then
            echo "\u2705 Patch updates are eligible for auto-merge"
          else
            echo "\u2139\uFE0F Only patch updates are auto-merged by default"
          fi
`}static generateScheduledWorkflows(j){let p=j?.pullRequest?.autoMerge,x=j?.pullRequest?.reviewers||[],q=j?.pullRequest?.labels||[],B=p?.enabled&&p.conditions?.includes("patch-only")?p:p?.enabled??!0,D=p?.enabled&&!p.conditions?.includes("patch-only")?p:!1,F=!1;return{"dependency-updates-daily.yml":this.generateWorkflow({name:"Daily Dependency Updates",schedule:j?.schedule?.cron||"0 2 * * *",strategy:"patch",autoMerge:B,reviewers:x,labels:q}),"dependency-updates-weekly.yml":this.generateWorkflow({name:"Weekly Dependency Updates",schedule:"0 2 * * 1",strategy:"minor",autoMerge:D,reviewers:x,labels:q}),"dependency-updates-monthly.yml":this.generateWorkflow({name:"Monthly Dependency Updates",schedule:"0 2 1 * *",strategy:"major",autoMerge:!1,reviewers:x,labels:q})}}static generateComprehensiveWorkflow(j){return`name: Buddy Dependency Updates

on:
  schedule:
    # Patch updates daily at 2 AM
    - cron: '0 2 * * *'
    # Minor updates twice weekly at 2 AM (Monday, Thursday)
    - cron: '0 2 * * 1,4'
    # Major updates monthly at 2 AM (first of month)
    - cron: '0 2 1 * *'

  workflow_dispatch:
    inputs:
      strategy:
        description: 'Update strategy'
        required: true
        default: 'all'
        type: choice
        options:
          - all
          - major
          - minor
          - patch
      dry_run:
        description: 'Dry run (preview only)'
        required: false
        default: false
        type: boolean
      packages:
        description: 'Specific packages (comma-separated)'
        required: false
        type: string

env:
  GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}

permissions:
  contents: write
  pull-requests: write
  issues: write
  actions: read
  checks: read
  statuses: read

jobs:
  determine-strategy:
    runs-on: ubuntu-latest
    outputs:
      strategy: \${{ steps.strategy.outputs.strategy }}
      auto_merge: \${{ steps.strategy.outputs.auto_merge }}
    steps:
      - name: Determine update strategy
        id: strategy
        run: |
          if [ "\${{ github.event_name }}" = "workflow_dispatch" ]; then
            echo "strategy=\${{ github.event.inputs.strategy }}" >> $GITHUB_OUTPUT
            echo "auto_merge=false" >> $GITHUB_OUTPUT
          elif [ "\${{ github.event.schedule }}" = "0 2 * * *" ]; then
            echo "strategy=patch" >> $GITHUB_OUTPUT
            echo "auto_merge=true" >> $GITHUB_OUTPUT
          elif [ "\${{ github.event.schedule }}" = "0 2 * * 1,4" ]; then
            echo "strategy=minor" >> $GITHUB_OUTPUT
            echo "auto_merge=false" >> $GITHUB_OUTPUT
          else
            echo "strategy=major" >> $GITHUB_OUTPUT
            echo "auto_merge=false" >> $GITHUB_OUTPUT
          fi

  dependency-updates:
    runs-on: ubuntu-latest
    needs: determine-strategy

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: \${{ secrets.GITHUB_TOKEN }}

      - name: Setup Bun
        uses: oven-sh/setup-bun@v2
\${GitHubActionsTemplate.generateComposerSetupSteps()}
      - name: Install dependencies
        run: bun install

      - name: Build buddy-bot
        run: bun run build

      - name: Scan for updates
        run: |
          STRATEGY="\${{ needs.determine-strategy.outputs.strategy }}"
          PACKAGES="\${{ github.event.inputs.packages || '' }}"

          if [ "$PACKAGES" != "" ]; then
            ./buddy scan --packages "$PACKAGES" --verbose
          else
            ./buddy scan --strategy "$STRATEGY" --verbose
          fi

      - name: Apply updates
        if: \${{ github.event.inputs.dry_run != 'true' }}
        run: |
          STRATEGY="\${{ needs.determine-strategy.outputs.strategy }}"
          PACKAGES="\${{ github.event.inputs.packages || '' }}"

          if [ "$PACKAGES" != "" ]; then
            ./buddy update --packages "$PACKAGES" --verbose
          else
            ./buddy update --strategy "$STRATEGY" --verbose
          fi

      - name: Dry run mode
        if: \${{ github.event.inputs.dry_run == 'true' }}
        run: |
          echo "\uD83D\uDD0D Dry run mode - showing what would be updated"
          STRATEGY="\${{ needs.determine-strategy.outputs.strategy }}"
          PACKAGES="\${{ github.event.inputs.packages || '' }}"

          if [ "$PACKAGES" != "" ]; then
            ./buddy update --packages "$PACKAGES" --dry-run --verbose
          else
            ./buddy update --strategy "$STRATEGY" --dry-run --verbose
          fi

      - name: Auto-merge eligible updates
        if: \${{ needs.determine-strategy.outputs.auto_merge == 'true' && github.event.inputs.dry_run != 'true' }}
        run: |
          echo "\uD83E\uDD16 Auto-merge enabled for patch updates"
          echo "This feature will be implemented in future versions"
`}static generateDockerWorkflow(j){return`name: Buddy Dependencies (Docker)

on:
  schedule:
    - cron: '0 2 * * 1' # Weekly on Monday
  workflow_dispatch:

jobs:
  dependency-updates:
    runs-on: ubuntu-latest
    container:
      image: oven/bun:latest

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install dependencies
        run: bun install

      - name: Run Buddy updates
        run: bunx buddy-bot update --verbose
        env:
          GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
`}static generateMonorepoWorkflow(j){return`name: Buddy Monorepo Updates

on:
  schedule:
    - cron: '0 2 * * 1'
  workflow_dispatch:
    inputs:
      workspace:
        description: 'Workspace to update'
        required: false
        type: string

jobs:
  find-workspaces:
    runs-on: ubuntu-latest
    outputs:
      workspaces: \${{ steps.workspaces.outputs.workspaces }}
    steps:
      - uses: actions/checkout@v4
      - name: Find workspaces
        id: workspaces
        run: |
          if [ "\${{ github.event.inputs.workspace }}" != "" ]; then
            echo "workspaces=["\${{ github.event.inputs.workspace }}"]" >> $GITHUB_OUTPUT
          else
            # Find all package.json files
            WORKSPACES=$(find . -name "package.json" -not -path "./node_modules/*" | sed 's|/package.json||' | sed 's|^./||' | jq -R . | jq -s .)
            echo "workspaces=$WORKSPACES" >> $GITHUB_OUTPUT
          fi

  update-workspace:
    needs: find-workspaces
    runs-on: ubuntu-latest
    strategy:
      matrix:
        workspace: \${{ fromJson(needs.find-workspaces.outputs.workspaces) }}

    steps:
      - uses: actions/checkout@v4
      - uses: oven-sh/setup-bun@v2

      - name: Install dependencies
        run: bun install

      - name: Update workspace dependencies
        run: |
          cd \${{ matrix.workspace }}
          bunx buddy-bot update --verbose
        env:
          GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}
`}static generateTestingWorkflow(j){return`name: Buddy Update

on:
  schedule:
    - cron: '*/20 * * * *' # Every 20 minutes for testing
  workflow_dispatch: # Manual triggering for development
    inputs:
      strategy:
        description: 'Update strategy'
        required: false
        default: 'patch'
        type: choice
        options:
          - all
          - major
          - minor
          - patch
      dry_run:
        description: 'Dry run (preview only)'
        required: false
        default: true
        type: boolean
      packages:
        description: 'Specific packages (comma-separated)'
        required: false
        type: string
      verbose:
        description: 'Enable verbose logging'
        required: false
        default: true
        type: boolean

env:
  GITHUB_TOKEN: \${{ secrets.GITHUB_TOKEN }}

permissions:
  contents: write
  pull-requests: write
  issues: write
  actions: read
  checks: read
  statuses: read

jobs:
  dependency-update:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
        with:
          token: \${{ secrets.GITHUB_TOKEN }}

      - name: Setup Bun
        uses: oven-sh/setup-bun@v2
\${GitHubActionsTemplate.generateComposerSetupSteps()}
      - name: Install dependencies
        run: bun install

      - name: Build buddy-bot
        run: bun run build

      - name: Display test configuration
        run: |
          echo "\uD83E\uDDEA **Buddy Bot Testing Mode**"
          echo "Strategy: \${{ github.event.inputs.strategy || 'patch' }}"
          echo "Dry Run: \${{ github.event.inputs.dry_run || 'true' }}"
          echo "Packages: \${{ github.event.inputs.packages || 'all' }}"
          echo "Verbose: \${{ github.event.inputs.verbose || 'true' }}"
          echo "Triggered by: \${{ github.event_name }}"
          echo "Repository: \${{ github.repository }}"
          echo "Branch: \${{ github.ref_name }}"

      - name: Run Buddy dependency scan
        run: |
          STRATEGY="\${{ github.event.inputs.strategy || 'patch' }}"
          PACKAGES="\${{ github.event.inputs.packages }}"
          VERBOSE="\${{ github.event.inputs.verbose || 'true' }}"

          echo "\uD83D\uDD0D Scanning for dependency updates..."

          if [ "$PACKAGES" != "" ]; then
            if [ "$VERBOSE" = "true" ]; then
              ./buddy scan --packages "$PACKAGES" --verbose
            else
              ./buddy scan --packages "$PACKAGES"
            fi
          else
            if [ "$VERBOSE" = "true" ]; then
              ./buddy scan --strategy "$STRATEGY" --verbose
            else
              ./buddy scan --strategy "$STRATEGY"
            fi
          fi

      - name: Run Buddy dependency updates
        if: \${{ github.event.inputs.dry_run != 'true' }}
        run: |
          STRATEGY="\${{ github.event.inputs.strategy || 'patch' }}"
          PACKAGES="\${{ github.event.inputs.packages }}"
          VERBOSE="\${{ github.event.inputs.verbose || 'true' }}"

          echo "\uD83D\uDE80 Running dependency updates..."

          if [ "$PACKAGES" != "" ]; then
            if [ "$VERBOSE" = "true" ]; then
              ./buddy update --packages "$PACKAGES" --verbose
            else
              ./buddy update --packages "$PACKAGES"
            fi
          else
            if [ "$VERBOSE" = "true" ]; then
              ./buddy update --strategy "$STRATEGY" --verbose
            else
              ./buddy update --strategy "$STRATEGY"
            fi
          fi

      - name: Dry run notification
        if: \${{ github.event.inputs.dry_run == 'true' }}
        run: |
          echo "\u2139\uFE0F **Dry Run Mode** - No changes were made"
          echo "To apply updates, run this workflow again with 'Dry run' set to false"

      - name: Create test summary
        if: always()
        run: |
          echo "## \uD83E\uDDEA Buddy Bot Testing Summary" >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY
          echo "- **Strategy**: \${{ github.event.inputs.strategy || 'patch' }}" >> $GITHUB_STEP_SUMMARY
          echo "- **Triggered by**: \${{ github.event_name }}" >> $GITHUB_STEP_SUMMARY
          echo "- **Dry run**: \${{ github.event.inputs.dry_run || 'true' }}" >> $GITHUB_STEP_SUMMARY
          echo "- **Packages**: \${{ github.event.inputs.packages || 'all' }}" >> $GITHUB_STEP_SUMMARY
          echo "- **Verbose**: \${{ github.event.inputs.verbose || 'true' }}" >> $GITHUB_STEP_SUMMARY
          echo "- **Time**: $(date)" >> $GITHUB_STEP_SUMMARY
          echo "" >> $GITHUB_STEP_SUMMARY

          if [ "\${{ github.event_name }}" = "schedule" ]; then
            echo "\u23F0 **Scheduled Run**: This was triggered automatically every 20 minutes" >> $GITHUB_STEP_SUMMARY
            echo "\uD83D\uDCA1 **Tip**: Use 'Actions' tab to manually trigger with custom settings" >> $GITHUB_STEP_SUMMARY
          else
            echo "\uD83D\uDDB1\uFE0F **Manual Trigger**: This was triggered manually from the Actions tab" >> $GITHUB_STEP_SUMMARY
            echo "\u23F0 **Auto-Schedule**: This workflow also runs every 20 minutes for testing" >> $GITHUB_STEP_SUMMARY
          fi

          echo "" >> $GITHUB_STEP_SUMMARY
          echo "\uD83D\uDCCA View detailed logs above for scan and update results." >> $GITHUB_STEP_SUMMARY
`}static generateCustomWorkflow(j,p){let x=!1;if(j.autoMerge!==void 0)x=j.autoMerge;else if(p?.pullRequest?.autoMerge){let q=p.pullRequest.autoMerge;if(q.enabled){if(q.conditions?.includes("patch-only")&&j.strategy==="patch")x=q;else if(!q.conditions?.includes("patch-only"))x=q}}return this.generateWorkflow({name:j.name,schedule:j.schedule,strategy:j.strategy||"all",autoMerge:x,reviewers:j.reviewers||p?.pullRequest?.reviewers||[],labels:j.labels||p?.pullRequest?.labels||[]})}}
export{E as b};

//# debugId=6C6ABA4B99F9375764756E2164756E21
