"use strict";
/*
 * ATTENTION: An "eval-source-map" devtool has been used.
 * This devtool is neither made for production nor for readable output files.
 * It uses "eval()" calls to create a separate source file with attached SourceMaps in the browser devtools.
 * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
 * or disable the default devtool with "devtool: false".
 * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
 */
self["webpackHotUpdate_N_E"]("app/admin/knowledge/page",{

/***/ "(app-pages-browser)/./src/components/admin/ThemeCard.tsx":
/*!********************************************!*\
  !*** ./src/components/admin/ThemeCard.tsx ***!
  \********************************************/
/***/ (function(module, __webpack_exports__, __webpack_require__) {

eval(__webpack_require__.ts("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */   ThemeCard: function() { return /* binding */ ThemeCard; }\n/* harmony export */ });\n/* harmony import */ var react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! react/jsx-dev-runtime */ \"(app-pages-browser)/./node_modules/next/dist/compiled/react/jsx-dev-runtime.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! react */ \"(app-pages-browser)/./node_modules/next/dist/compiled/react/index.js\");\n/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var next_link__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! next/link */ \"(app-pages-browser)/./node_modules/next/dist/api/link.js\");\n/* harmony import */ var _components_ui_StatusBadge__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/components/ui/StatusBadge */ \"(app-pages-browser)/./src/components/ui/StatusBadge.tsx\");\n/* harmony import */ var _components_ui_Button__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @/components/ui/Button */ \"(app-pages-browser)/./src/components/ui/Button.tsx\");\n/* harmony import */ var _lib_pocketbase__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @/lib/pocketbase */ \"(app-pages-browser)/./src/lib/pocketbase.ts\");\n/* harmony import */ var _lib_services__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/lib/services */ \"(app-pages-browser)/./src/lib/services.ts\");\n/* __next_internal_client_entry_do_not_use__ ThemeCard auto */ \nvar _s = $RefreshSig$();\n\n\n\n\n\n\nfunction ThemeCard(param) {\n    let { theme, onUpdate } = param;\n    _s();\n    const [approving, setApproving] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);\n    const [rejecting, setRejecting] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);\n    const [toast, setToast] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null);\n    const [error, setError] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(null);\n    async function handleApprove() {\n        setApproving(true);\n        setError(null);\n        setToast(null);\n        try {\n            // 1. Fetch all topics in this theme\n            const topics = await _lib_pocketbase__WEBPACK_IMPORTED_MODULE_5__.pb.collection(\"topics\").getFullList({\n                filter: 'theme=\"'.concat(theme.id, '\"'),\n                fields: \"id\"\n            });\n            // 2. Publish all topics\n            await Promise.all(topics.map((t)=>_lib_pocketbase__WEBPACK_IMPORTED_MODULE_5__.pb.collection(\"topics\").update(t.id, {\n                    status: \"published\"\n                })));\n            // 3. Publish the theme\n            await _lib_pocketbase__WEBPACK_IMPORTED_MODULE_5__.pb.collection(\"themes\").update(theme.id, {\n                status: \"published\"\n            });\n            // 4. Trigger generation service\n            const { queued } = await (0,_lib_services__WEBPACK_IMPORTED_MODULE_6__.postGenerateAll)(theme.id);\n            setToast(\"Generation queued for \".concat(queued, \" micro-learnings\"));\n            onUpdate();\n        } catch (err) {\n            setError(err instanceof Error ? err.message : \"Approval failed\");\n        } finally{\n            setApproving(false);\n        }\n    }\n    async function handleReject() {\n        setRejecting(true);\n        setError(null);\n        try {\n            await _lib_pocketbase__WEBPACK_IMPORTED_MODULE_5__.pb.collection(\"themes\").update(theme.id, {\n                status: \"rejected\"\n            });\n            onUpdate();\n        } catch (err) {\n            setError(err instanceof Error ? err.message : \"Rejection failed\");\n        } finally{\n            setRejecting(false);\n        }\n    }\n    const isPublished = theme.status === \"published\";\n    const isRejected = theme.status === \"rejected\";\n    return /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n        style: {\n            background: \"var(--bg)\",\n            border: \"1.5px solid var(--cream)\",\n            borderRadius: \"var(--r-md)\",\n            padding: \"var(--s-4)\",\n            display: \"flex\",\n            flexDirection: \"column\",\n            gap: \"var(--s-3)\",\n            opacity: isRejected ? 0.6 : 1\n        },\n        children: [\n            /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                style: {\n                    display: \"flex\",\n                    alignItems: \"flex-start\",\n                    justifyContent: \"space-between\",\n                    gap: \"var(--s-3)\"\n                },\n                children: [\n                    /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                        style: {\n                            flex: 1,\n                            minWidth: 0\n                        },\n                        children: [\n                            /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"h3\", {\n                                style: {\n                                    margin: \"0 0 var(--s-1)\",\n                                    fontSize: \"var(--t-body)\",\n                                    fontWeight: 700,\n                                    color: \"var(--fg)\"\n                                },\n                                children: theme.title\n                            }, void 0, false, {\n                                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                                lineNumber: 82,\n                                columnNumber: 11\n                            }, this),\n                            /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"p\", {\n                                style: {\n                                    margin: 0,\n                                    fontSize: \"var(--t-small)\",\n                                    color: \"var(--fg-muted)\",\n                                    lineHeight: 1.5\n                                },\n                                children: theme.description\n                            }, void 0, false, {\n                                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                                lineNumber: 85,\n                                columnNumber: 11\n                            }, this)\n                        ]\n                    }, void 0, true, {\n                        fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                        lineNumber: 81,\n                        columnNumber: 9\n                    }, this),\n                    /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(_components_ui_StatusBadge__WEBPACK_IMPORTED_MODULE_3__.StatusBadge, {\n                        status: theme.status\n                    }, void 0, false, {\n                        fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                        lineNumber: 89,\n                        columnNumber: 9\n                    }, this)\n                ]\n            }, void 0, true, {\n                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                lineNumber: 80,\n                columnNumber: 7\n            }, this),\n            /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                style: {\n                    fontSize: \"var(--t-label)\",\n                    fontFamily: \"var(--font-mono)\",\n                    color: \"var(--fg-subtle)\",\n                    textTransform: \"uppercase\",\n                    letterSpacing: \"var(--label-ls)\"\n                },\n                children: [\n                    theme.source_documents.length,\n                    \" source doc\",\n                    theme.source_documents.length !== 1 ? \"s\" : \"\"\n                ]\n            }, void 0, true, {\n                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                lineNumber: 92,\n                columnNumber: 7\n            }, this),\n            toast && /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                style: {\n                    background: \"var(--success)\",\n                    color: \"var(--teal-900)\",\n                    borderRadius: \"var(--r-sm)\",\n                    padding: \"var(--s-2) var(--s-3)\",\n                    fontSize: \"var(--t-small)\",\n                    fontWeight: 500\n                },\n                children: toast\n            }, void 0, false, {\n                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                lineNumber: 105,\n                columnNumber: 9\n            }, this),\n            error && /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                style: {\n                    background: \"#f8d7da\",\n                    color: \"#c0392b\",\n                    borderRadius: \"var(--r-sm)\",\n                    padding: \"var(--s-2) var(--s-3)\",\n                    fontSize: \"var(--t-small)\"\n                },\n                children: error\n            }, void 0, false, {\n                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                lineNumber: 111,\n                columnNumber: 9\n            }, this),\n            /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(\"div\", {\n                style: {\n                    display: \"flex\",\n                    gap: \"var(--s-2)\",\n                    flexWrap: \"wrap\"\n                },\n                children: [\n                    !isRejected && /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(next_link__WEBPACK_IMPORTED_MODULE_2__[\"default\"], {\n                        href: \"/admin/knowledge/\".concat(theme.id),\n                        style: {\n                            textDecoration: \"none\"\n                        },\n                        children: /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(_components_ui_Button__WEBPACK_IMPORTED_MODULE_4__.Button, {\n                            variant: \"secondary\",\n                            size: \"sm\",\n                            children: \"Edit topics\"\n                        }, void 0, false, {\n                            fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                            lineNumber: 119,\n                            columnNumber: 13\n                        }, this)\n                    }, void 0, false, {\n                        fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                        lineNumber: 118,\n                        columnNumber: 11\n                    }, this),\n                    !isPublished && !isRejected && /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.Fragment, {\n                        children: [\n                            /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(_components_ui_Button__WEBPACK_IMPORTED_MODULE_4__.Button, {\n                                variant: \"primary\",\n                                size: \"sm\",\n                                onClick: ()=>void handleApprove(),\n                                loading: approving,\n                                children: \"Approve batch\"\n                            }, void 0, false, {\n                                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                                lineNumber: 124,\n                                columnNumber: 13\n                            }, this),\n                            /*#__PURE__*/ (0,react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV)(_components_ui_Button__WEBPACK_IMPORTED_MODULE_4__.Button, {\n                                variant: \"danger\",\n                                size: \"sm\",\n                                onClick: ()=>void handleReject(),\n                                loading: rejecting,\n                                children: \"Reject\"\n                            }, void 0, false, {\n                                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                                lineNumber: 127,\n                                columnNumber: 13\n                            }, this)\n                        ]\n                    }, void 0, true)\n                ]\n            }, void 0, true, {\n                fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n                lineNumber: 116,\n                columnNumber: 7\n            }, this)\n        ]\n    }, void 0, true, {\n        fileName: \"C:\\\\Users\\\\RaymondVerhoef\\\\Gitea\\\\learning-platform\\\\app\\\\frontend\\\\src\\\\components\\\\admin\\\\ThemeCard.tsx\",\n        lineNumber: 68,\n        columnNumber: 5\n    }, this);\n}\n_s(ThemeCard, \"qyOGNsXMqmwDEvqSEbV/iLZ9H5M=\");\n_c = ThemeCard;\nvar _c;\n$RefreshReg$(_c, \"ThemeCard\");\n\n\n;\n    // Wrapped in an IIFE to avoid polluting the global scope\n    ;\n    (function () {\n        var _a, _b;\n        // Legacy CSS implementations will `eval` browser code in a Node.js context\n        // to extract CSS. For backwards compatibility, we need to check we're in a\n        // browser context before continuing.\n        if (typeof self !== 'undefined' &&\n            // AMP / No-JS mode does not inject these helpers:\n            '$RefreshHelpers$' in self) {\n            // @ts-ignore __webpack_module__ is global\n            var currentExports = module.exports;\n            // @ts-ignore __webpack_module__ is global\n            var prevSignature = (_b = (_a = module.hot.data) === null || _a === void 0 ? void 0 : _a.prevSignature) !== null && _b !== void 0 ? _b : null;\n            // This cannot happen in MainTemplate because the exports mismatch between\n            // templating and execution.\n            self.$RefreshHelpers$.registerExportsForReactRefresh(currentExports, module.id);\n            // A module can be accepted automatically based on its exports, e.g. when\n            // it is a Refresh Boundary.\n            if (self.$RefreshHelpers$.isReactRefreshBoundary(currentExports)) {\n                // Save the previous exports signature on update so we can compare the boundary\n                // signatures. We avoid saving exports themselves since it causes memory leaks (https://github.com/vercel/next.js/pull/53797)\n                module.hot.dispose(function (data) {\n                    data.prevSignature =\n                        self.$RefreshHelpers$.getRefreshBoundarySignature(currentExports);\n                });\n                // Unconditionally accept an update to this module, we'll check if it's\n                // still a Refresh Boundary later.\n                // @ts-ignore importMeta is replaced in the loader\n                module.hot.accept();\n                // This field is set when the previous version of this module was a\n                // Refresh Boundary, letting us know we need to check for invalidation or\n                // enqueue an update.\n                if (prevSignature !== null) {\n                    // A boundary can become ineligible if its exports are incompatible\n                    // with the previous exports.\n                    //\n                    // For example, if you add/remove/change exports, we'll want to\n                    // re-execute the importing modules, and force those components to\n                    // re-render. Similarly, if you convert a class component to a\n                    // function, we want to invalidate the boundary.\n                    if (self.$RefreshHelpers$.shouldInvalidateReactRefreshBoundary(prevSignature, self.$RefreshHelpers$.getRefreshBoundarySignature(currentExports))) {\n                        module.hot.invalidate();\n                    }\n                    else {\n                        self.$RefreshHelpers$.scheduleUpdate();\n                    }\n                }\n            }\n            else {\n                // Since we just executed the code for the module, it's possible that the\n                // new exports made it ineligible for being a boundary.\n                // We only care about the case when we were _previously_ a boundary,\n                // because we already accepted this update (accidental side effect).\n                var isNoLongerABoundary = prevSignature !== null;\n                if (isNoLongerABoundary) {\n                    module.hot.invalidate();\n                }\n            }\n        }\n    })();\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64, \n//# sourceURL=webpack-internal:///(app-pages-browser)/./src/components/admin/ThemeCard.tsx\n"));

/***/ })

});