{
  "folders": [
    {
      "name": "🎯 Root",
      "path": ".",
    },
    {
      "name": "🔧 Backend",
      "path": "backend",
    },
    {
      "name": "🎨 Frontend",
      "path": "frontend",
    },
    {
      "name": "🔗 specs",
      "path": "specs",
    },
  ],
  "settings": {
    // ========================================
    // EDITOR SETTINGS
    // ========================================

    "editor.fontSize": 20,
    "editor.tabSize": 2,
    "editor.lineHeight": 1.6,
    "editor.rulers": [80, 120],
    "editor.minimap.enabled": true,
    "editor.minimap.sectionHeaderFontSize": 14,
    "editor.renderWhitespace": "selection",
    // "editor.renderWhitespace": "boundary",
    "editor.renderControlCharacters": true,
    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs": "active",
    "editor.smoothScrolling": true,
    "editor.cursorBlinking": "smooth",
    "editor.cursorSmoothCaretAnimation": "on",
    "editor.wordWrap": "off",
    "editor.linkedEditing": true,
    "editor.formatOnSave": true,
    "editor.formatOnPaste": true,
    "editor.suggestSelection": "first",
    "editor.detectIndentation": true,

    // ========================================
    // DEFAULT FORMATTER
    // ========================================

    "editor.defaultFormatter": "esbenp.prettier-vscode",

    "[javascript]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[javascriptreact]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[typescript]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[typescriptreact]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[json]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[jsonc]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[html]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[css]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[scss]": {
      "editor.defaultFormatter": "esbenp.prettier-vscode",
    },
    "[markdown]": {
      "editor.defaultFormatter": "yzhang.markdown-all-in-one",
      "editor.wordWrap": "on",
    },
    "[yaml]": {
      "editor.defaultFormatter": "redhat.vscode-yaml",
    },
    "[dockerfile]": {
      "editor.defaultFormatter": "ms-azuretools.vscode-containers",
    },
    "[sql]": {
      "editor.defaultFormatter": "mtxr.sqltools",
      "editor.tabSize": 2,
      "editor.insertSpaces": true,
      "editor.detectIndentation": false,
      "editor.wordWrap": "off",
      "editor.formatOnSave": true,
    },
    "sqltools.format": {
      "indent": "  ", // 2 spaces
      "indentStyle": "space", // ใช้ space แทน tab
      "tabSize": 2,
      "reservedWordCase": "upper", // คำสงวนเป็นตัวพิมพ์ใหญ่ SELECT, FROM, WHERE
      "dataTypeCase": "lower", // varchar, int, datetime
      "functionCase": "lower", // count(), sum(), date_format()
      // Spacing and Lines
      "linesBetweenQueries": 2, // เว้นบรรทัดระหว่าง query
      //"denseOperators": true,
      "spaceAroundOperators": false,
      // Comma Style
      "commaPosition": "after", // ใส่ comma หลังคอลัมน์
      "newlineBeforeComma": false,
      "newlineAfterComma": false,
      // Parentheses Style
      "newlineBeforeOpenParen": false,
      "newlineAfterOpenParen": false,
      "newlineBeforeCloseParen": false,
      "newlineAfterCloseParen": false,
      // Width Control
      "expressionWidth": 120,
      "wrapLength": 120,
      // Other Styles
      "compact": true, // ไม่ย่อโค้ดให้แน่นเกินไป
      "uppercaseKeywords": true,
      "newlineBeforeSemicolon": false,
    },
    // ป้องกัน extension อื่นมายุ่ง

    // ========================================
    // CODE ACTION ON SAVE
    // ========================================

    "editor.codeActionsOnSave": {
      "source.fixAll": "explicit",
      "source.fixAll.prettier": "explicit",
      "source.fixAll.eslint": "explicit",
      //"source.organizeImports": "explicit",
      //"source.addMissingImports": "explicit"
    },

    // ========================================
    // PRETTIER SETTINGS .prettierrc
    // ========================================

    // ========================================
    // ESLINT SETTINGS
    // ========================================

    "eslint.enable": true,
    "eslint.validate": ["javascript", "javascriptreact", "typescript", "typescriptreact"],
    "eslint.alwaysShowStatus": true,
    "eslint.format.enable": false,
    "eslint.lintTask.enable": true,
    "eslint.workingDirectories": ["./backend", "./frontend"],
    // ========================================
    // PATH INTELLISENSE - ไม่มี src folder
    // ========================================

    "path-intellisense.mappings": {
      // Backend paths
      "@backend": "${workspaceFolder:🔧 Backend}/src",
      "@backend/*": "${workspaceFolder:🔧 Backend}/src/*",
      "@modules": "${workspaceFolder:🔧 Backend}/src/modules",
      "@common": "${workspaceFolder:🔧 Backend}/src/common",
      "@config": "${workspaceFolder:🔧 Backend}/src/common/config",
      "@circulation": "${workspaceFolder:🔧 Backend}/src/modules/circulation",
      "@correspondence": "${workspaceFolder:🔧 Backend}/src/modules/correspondence",
      "@document-numbering": "${workspaceFolder:🔧 Backend}/src/modules/document-numbering",
      "@drawing": "${workspaceFolder:🔧 Backend}/src/modules/drawing",
      "@json-schema": "${workspaceFolder:🔧 Backend}/src/modules/json-schema",
      "@master": "${workspaceFolder:🔧 Backend}/src/modules/master",
      "@monitoring": "${workspaceFolder:🔧 Backend}/src/modules/monitoring",
      "@notification": "${workspaceFolder:🔧 Backend}/src/modules/notification",
      "@project": "${workspaceFolder:🔧 Backend}/src/modules/project",
      "@rfa": "${workspaceFolder:🔧 Backend}/src/modules/rfa",
      "@search": "${workspaceFolder:🔧 Backend}/src/modules/search",
      "@transmittal": "${workspaceFolder:🔧 Backend}/src/modules/transmittal",
      "@users": "${workspaceFolder:🔧 Backend}/src/modules/users",
      "@workflow-engine": "${workspaceFolder:🔧 Backend}/src/modules/workflow-engine",

      // Frontend paths (ไม่มี src)
      "@": "${workspaceFolder:🎨 Frontend}/app",
      "@/*": "${workspaceFolder:🎨 Frontend}/app/*",
      "@app": "${workspaceFolder:🎨 Frontend}/app",
      "@components": "${workspaceFolder:🎨 Frontend}/components",
      "@fe-config": "${workspaceFolder:🎨 Frontend}/config",
      "@lib": "${workspaceFolder:🎨 Frontend}/lib",
      "@hooks": "${workspaceFolder:🎨 Frontend}/app/hooks",
      "@utils": "${workspaceFolder:🎨 Frontend}/utils",
      "@providers": "${workspaceFolder:🎨 Frontend}/providers",
      "@public": "${workspaceFolder:🎨 Frontend}/public",
      "@styles": "${workspaceFolder:🎨 Frontend}/styles",
      "@types": "${workspaceFolder:🎨 Frontend}/types",
      "@api": "${workspaceFolder:🎨 Frontend}/app/api",
    },
    "path-intellisense.autoSlashAfterDirectory": true,
    "path-intellisense.extensionOnImport": false,
    "path-intellisense.showHiddenFiles": false,

    // ========================================
    // ERROR LENS
    // ========================================

    "errorLens.enabled": true,
    "errorLens.enabledDiagnosticLevels": ["error", "warning"],
    "errorLens.padding": "0 1ch",
    "errorLens.messageTemplate": "$message",
    "errorLens.messageEnabled": true,

    // ========================================
    // TAILWIND CSS
    // ========================================

    "tailwindCSS.emmetCompletions": true,
    "tailwindCSS.colorDecorators": true,
    "tailwindCSS.suggestions": true,
    "tailwindCSS.includeLanguages": {
      "typescript": "javascript",
      "typescriptreact": "javascript",
    },
    "tailwindCSS.experimental.classRegex": [
      ["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
      ["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
      "class[Nn]ame\\s*=\\s*['\"`]([^'\"`]*)['\"`]",
    ],

    // ระบุที่ตั้งของ tailwind.config (ถ้ามี)
    "tailwindCSS.experimental.configFile": {
      //"backend/tailwind.config.js": "backend/**",
      "frontend/tailwind.config.ts": "frontend/**",
    },

    // ========================================
    // HEADWIND
    // ========================================

    "headwind.runOnSave": true,

    // ========================================
    // AUTO CLOSE/RENAME TAG
    // ========================================

    "auto-close-tag.activationOnLanguage": [
      "html",
      "xml",
      "javascript",
      "javascriptreact",
      "typescript",
      "typescriptreact",
    ],

    "auto-rename-tag.activationOnLanguage": [
      "html",
      "xml",
      "javascript",
      "javascriptreact",
      "typescript",
      "typescriptreact",
    ],

    // ========================================
    // BETTER COMMENTS
    // ========================================

    "better-comments.tags": [
      {
        "tag": "!",
        "color": "#FF2D00",
        "strikethrough": false,
        "backgroundColor": "transparent",
        "bold": true,
      },
      {
        "tag": "?",
        "color": "#3498DB",
        "strikethrough": false,
        "backgroundColor": "transparent",
      },
      {
        "tag": "//",
        "color": "#474747",
        "strikethrough": true,
        "backgroundColor": "transparent",
      },
      {
        "tag": "todo",
        "color": "#FF8C00",
        "strikethrough": false,
        "backgroundColor": "transparent",
      },
      {
        "tag": "*",
        "color": "#98C379",
        "strikethrough": false,
        "backgroundColor": "transparent",
      },
    ],

    // ========================================
    // TODO TREE
    // ========================================

    "todo-tree.general.tags": ["TODO", "FIXME", "BUG", "HACK", "NOTE", "XXX", "[ ]", "[x]"],
    "todo-tree.highlights.enabled": true,
    "todo-tree.tree.showScanModeButton": true,
    "todo-tree.filtering.excludeGlobs": ["**/node_modules", "**/dist", "**/build", "**/.next"],
    "todo-tree.highlights.customHighlight": {
      "TODO": {
        "icon": "check",
        "iconColour": "#FF8C00",
        "foreground": "#FF8C00",
      },
      "FIXME": {
        "icon": "alert",
        "iconColour": "#FF2D00",
        "foreground": "#FF2D00",
      },
      "BUG": {
        "icon": "bug",
        "iconColour": "#FF2D00",
        "foreground": "#FF2D00",
      },
      "NOTE": {
        "icon": "note",
        "iconColour": "#3498DB",
        "foreground": "#3498DB",
      },
      "HACK": {
        "icon": "tools",
        "iconColour": "#FFA500",
        "foreground": "#FFA500",
      },
    },
    // ========================================
    // GIT
    // ========================================

    "git.enabled": true,
    "git.autofetch": true,
    "git.autofetchPeriod": 180,
    "git.confirmSync": false,
    "git.enableSmartCommit": true,
    "git.postCommitCommand": "none",
    "git.untrackedChanges": "separate",
    "git.openRepositoryInParentFolders": "always",

    // ========================================
    // IMPORT COST
    // ========================================

    "importCost.showCalculatingDecoration": true,
    "importCost.largePackageSize": 100,
    "importCost.mediumPackageSize": 50,
    "importCost.smallPackageSize": 20,
    "importCost.largePackageColor": "#FF2D00",
    "importCost.mediumPackageColor": "#FF8C00",
    "importCost.smallPackageColor": "#98C379",

    // ========================================
    // JAVASCRIPT/TYPESCRIPT
    // ========================================

    "javascript.suggest.autoImports": true,
    "javascript.updateImportsOnFileMove.enabled": "always",
    "javascript.inlayHints.parameterNames.enabled": "all",
    "javascript.inlayHints.functionLikeReturnTypes.enabled": true,
    "javascript.inlayHints.variableTypes.enabled": false,
    "javascript.preferences.importModuleSpecifier": "relative",

    "typescript.suggest.autoImports": true,
    "typescript.updateImportsOnFileMove.enabled": "always",
    "typescript.inlayHints.parameterNames.enabled": "all",
    "typescript.inlayHints.functionLikeReturnTypes.enabled": true,
    "typescript.inlayHints.variableTypes.enabled": false,
    "typescript.inlayHints.propertyDeclarationTypes.enabled": true,
    "typescript.preferences.importModuleSpecifier": "relative",
    "typescript.tsdk": "node_modules/typescript/lib", // ✅ ใช้ relative path
    // ========================================
    // EMMET
    // ========================================

    "emmet.includeLanguages": {
      "javascript": "javascriptreact",
      "typescript": "typescriptreact",
    },
    "emmet.triggerExpansionOnTab": true,
    "emmet.showSuggestionsAsSnippets": true,

    // ========================================
    // FILES
    // ========================================

    //"files.autoSave": "onFocusChange",
    "files.trimTrailingWhitespace": true,
    "files.insertFinalNewline": true,
    "files.encoding": "utf8",
    "files.autoGuessEncoding": true,
    "files.eol": "\n",
    "files.associations": {
      "*.css": "tailwindcss",
      ".env*": "dotenv",
      "*.md": "markdown",
    },

    "files.exclude": {
      "**/.git": true,
      "**/.DS_Store": true,
      "**/node_modules": true,
      "**/.next": true,
      "**/dist": true,
      "**/build": true,
      "**/.turbo": true,
      "**/coverage": true,
      "**/.nyc_output": true,
      "**/*.log": true,
    },

    "files.watcherExclude": {
      "**/.git/objects/**": true,
      "**/.git/subtree-cache/**": true,
      "**/node_modules/**": true,
      "**/.next/**": true,
      "**/dist/**": true,
      "**/build/**": true,
      "**/.turbo/**": true,
    },

    // ========================================
    // SEARCH
    // ========================================

    "search.exclude": {
      "**/node_modules": true,
      "**/dist": true,
      "**/build": true,
      "**/.next": true,
      "**/.turbo": true,
      "**/coverage": true,
      "**/.nyc_output": true,
      "**/yarn.lock": true,
      "**/package-lock.json": true,
      "**/pnpm-lock.yaml": true,
      "**/*.log": true,
    },
    "search.followSymlinks": false,
    "search.useIgnoreFiles": true,
    "search.smartCase": true,

    // ========================================
    // TERMINAL
    // ========================================

    "terminal.integrated.fontSize": 15,
    "terminal.integrated.lineHeight": 1.2,
    "terminal.integrated.smoothScrolling": true,
    "terminal.integrated.cursorBlinking": true,
    "terminal.integrated.fontFamily": "MesloLGS NF, Consolas, monospace",
    "terminal.integrated.copyOnSelection": true,
    "terminal.integrated.tabs.defaultColor": "terminal.ansiBlue",
    "terminal.integrated.defaultProfile.windows": "PowerShell-7",
    "terminal.integrated.profiles.windows": {
      "PowerShell-7": {
        "path": "C:\\Program Files\\PowerShell\\7\\pwsh.exe",
        "icon": "terminal-powershell",
      },
      "SSH QNAP": {
        "path": "C:\\Windows\\System32\\OpenSSH\\ssh.exe",
        "args": ["qnap"],
        "icon": "terminal-linux",
        "color": "terminal.ansiGreen",
        "overrideName": true,
      },
      "SSH ASUSTOR": {
        "path": "C:\\Windows\\System32\\OpenSSH\\ssh.exe",
        "args": ["asustor"],
        "icon": "terminal-linux",
        "color": "terminal.ansiBlue",
        "overrideName": true,
      },
    },

    // ========================================
    // WORKBENCH
    // ========================================

    "workbench.iconTheme": "material-icon-theme",
    "workbench.activityBar.location": "default",
    "workbench.sideBar.location": "left",
    "workbench.view.alwaysShowHeaderActions": true,
    "workbench.tree.indent": 15,
    "workbench.list.smoothScrolling": true,
    "workbench.editor.enablePreview": false,
    "workbench.editor.limit.enabled": true,
    "workbench.editor.limit.value": 10,
    "workbench.startupEditor": "welcomePage",
    "workbench.view.showQuietly": {
      "workbench.panel.output": false,
    },
    // ========================================
    // EXPLORER
    // ========================================

    "explorer.compactFolders": false,
    "explorer.confirmDelete": true,
    "explorer.confirmDragAndDrop": false,
    "explorer.sortOrder": "type",
    "explorer.fileNesting.enabled": true,
    "explorer.fileNesting.expand": false,
    "explorer.fileNesting.patterns": {
      "package.json": "package-lock.json, yarn.lock, pnpm-lock.yaml, .npmrc",
      "tsconfig.json": "tsconfig.*.json",
      ".env": ".env.*",
      "docker-compose.yml": "docker-compose.*.yml, Dockerfile*",
      "*.ts": "${capture}.test.ts, ${capture}.spec.ts",
      "*.tsx": "${capture}.test.tsx, ${capture}.spec.tsx, ${capture}.module.css",
      "*.js": "${capture}.test.js, ${capture}.spec.js",
      "*.jsx": "${capture}.test.jsx, ${capture}.spec.jsx",
    },

    // ========================================
    // BREADCRUMBS
    // ========================================

    "breadcrumbs.enabled": true,
    "breadcrumbs.filePath": "on",
    "breadcrumbs.symbolPath": "on",

    // ========================================
    // JEST
    // ========================================

    // เปิดใช้งาน Jest extension
    "jest.enable": true,

    // ปิดการเปิด Terminal ตอนเปิด VS Code
    "jest.showTerminalOnLaunch": false,

    // ปิดการเปิด Terminal ตอนรันเทสต์
    "jest.showTerminalOnTestRun": false,

    // ให้รัน Jest ใน background โดยไม่ต้องเปิด terminal
    "jest.runInWorkspace": true,

    // แสดงผลลัพธ์เทสต์ใน editor (inline)
    "jest.showInlineError": true,

    // ใช้ watch mode สำหรับการรันเทสต์อัตโนมัติเมื่อไฟล์เปลี่ยน
    "jest.runMode": "watch",

    // กำหนด path ของ Jest ถ้าใช้ local install
    "jest.pathToJest": "node_modules/.bin/jest",

    "jest.disabledWorkspaceFolders": ["🎯 Root", "🗓️ docs", "🔗 specs", "🎨 Frontend"],

    // ========================================
    // DOCKER
    // ========================================

    "docker.languageserver.formatter.ignoreMultilineInstructions": true,
    "docker.showStartPage": false,

    // ========================================
    // YAML
    // ========================================

    "yaml.schemas": {
      "https://json.schemastore.org/prettierrc.json": ".prettierrc.{yml,yaml}",
      "https://json.schemastore.org/docker-compose.json": "docker-compose*.{yml,yaml}",
    },
    "yaml.format.enable": true,
    "yaml.format.singleQuote": false,
    "yaml.format.bracketSpacing": true,
    "yaml.validate": true,
    "yaml.hover": true,
    "yaml.completion": true,

    // ========================================
    // REST CLIENT
    // ========================================

    "rest-client.timeoutinmilliseconds": 30000,
    "rest-client.showResponseInDifferentTab": true,
    "rest-client.environmentVariables": {
      "$shared": {
        "apiUrl": "http://localhost:3000",
      },
      "development": {
        "apiUrl": "http://localhost:3000",
      },
      "production": {
        "apiUrl": "https://lcbp3.nap-dms.work",
      },
    },

    // ========================================
    // MATERIAL ICON THEME
    // ========================================

    "material-icon-theme.folders.theme": "specific",
    "material-icon-theme.folders.color": "#90a4ae",
    "material-icon-theme.files.associations": {
      "*.env.local": "Tune",
      "*.env.development": "Tune",
      "*.env.production": "Tune",
      "docker-compose.*.yml": "Docker",
    },
    "material-icon-theme.folders.associations": {
      "hooks": "Custom",
      "utils": "Helper",
      "lib": "Library",
      "components": "Components",
      "api": "Api",
      "dto": "Class",
      "entities": "Database",
      "modules": "Folder-Controllers",
      "common": "Shared",
      "config": "Config",
    },

    // ========================================
    // NPM INTELLISENSE
    // ========================================

    "npm-intellisense.importES6": true,
    "npm-intellisense.importQuotes": "'",
    "npm-intellisense.importLinebreak": ";\n",
    "npm-intellisense.importDeclarationType": "const",

    // ========================================
    // PERFORMANCE
    // ========================================

    "files.maxMemoryForLargeFilesMB": 1024,
    "telemetry.telemetryLevel": "off",
    "security.workspace.trust.untrustedFiles": "open",
    "extensions.ignoreRecommendations": true,
    // ========================================
    // DEBUGGING
    // ========================================

    "debug.console.fontSize": 16,
    "debug.console.fontFamily": "Consolas, 'Courier New', monospace",
    "debug.console.lineHeight": 20,
    "debug.console.wordWrap": false,
    "debug.internalConsoleOptions": "openOnSessionStart",
    "debug.openDebug": "openOnDebugBreak",
    "debug.showBreakpointsInOverviewRuler": true,
    "prettier.configPath": "./.prettierrc",
    "sqltools.connections": [
      {
        "mysqlOptions": {
          "authProtocol": "default",
          "enableSsl": "Disabled",
        },
        "ssh": "Disabled",
        "previewLimit": 50,
        "server": "localhost",
        "port": 3306,
        "driver": "MySQL",
        "name": "lcbp3_dev",
        "database": "lcbp3_dev",
        "username": "root",
        "password": "",
        "askForPassword": true, // ✅ ปลอดภัยกว่า
      },
    ],
    "database-client.variableIndicator": [":", "$"],
    "geminicodeassist.rules": "ใช้ภาษาไทยในการโต้ตอบ\n\n\n\n",
    "geminicodeassist.verboseLogging": true,
    "liveServer.settings.multiRootWorkspaceName": "🎯 Root",
    "vitest.commandLine": "npm run test --",
    "vitest.enable": true,
    "yaml.maxItemsComputed": 10000,
    "powershell.cwd": "🎯 Root",
    "files.autoSave": "onFocusChange",
    "diffEditor.codeLens": false,
    "workbench.colorTheme": "Default Dark Modern",
    "workbench.preferredDarkColorTheme": "Default Dark Modern",
    "scm.alwaysShowActions": false,
  },
  // ========================================
  // LAUNCH CONFIGURATIONS
  // ========================================
  "launch": {
    "version": "0.2.0",
    "configurations": [
      {
        "name": "🔧 Debug Backend (NestJS)",
        "type": "node",
        "request": "launch",
        "runtimeExecutable": "npm",
        "runtimeArgs": ["run", "start:debug"],
        "cwd": "${workspaceFolder:🔧 Backend}",
        "console": "integratedTerminal",
        // "internalConsoleOptions": "neverOpen",
        "skipFiles": ["<node_internals>/**"],
        "sourceMaps": true,
        "restart": true,
      },
      {
        "name": "🎨 Debug Frontend (Next.js)",
        "type": "node",
        "request": "launch",
        "cwd": "${workspaceFolder:🎨 Frontend}",
        "runtimeExecutable": "npm",
        "runtimeArgs": ["run", "dev"],
        "serverReadyAction": {
          "pattern": "- Local:.+(https?://\\S+)",
          "uriFormat": "%s",
          "action": "debugWithChrome",
        },
      },
      {
        "name": "🧪 Debug Backend Tests (Jest)",
        "type": "node",
        "request": "launch",
        "runtimeExecutable": "npm",
        "runtimeArgs": ["run", "test:debug"],
        "cwd": "${workspaceFolder:🔧 Backend}",
        "console": "integratedTerminal",
      },
      {
        "name": "🧪 Debug Frontend Tests (Vitest)",
        "type": "node",
        "request": "launch",
        "runtimeExecutable": "npm",
        "runtimeArgs": ["run", "test:debug"],
        "cwd": "${workspaceFolder:🎨 Frontend}",
        "console": "integratedTerminal",
        "internalConsoleOptions": "neverOpen",
      },
    ],

    "compounds": [
      {
        "name": "🚀 Debug Full Stack",
        "configurations": ["🔧 Debug Backend (NestJS)", "🎨 Debug Frontend (Next.js)"],
        "stopAll": true,
      },
    ],
  },
  // ========================================
  // TASKS
  // ========================================
  "tasks": {
    "version": "2.0.0",
    "tasks": [
      {
        "label": "🔧 Start Backend Dev",
        "type": "shell",
        "command": "npm run start:dev",
        "options": {
          "cwd": "${workspaceFolder:🔧 Backend}",
        },
        "problemMatcher": [],
        "isBackground": true,
        "presentation": {
          "reveal": "always",
          "panel": "dedicated",
          "group": "dev",
        },
      },
      {
        "label": "🎨 Start Frontend Dev",
        "type": "shell",
        "command": "npm run dev",
        "options": {
          "cwd": "${workspaceFolder:🎨 Frontend}",
        },
        "problemMatcher": [],
        "isBackground": true,
        "presentation": {
          "reveal": "always",
          "panel": "dedicated",
          "group": "dev",
        },
      },
      {
        "label": "🚀 Start Full Stack",
        "dependsOn": ["🔧 Start Backend Dev", "🎨 Start Frontend Dev"],
        "problemMatcher": [],
      },
      {
        "label": "🧪 Run Backend Tests",
        "type": "shell",
        "command": "npm run test",
        "options": {
          "cwd": "${workspaceFolder:🔧 Backend}",
        },
        "problemMatcher": [],
      },
      {
        "label": "🧪 Run Frontend Tests",
        "type": "shell",
        "command": "npm run test",
        "options": {
          "cwd": "${workspaceFolder:🎨 Frontend}",
        },
        "problemMatcher": [],
      },
      {
        "label": "🧪 Watch Backend Tests",
        "type": "shell",
        "command": "npm run test:watch",
        "options": {
          "cwd": "${workspaceFolder:🔧 Backend}",
        },
        "problemMatcher": [],
        "isBackground": true,
      },
      {
        "label": "🧪 Watch Frontend Tests",
        "type": "shell",
        "command": "npm run test:watch",
        "options": {
          "cwd": "${workspaceFolder:🎨 Frontend}",
        },
        "problemMatcher": [],
        "isBackground": true,
      },
      {
        "label": "🏗️ Build Backend",
        "type": "shell",
        "command": "npm run build",
        "options": {
          "cwd": "${workspaceFolder:🔧 Backend}",
        },
        "problemMatcher": ["$tsc"],
        "group": {
          "kind": "build",
          "isDefault": false,
        },
      },
      {
        "label": "🏗️ Build Frontend",
        "type": "shell",
        "command": "npm run build",
        "options": {
          "cwd": "${workspaceFolder:🎨 Frontend}",
        },
        "problemMatcher": ["$tsc"],
        "group": {
          "kind": "build",
          "isDefault": false,
        },
      },
      {
        "label": "🔍 Lint Backend",
        "type": "shell",
        "command": "npm run lint",
        "options": {
          "cwd": "${workspaceFolder:🔧 Backend}",
        },
        "problemMatcher": ["$eslint-stylish"],
      },
      {
        "label": "🔍 Lint Frontend",
        "type": "shell",
        "command": "npm run lint",
        "options": {
          "cwd": "${workspaceFolder:🎨 Frontend}",
        },
        "problemMatcher": ["$eslint-stylish"],
      },
      {
        "label": "🐳 Docker Compose Up",
        "type": "shell",
        "command": "docker-compose up -d",
        "options": {
          "cwd": "${workspaceFolder:🎯 Root}",
        },
        "problemMatcher": [],
      },
      {
        "label": "🐳 Docker Compose Down",
        "type": "shell",
        "command": "docker-compose down",
        "options": {
          "cwd": "${workspaceFolder:🎯 Root}",
        },
        "problemMatcher": [],
      },
      // 1. Task หลักที่จะรันอัตโนมัติเมื่อเปิดโปรแกรม
      {
        "label": "🚀 Setup Workspace",
        "dependsOn": ["🔧 PS: Backend", "🎨 PS: Frontend"], // สั่งให้รัน 2 task ย่อย
        "runOptions": {
          "runOn": "folderOpen", // <--- คำสั่งศักดิ์สิทธิ์: รันทันทีที่เปิด VS Code
        },
        "presentation": {
          "reveal": "never", // ไม่ต้องโชว์หน้าต่างของตัวคุมหลัก
        },
        "problemMatcher": [],
      },
      // 2. Task ย่อย: เปิด Terminal ที่ Backend
      {
        "label": "🔧 PS: Backend",
        "type": "shell",
        "command": "powershell", // สั่งเปิด PowerShell ค้างไว้
        "options": {
          "cwd": "${workspaceFolder:🔧 Backend}", // cd เข้า folder นี้
        },
        "isBackground": true, // บอก VS Code ว่าไม่ต้องรอให้จบ (รันค้างไว้เลย)
        "problemMatcher": [],
        "presentation": {
          "group": "workspace-terminals", // จัดกลุ่มเดียวกัน
          "reveal": "always",
          "panel": "dedicated", // แยก Tab ให้ชัดเจน
          "focus": false, // ไม่ต้องแย่ง Focus ทันที
        },
      },
      // 3. Task ย่อย: เปิด Terminal ที่ Frontend
      {
        "label": "🎨 PS: Frontend",
        "type": "shell",
        "command": "powershell",
        "options": {
          "cwd": "${workspaceFolder:🎨 Frontend}", // cd เข้า folder นี้
        },
        "isBackground": true,
        "problemMatcher": [],
        "presentation": {
          "group": "workspace-terminals",
          "reveal": "always",
          "panel": "dedicated",
          "focus": false, // ไม่ต้องแย่ง Focus ทันที
          // "focus": true // ให้ Focus ที่อันนี้เป็นอันสุดท้าย (พร้อมพิมพ์)
        },
      },
    ],
  },
  "extensions": {
    "recommendations": [],
  },
}
